Language \ Environment \ Comparison
 
  Environment. The Processing Environment includes a text editor, a compiler, and a display window. It enables the creation of software within a carefully designed set of constraints.

Overview
Coordinates
Programming_modes

Overview

The Processing Environment consists of an integrated text editor and display window for showing programs. When the "run" button is pushed, the program compiles and plays in the graphic window. From the main environment window, it is possible to run, stop, save, open, and export files.



    

Coordinates

Processing uses a Cartesian coordinate system with the origin in the upper-left corner. If your program 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.



    

Programming_modes

Processing allows people to program within three levels of complexity: Static Mode, Active Mode, and Java Mode.


Static Mode

This mode is for drawing static images. The following example draws a yellow rectangle on the screen.

size(200, 200);
background(255);
noStroke();
fill(255, 204, 0);
rect(30, 20, 50, 50);

Active Mode

This mode provides an optional setup() section that is run once when the program begins. The loop() section runs forever until the program is stopped.

This example draws rectangles that follow the mouse position (stored in the variables mouseX and mouseY). Note also that the call to the background() method is in setup() because it's only needed once.
void setup()
{
  size(200, 200);
  background(255);
  rectMode(CENTER_DIAMETER);
  noStroke();
  fill(255, 204, 0);
}

void loop()
{
  rect(width-mouseX, height-mouseY, 50, 50);
  rect(mouseX, mouseY, 50, 50);
}

Java Mode (Not available until Processing 1.0 Beta)

This mode is the most flexible, and allows for writing complete Java programs from inside the Processing Environment

This example is the same as above, but done in the Java style:
public class MyDemo extends BApplet {
  void setup()
  {
    size(200, 200);
    background(255);
    rectMode(CENTER_DIAMETER);
    noStroke();
    fill(255, 204, 0);
  }

  void loop()
  {
    rect(width-mouseX, height-mouseY, 50, 50);
    rect(mouseX, mouseY, 50, 50);
  }
}
   
© 2002, 2001 Massachusetts Institute of Technology and Interaction Design Institute Ivrea
Processing is an open project initiated by Ben Fry and Casey Reas