Processing (programming language)

From Wikipedia, the free encyclopedia

Jump to: navigation, search
Processing
Image:Processing-loading-logo.png
Paradigm object-oriented
Appeared in 2001
Latest release 1.0.3/ 2009-02-24; 44 days ago
Typing discipline strong
Influenced by Design by Numbers, Java, OpenGL, PostScript, C
OS Cross-platform
License GPL and LGPL
Website processing.org

Processing is an open source project initiated by Casey Reas and Benjamin Fry, both formerly of the Aesthetics and Computation Group at the MIT Media Lab. It is "a programming language and integrated development environment (IDE) built for the electronic arts and visual design communities", which aims to teach the basics of computer programming in a visual context, and to serve as the foundation for electronic sketchbooks. One of the stated aims of Processing is to act as a tool to get non-programmers started with programming, through the instant gratification of visual feedback. The language builds on the graphical capabilities of the Java programming language, simplifying features and creating a few new ones.

Contents

[edit] Features

The Processing IDE

Processing includes a "sketchbook", a minimal alternative to an IDE for organizing projects.

When programming in Processing all classes defined will be treated as inner classes when the code is translated into pure Java before compiling. This means that the use of static variables and methods in classes is prohibited unless you explicitly tell Processing that you want to code in pure Java mode.

[edit] Hello World

void setup() {
  println("Hello World!");
}

While this is a valid Hello World program, the following code is a better example of the look and feel of the Processing language.

void setup() {
 // define the window size, and font we'll use. (antialiased)
 size(200, 200);
 PFont font = loadFont("Calibri-24.vlw");
 smooth();
 
 // Set "ink" color, font, and alignment for rendering text.
 fill(0);  // Black
 textAlign(CENTER);
 textFont(font);
 noLoop();  // draw() only once
}
 
void draw() {
 // Draw text to screen using the previously set font.
 text("Hello World!", width/2, height/2);
}

The next example show USA presidential election of 2008 results map. Blue denotes states won by Obama, and Red denotes those won by McCain.

PShape usa;
PShape state;
String [] Obama  = { "HI", "RI", "CT", "MA", "ME", "NH", "VT", "NY", "NJ",
	"FL", "NC", "OH", "IN", "IA", "CO", "NV", "PA", "DE", "MD", "MI",
	"WA", "CA", "OR", "IL", "MN", "WI", "DC", "NM", "VA" };
 
String [] McCain = { "AK", "GA", "AL", "TN", "WV", "KY", "SC", "WY", "MT",
	"ID", "TX", "AZ", "UT", "ND", "SD", "NE", "MS", "MO", "AR", "OK",
	"KS", "LA" };
 
void setup() {
  size(950, 600);
  // Blank_US_Map.svg file can be found at Wikimedia Commons
  // http://upload.wikimedia.org/wikipedia/commons/3/32/Blank_US_Map.svg
  usa = loadShape("Blank_US_Map.svg");
  smooth(); // Improves the drawing quality of the SVG
  noLoop();
}
 
void draw() {
  background(255);
  // Draw the full map
  shape(usa, 0, 0);
  // Blue denotes states won by Obama
  statesColoring(Obama , color(0, 51, 102));
  // Red  denotes states won by McCain
  statesColoring(McCain, color(153, 0, 0));
  // Save the map as image
  saveFrame("map output.png");
}
 
void statesColoring(String[] data, int c){
  for (int i = 0; i < data.length; ++i) {
    PShape state = usa.getChild(data[i]);
    // Disable the colors found in the SVG file
    state.disableStyle();
    // Set our own coloring
    fill(c);
    noStroke();
    // Draw a single state
    shape(state, 0, 0);
  }
}

[edit] Related projects

[edit] Design By Numbers

Processing was based on the original work done on Design By Numbers project in MIT. It shares much of the same ideas and is a direct child of that experiment.

[edit] Wiring, Arduino, and Fritzing

Processing has spawned another project, Wiring, which uses the Processing IDE together with a simplified version of the C programming language as a way to teach artists how to program microcontrollers. There are now two separate hardware projects, Wiring and Arduino, using the Wiring environment and language. Fritzing is another software environment within this family, which supports designers and artists to document their interactive prototypes and to take the step from physical prototyping to actual product.

[edit] Mobile Processing

Another spin-off project, Mobile Processing by Francis Li, allows software written using the Processing programming language and environment to run on Java powered mobile devices.

[edit] Processing.js

John Resig has recently ported Processing to JavaScript using the Canvas element for rendering,[1] allowing Processing to be used in modern web browsers without the need for a Java plugin.

[edit] Awards

In 2005 Reas and Fry won the prestigious Golden Nica award from Ars Electronica in its Net Vision category for their work on Processing.

[edit] License

The IDE is licensed under the GNU General Public License.

Processing's 'core' libraries, the code included in exported applications and applets, is licensed under the GNU Lesser General Public License, allowing the programmer to release their original code with their license of choice.

[edit] Name

Originally, Processing had the URL at proce55ing.org, because the "processing" domain was taken. Eventually, however, Reas and Fry acquired the domain. Although the name had a combination of letters and numbers, it was still pronounced "processing". They do not prefer the environment being referred to as "Proce55ing." But, despite the name change, Processing still uses the term "p5" sometimes as a shortened name. However, they specifically use "p5" and not "p55".

[edit] Books

[edit] See also

[edit] References

  1. ^ John Resig - Processing.js

[edit] External links

Personal tools