<p>The <code>PaperScope</code> class represents the scope associated with a Paper context. When working with PaperScript, these scopes are automatically created for us, and through clever scoping the properties and methods of the active scope seem to become part of the global scope.</p>
<p>When working with normal JavaScript code, <code>PaperScope</code> objects need to be manually created and handled.</p>
<p>Paper classes can only be accessed through <code>PaperScope</code> objects. Thus in PaperScript they are global, while in JavaScript, they are available on the global <ahref="../classes/global.html#paper"><tt>paper</tt></a> object. For JavaScript you can use <ahref="../classes/PaperScope.html#install-scope"><tt>paperScope.install(scope)</tt></a> to install the Paper classes and objects on the global scope. Note that when working with more than one scope, this still works for classes, but not for objects like <ahref="../classes/PaperScope.html#project"><tt>paperScope.project</tt></a>, since they are not updated in the injected scope if scopes are switched.</p>
<p>The global <ahref="../classes/global.html#paper"><tt>paper</tt></a> object is simply a reference to the currently active <code>PaperScope</code>.</p>
<li><tt>settings.insertItems: <tt>Boolean</tt></tt>— controls whether newly created items are automatically inserted into the scene graph, by adding them to <ahref="../classes/Project.html#activelayer"><tt>project.activeLayer</tt></a>— default: <tt>true</tt></li>
<li><tt>settings.applyMatrix: <tt>Boolean</tt></tt>— controls what value newly created items have their <ahref="../classes/Item.html#applymatrix"><tt>item.applyMatrix</tt></a> property set to (Note that not all items can set this to <code>false</code>) — default: <tt>true</tt></li>
<li><tt>settings.handleSize: <tt>Number</tt></tt>— the size of the curve handles when drawing selections — default: <tt>4</tt></li>
<li><tt>settings.hitTolerance: <tt>Number</tt></tt>— the default tolerance for hit- tests, when no value is specified — default: <tt>0</tt></li>
<p>Compiles the PaperScript code into a compiled function and executes it. The compiled function receives all properties of this <ahref="../classes/PaperScope.html"><tt>PaperScope</tt></a> as arguments, to emulate a global scope with unaffected performance. It also installs global view and tool handlers automatically on the respective objects.</p>
<ulclass="member-list">
<h4>Options:</h4>
<li><tt>options.url: <tt>String</tt></tt>— the url of the source, for source-map debugging</li>
<li><tt>options.source: <tt>String</tt></tt>— the source to be used for the source- mapping, in case the code that’s passed in has already been mingled.</li>
<p>Injects the paper scope into any other given scope. Can be used for example to inject the currently active PaperScope into the window’s global scope, to emulate PaperScript-style globally accessible Paper classes and objects.</p>
<p><b>Please note:</b> Using this method may override native constructors (e.g. Path). This may cause problems when using Paper.js in conjunction with other libraries that rely on these constructors. Keep the library scoped if you encounter issues caused by this.</p>
<p>Sets up an empty project for us. If a canvas is provided, it also creates a <ahref="../classes/View.html"><tt>View</tt></a> for it, both linked to this scope.</p>
<ulclass="member-list">
<h4>Parameters:</h4>
<li>
<tt>element:</tt>
<tt>HTMLCanvasElement</tt>⟋<tt>String</tt>
— the HTML canvas element this scope should be associated with, or an ID string by which to find the element.
Copyright © 2011—2017 <ahref="http://www.lehni.org"target="_blank">Jürg Lehni</a>&<ahref="http://www.jonathanpuckey.com"target="_blank">Jonathan Puckey</a>. All Rights Reserved.</p>