Processing.js


Processing.js
Processing logo
Original author(s)John Resig
Developer(s)Processing Foundation
Initial release2008; 10 years ago (2008)
Stable release
1.4.8 / March 25, 2014; 4 years ago (2014-03-25)
Repository Edit this at Wikidata
Written inJavaScript
Size / /
TypeWeb application framework
LicenseMIT
Websiteprocessingjs.org

Processing.js is a JavaScript port of Processing, a programming language designed to write visualisations, images, and interactive content. It allows web browsers to display animations, visual applications, games and other graphical rich content without the need for a Java applet or Flash plugin.

Processing.js was originally created to allow existing Processing developers and existing code to work unmodified on web. Processing.js uses JavaScript to render 2D and 3D content on the HTML canvas element, and is supported by browsers that have implemented this element (the latest versions of Mozilla Firefox, Opera, Internet Explorer, Safari and Google Chrome).

The development of Processing.js was begun by John Resig and then picked up by students at Seneca College after its initial release in 2008. A team of students finished the port of Processing.js, fixing more than 900 bugs, shipping 12 releases, and creating a vibrant community in the process. The project was done through a partnership between the Mozilla Foundation and Seneca College, led by David Humphrey, Al MacDonald, and Corban Brook. The students continue to maintain the project today.

IDE

The Processing.js code is designed to be used with standalone text editors, or it may be built into an integrated development environment (IDE).

Following are the IDEs which support Processing.js:

  • Sketchpad puts processing on Etherpad, allowing authors to simultaneously edit a text document, and see all of the participants' edits in real-time, with the ability to display each author's text in their own color.
  • The Processing.js code can be edited in Processing helper tool.
  • Even the code can be designed by using Eclipse by importing packages using GitHub.

iPhone use

There exists an integration of the Processing.js library and a Javascript application framework for iPhone, called iProcessing.

Processing syntax

Processing.js syntax is almost identical to that of the Processing language, in that a setup function is used to define general visualization properties like canvas size, frame rate and other variables, and a draw function controls the behavior of each frame in the animation.

The Processing.js library can be included in head section of a web page as a single JavaScript file:

<html>
<head>
  <script type="text/javascript" src="processing.js"></script>
</head>

A canvas element is declared inside the body, with a data-processing-sources attribute, specifying the location of an external file holding the Processing code:

<canvas data-processing-sources="example.pde"></canvas>

Any extension can be used in the external file, for example, the .pde extension used by the Processing language sketch files.

/* example.pde */

// The statements in the setup function 
// execute once when the program begins
void setup 
{
  size(200, 200);  // Sets the canvas size to 200 by 200 pixels
  stroke(255);     // Set line drawing color to monochrome white
  frameRate(30);   // Set up draw to be called 30 times per second
}

float y = 100;

// The statements in draw are executed until the 
// program is stopped. The function is called as many
// times per second as the frameRate. If no explicit
// rate is set, this is 45 times per second.
void draw 
{ 
  background(0);   // Set the background to monochrome black
  y = y - 1; 
  if (y < 0) { y = height; } 
  line(0, y, width, y);  // draw a horizontal line at height y
}

Processing language has two ways of rendering a 2D or 3D in order to understand underlying graphic. It uses Java for 2D, and OpenGL for 3D. This code demonstrates the rendering . The size function provide choice to choose 2D or 3D. To create a 2D sketch that is 100 by 100 pixels. size(100, 100, P2D);
To draw a 3D sketch OpenGL is used: size(100, 100, OPENGL);

p5.js

Lauren McCarthy created p5.js,[1] a native JavaScript alternative and successor to Processing.js that has the official support of the Processing Foundation. McCarthy also teaches an introductory course to p5.js on Kadenze.

See also

References

External links


  This article uses material from the Wikipedia page available here. It is released under the Creative Commons Attribution-Share-Alike License 3.0.


Processing.js
 

Manage research, learning and skills at IT1me. Create an account using LinkedIn to manage and organize your IT knowledge. IT1me works like a shopping cart for information -- helping you to save, discuss and share.


  Contact Us  |  About IT1me.com |  IT Training & References |  IT Careers |  IT Hardware |  IT Software |  IT Books