Using Paperjs:
By specifying type="text/paperscript"
on your tag, you are loading your code as
PaperScript
rather than JavaScript
.
This means that Paper.js
will parse it first before passing it to the browser JavaScript
engine.
In order to parse your code, Paper.js
uses acorn, a parser library. And the version of acorn
bundled with Paper.js
doesn't support ES6
syntax.
What you can do to circumvent that, is loading a newer version of acorn
(that supports ES6
) before loading Paper.js
.
This is actually what is done on the Paper.js
playground: http://sketch.paperjs.org/
Here is a fiddle demonstrating the solution.
Note that I used https://unpkg.com to quickly load the latest versions of npm packages but you load them from wherever you want.
Debug