Functions, Objects & Arrays in Processing

As part of my exploration of the program Processing, I’ve been trying to work out the differences between Functions, Objects, and Arrays. In this first example, I made a car Function, where I can basically use one Function that describes the size of the rectangle to draw, and the relationship of the ‘wheels’ to the body of the car. I can make the color independent and here I call the car function three times, each with a different color. I can also offset the placement of the three cars, but since all three are tied to the same function, they move at the same speed, at the same distance from each other.

Rather than treating the car as a function, I can make a car object. This allows me to make as many cars as I like, all moving independently. I also decided to animate the yellow stripe on the road.

Adding an Array to the sketch, I can now cycle through a series of cars of each color that also decreases in size and opacity from the original, with the idea of adding a motion blur effect. I was too lazy to add the blur effect to the tires.

Leave a Reply