Question

In http://paperjs.org/examples/chain/ at source code line 16 you can see this:

var start = view.center / [10, 1];

I assume that this is some kind of 2D vector division. But how can someone define the type conversions at certain operations in javascript?
Or is this string parsed and translated into some other javascript code?

Was it helpful?

Solution

Quoting from the Paper.js Website:

What is PaperScript?

PaperScript is the plain old JavaScript that you are used to, with added support of mathematical operators (+ - * / %) for Point and Size objects. PaperScript code is automatically executed in its own scope that without polluting with the global scope still has access to all the global browser objects and functions, such as document or window.

By default, the Paper.js library only exports one object into the global scope: the paper object. It contains all the classes and objects that the library defines. When working with PaperScript, the user does not need to care about this though, because inside PaperScript code, through the use of clever scoping, all of paper's objects and functions seem global.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top