Changes

Jump to: navigation, search

Processing.js for JavaScript Devs

3 bytes added, 16:35, 26 September 2010
It is possible to put Processing code directly in your web page
===It is possible to put Processing code directly in your web page===
Using the data-processing-sources attribute on the canvas, and having Processing.js load an external file is the preferred and recommend recommended way to include scripts in a web page. However, it is also possible to write in-line Processing code.
A few changes are necessary to make the example above work with inline Processing code:
</pre>
This code is more complex because it has to figure out which canvas goes with which script (i.e., you can have multiple Processing sketches living in the same page, and therefore, multiple canvsescanvases). Also note that the scripts include a '''type''' attribute, which distinguishes between JavaScript and Processing code (the browser will ignore Processing scripts). Finally, note the use of the '''id''' and '''target''' attributes to connect the Processing script with the associated canvas.
Portions of the code above are from the Processing.js project's '''init.js''' file, see http://github.com/annasob/processing-js/blob/0.9.8/examples/init.js. This file will likely be going away in the future, and happen automatically as part of Processing.js initialization.
40
edits

Navigation menu