I am new to paperJS and I'm trying to include an external paperscript file in html, but it isn't working. While the inline scripting is working fine. My code are:
HTML Code:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="js/paper.js"></script>
</head>
<body>
<script type="text/paperscript" src = "js/myScript.js" canvas = "myCanvas" >
</script>
<canvas id="myCanvas" resize></canvas>
paperScript Code (myScript.js):
// Create a Paper.js Path to draw a line into it:
var path = new Path();
// Give the stroke a color
path.strokeColor = 'black';
var start = new Point(100, 100);
// Move to start and draw a line from there
path.moveTo(start);
// Note the plus operator on Point objects.
// PaperScript does that for us, and much more!
path.lineTo(start + [ 100, -50 ]);
I found an old link on stackOverflow which says that using version 0.9.10 fix the problem. But is that issue still not fixed in newer version? Here's the link:
This is not paperJs issue. Here I was trying to load a resource from the local file system, which chrome doesn't permit (Violation of its same-origin policy) and so we need a local web server.Why?
Local web server can be setup using WAMP (on Windows), MAMP (on OS X), LAMP(for ubuntu). It can aslo be setup by Python http-server and NodeJS http-server.