You could try to call call paper.js with
c.type="text/paperscript";
and see if this helps. Or execute your code with PaperScript.execute(code, scope)
Question
I have a JavaScript file:
var canvas = document.createElement('canvas');
canvas.id = 'canvas1';
canvas.width = 400;
canvas.height = 400;
canvas.resize;
var e = document.createElement('script');
e.type = '/text/javascript/';
e.src = '/static/notebook/js/paper.js';
var c = document.createElement('script');
c.type = '/text/javascript/';
c.src = '/static/notebook/js/mypaper.js';
My mypaper.js file has the following function that is built into paper.js:
var d = document.getElementById('canvas1');
paper.setup(d);
function onFrame(event) { //this function does not run
console.log("test");
}
var raster = new paper.Raster('/static/notebook/js/turtle.png'); //this works?
but it does not run. I also noticed onkeydown does not work. I believe this has something to do with the PaperScope but I am unsure. I can create rasters, paths and lines, they all display fine, except the functions don't run. I am trying to get it to animate in IPython Notebook.
Solution
You could try to call call paper.js with
c.type="text/paperscript";
and see if this helps. Or execute your code with PaperScript.execute(code, scope)