Beginning Work in Processing

The practical part of the first term of our second year is going to be based around the Java-based integrated development environment Processing in order to learn the basics of programming and eventually create a piece of interactive artwork using the program.

In a processing sketch conventionally there are two main functions, void setup, where any “background information” of the sketch (such as setting up arrays) is written and void draw, where functions that provide the output of the sketch are written.  Variables and objects are declared above both these functions. void setup is initialized at the start-up of the sketch whilst void draw is a looping function where the output is drawn at 30 fps.

sketch1code sketch 1 code a sketch1

Processing sketches begin at pixel (0,0) which is at the top left of the screen. The first value increase as you go right (along the x axis) and the second as you go down (along the y axis).

This sketch draws a line between the point (150, 25) and the mouse. The screen becomes progressively filled with lines as the mouse is moved as a new line is drawn every frame. However on each start-up of the sketch the background color is changed at random.

sketch2code sketch2

However moving the background function to the end of the code provides an output of a sketch with a rapidly changing colored background but no line-mouse output. The background function will overwrite the rest of the sketch.

Leave a Comment