I'm working on a project that requires me to control paper via javascript rather than using the normal paperscript route. I'm currently stuck because of a weird behavior that I can't seem to figure out. Here's a simplified version of the code I'm running
paper.install(window);
$(document).ready(function() {
paper.setup("canvas");
Game.ship = new Ship(view.center, 1) // Essentially calls new Raster("imgid"); and positions it
view.draw();
});
For some reason, this code is resulting in a blank canvas. What's weird is that if I call new Ship(...) in my dev console after a few seconds, the raster renders just fine on the canvas, as it should. I've also noticed that when I look at the value of Game.ship.elem.__canvas, I see a canvas element with a size of 32, 32, even though no such canvas exists in the DOM.
I'm assuming this has something to do with timing, but I can't seem to figure out what I have to do to make it work, other than the incredibly messy approach of using a setTimeout to create the raster a few seconds after $(document).ready() is called.
Anyone have any ideas as to what's going on here, or something that could lead me in the right direction?