Skip to content

Instantly share code, notes, and snippets.

@eligrey
Created August 26, 2009 00:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eligrey/175160 to your computer and use it in GitHub Desktop.
Save eligrey/175160 to your computer and use it in GitHub Desktop.
// this example script uses a user-submitted script to modify image
// data from a canvas in which the user drew art
var sandbox = new JSandbox(),
userArt = document.getElementById("userArt").getContext("2d"),
imageData = userArt.getImageData(0, 0, userArt.width, userArt.height);
sandbox.load("user-submitted-script.js", function () { // onload
this.eval("doStuffWithImageData(input)", function (modifiedImageData) {
userArt.putImageData(modifiedImageData, 0, 0);
this.terminate();
sandbox = null;
}, imageData);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment