javascript - Unable to run paper.js from .html file -
dear didn't find normal explanation decided ask help. want create paper.js project in html file. problem cannot connect them tried use var scope = new paper.paperscope(); scope.setup(mycanvas);
but didn't work out. here code taken paper.js web site
<!doctype html> <html> <head> <!-- load paper.js library --> <script type="text/javascript" src="paper.js"></script> <!-- define inlined javascript --> <script type="text/javascript"> // executed our code once dom ready. var scope = new paper.paperscope(); scope.setup(mycanvas); var mypath = new path(); mypath.strokecolor = 'black'; // function called whenever user // clicks mouse in view: function onmousedown(event) { // add segment path @ position of mouse: mypath.add(event.point); } </script> </head> <body> <canvas id="mycanvas" resize></canvas> </body> </html>
but doesn't here... attention.
you should have @ tutorial: http://paperjs.org/tutorials/getting-started/using-javascript-directly/
here's working example:
<!doctype html> <html> <head> <!-- load paper.js library --> <script type="text/javascript" src="paper.min.js"></script> <!-- define inlined javascript --> <script type="text/javascript"> // executed our code once dom ready. window.onload = function() { // reference canvas object var canvas = document.getelementbyid('mycanvas'); // create empty project , view canvas: paper.setup(canvas); var mypath = new paper.path(); mypath.strokecolor = 'black'; // draw view now: paper.view.draw(); var tool = new paper.tool(); tool.onmousedown = function(event) { mypath.add(event.point); } } </script> </head> <body> <canvas id="mycanvas" resize></canvas> </body> </html>
Comments
Post a Comment