Posts Tagged ‘sketch’

Run an External Processing.js Sketch

Wednesday, November 11th, 2009

It is very easy to load an external sketch with Processing.js. How easy?

Two lines easy!

 <script src="processing.min.js"></script>
 <canvas datasrc="init-example.pjs" width="200" height="200"></canvas>

Try this code

1) Include the “processing.js” JavaScript file.
2) Use the datasrc attribute to specify which Processing sketch you want to load.

This way the sketch is loaded using AJAX, so for security reasons you cannot run cross domain scripts.