Processing.DynamicLoad History

Hide minor edits - Show changes to output - Cancel

April 08, 2014, at 04:07 PM by MichaelPaulukonis -
Added lines 1-39:
dynamic loading and unloading of sketch.


well, say you change the images for a PImage which has to be preloaded (NB: maybe not?)
or you want to change the canvas size, which has to be the first thing set up in setup.

(:source lang=javascript:)
Processing.loadSketchFromSources(canvas, ["pixel8.pde"]);

Also, dynamic '''unloading''' of previously loaded code, because otherwise it'll just start running again

(:source lang=javascript:)
var oldp = Processing.getInstanceById('jstest');
if (oldp) oldp.exit();

@@Processing.instances[n]@@ does not appear to work, despite assurances in [[|this bug]]

[[]] - not evaluated

TODO: some morel links to sources, and notes.

Also, I've found that pre-loading a PImage with a data-uri ''still'' takes time to load.

(:source lang=javascript:)

  // wait until image is REALLY loaded from URI
  // crude
  if (img.pixels.length <= 10) return;