Is there a sleep() function for Processing.js? If not what would be a suitable alternative to add a delay in the draw() loop?
I am using JQuery with Processing – can I use a JQuery or Javascript function to cause a sleep type delay in the loop?
Thanks!
Processing has a delay() function but unfortunately that is not implemented into Processing.js yet.
You can mix JS(JQuery,etc.) with Processing though.
Processing 1.9.9 has a Javascript mode now and there are examples for Processing/DOM integration, like SelectionFlower.
In the sketch/pde file there is a method setup to be called form js:
and in the js file, a timeout is set to make sure the sketch is initialized and can be accessed:
Then when the sketch instance is available, you can simply call a method/function on the sketch:
HTH