Writing sketches with JavaScript
Since Processing.js is actually JavaScript, you can use it as a library to write Processing sketches with pure JavaScript. In this recipe, we'll take a look at how you can do this. You'll need the minified Processing.js file you'd downloaded for the previous recipe.
How to do it...
You need to start by creating an HTML file that links the reset.css
and style.css
files we created in the Using Processing.js without the Processing editor recipe. We also need to link the minified Processing.js file and a new JavaScript file named mysketch.js
. Note that the <canvas>
tag doesn't have a data-processing-sources
attribute.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Using Processing.js without the Processing editor</title> <link rel="stylesheet" href="css/reset.css" media="screen" /> <link rel="stylesheet" href="css/style.css" media="screen" /> <script src="js/processing...