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 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.
- Basic :: For drawing static images.
- Continuous :: Provides a setup() section that is called once when the program begins, and a draw() section that is called over and over until the program stops.
- Java :: The most flexible mode which allows for writing complete Java programs from inside the Processing Environment.
- Compile :: Convert the program we write into code the computer understands.
- Run :: Execute the compiled code.
In the Processing environment, the program is automatically compiled and run when the button is pressed.
- Export :: Package the application in a JAR file and create a webpage for publishing.
- index.html :: Page for displaying applet
- xxx.jar :: Compressed java bytecode
- xxx.java :: Java source code
- xxx.pde :: Processing file with Processing code
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);