introduction

Processing is an open-source programming language developed by Ben Fry and Casey Reas. It is a derivative of the Java programming language, written by/for artists and designers. As such, it enables us to focus directly on graphical and interactive applications without having to concern ourselves with confusing tasks such as setting up class paths and compilation parameters, or menial procedures such as creating windows and setting up a graphics context.

Processing has an active community of users and a very useful website which should be your first stop when looking for answers, most notably the Reference and Discourse sections.

the environment

coordinate system

Processing uses a Cartesian coordinate system with the origin in the upper-left corner. The position of a pixel on the horizontal axis is referred to as the x-coordinate; the position on the vertical axis is called the y-coordinate. If your program window is 320 pixels wide and 240 pixels high, coordinate (0, 0) is the upper-left pixel and coordinate (320, 240) is in the lower right.

When working in three dimensions, the z-coordinate is the "depth" of the window, with 0 being at the surface of the image and negative values moving back in space.

modes

terminology

In the Processing environment, the program is automatically compiled and run when the button is pressed.

comments

A comment is a part of the source code that is not interpreted by the Java compiler. It's only purpose is to clarify the code to the human reader.

Single-line comments begin with //

// this is a single-line comment
			

Multi-line comment blocks begin with either /** or /* and end with */. Multi-line comments starting with /** are automatically added to the index.html page under the applet when you export your project.

/**
 * this is a
 * multi-line comment
 */

/*
 * this is another
 * multi-line 
 * comment
 */

Commenting your source code is very important as it can help others understand what's going on, as well as reminding you of what you were doing when you re-read your code in 6 months. However, you should be careful not to be redundant and not to over-saturate your code with comments. Here are some bad commenting examples:

// set the number of units to 12
numUnits = 12;

// set the size of the window to 500x500
size(500, 500);

debugging

Use print() or println() to check values in the output window.

Processing Workshop

Elie Zananiri
Alberta College of Art + Design
3-5 April 2008