paper.js/dist/docs/classes/PaperScope.html

433 lines
No EOL
9.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>PaperScope</title>
<base target="class-frame">
<link href="../assets/css/docs.css" rel="stylesheet" type="text/css">
<script src="../assets/js/paper.js"></script>
<script src="../assets/js/jquery.js"></script>
<script src="../assets/js/codemirror.js"></script>
<script src="../assets/js/docs.js"></script>
</head>
<body>
<article class="reference">
<div class="reference-class">
<h1>PaperScope</h1>
<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 <a href="../classes/global.html#paper"><tt>paper</tt></a> object. For JavaScript you can use <a href="../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 <a href="../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 <a href="../classes/global.html#paper"><tt>paper</tt></a> object is simply a reference to the currently active <code>PaperScope</code>.</p>
</div>
<!-- =============================== constructors ========================== -->
<div class="reference-members">
<h2>Constructors</h2>
<div id="paperscope" class="member">
<div class="member-link">
<a name="paperscope" href="#paperscope"><tt><b>PaperScope</b>()</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Creates a PaperScope object.</p>
<ul class="member-list">
<h4>Returns:</h4>
<li>
<tt><a href="../classes/PaperScope.html"><tt>PaperScope</tt></a></tt>
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- ================================ properties =========================== -->
<div class="reference-members">
<h2>Properties</h2>
<div id="version" class="member">
<div class="member-link">
<a name="version" href="#version"><tt><b>version</b></tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>The version of Paper.js, as a string.</p>
<ul class="member-list">
<h4>Type:</h4>
<li>
<tt>String</tt>
</li>
</ul>
</div>
</div>
</div>
<div id="settings" class="member">
<div class="member-link">
<a name="settings" href="#settings"><tt><b>settings</b></tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Gives access to paper&rsquo;s configurable settings.</p>
<ul class="member-list">
<h4>Type:</h4>
<li>
<tt>Object</tt>
</li>
</ul>
<ul class="member-list">
<h4>Options:</h4>
<li><tt>settings.applyMatrix: <tt>Boolean</tt></tt> &mdash;&nbsp;default: <tt>true</tt></li>
<li><tt>settings.handleSize: <tt>Number</tt></tt> &mdash;&nbsp;default: <tt>4</tt></li>
<li><tt>settings.hitTolerance: <tt>Number</tt></tt> &mdash;&nbsp;default: <tt>0</tt></li>
</ul>
</div>
</div>
</div>
<div id="project" class="member">
<div class="member-link">
<a name="project" href="#project"><tt><b>project</b></tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>The currently active project.</p>
<ul class="member-list">
<h4>Type:</h4>
<li>
<a href="../classes/Project.html"><tt>Project</tt></a>
</li>
</ul>
</div>
</div>
</div>
<div id="projects" class="member">
<div class="member-link">
<a name="projects" href="#projects"><tt><b>projects</b></tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>The list of all open projects within the current Paper.js context.</p>
<ul class="member-list">
<h4>Type:</h4>
<li>
Array of <a href="../classes/Project.html"><tt>Project</tt></a> objects
</li>
</ul>
</div>
</div>
</div>
<div id="view" class="member">
<div class="member-link">
<a name="view" href="#view"><tt><b>view</b></tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>The reference to the active project&rsquo;s view.</p>
<p>Read only.</p>
<ul class="member-list">
<h4>Type:</h4>
<li>
<a href="../classes/View.html"><tt>View</tt></a>
</li>
</ul>
</div>
</div>
</div>
<div id="tool" class="member">
<div class="member-link">
<a name="tool" href="#tool"><tt><b>tool</b></tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>The reference to the active tool.</p>
<ul class="member-list">
<h4>Type:</h4>
<li>
<a href="../classes/Tool.html"><tt>Tool</tt></a>
</li>
</ul>
</div>
</div>
</div>
<div id="tools" class="member">
<div class="member-link">
<a name="tools" href="#tools"><tt><b>tools</b></tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>The list of available tools.</p>
<ul class="member-list">
<h4>Type:</h4>
<li>
Array of <a href="../classes/Tool.html"><tt>Tool</tt></a> objects
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- ============================== methods ================================ -->
<div class="reference-members">
<h2>Methods</h2>
<div id="execute-code" class="member">
<div class="member-link">
<a name="execute-code" href="#execute-code"><tt><b>execute</b>(code[, option])</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Compiles the PaperScript code into a compiled function and executes it. The compiled function receives all properties of this <a href="../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>
<ul class="member-list">
<h4>Options:</h4>
<li><tt>options.url: <tt>String</tt></tt> &mdash; the url of the source, for source-map debugging</li>
<li><tt>options.source: <tt>String</tt></tt> &mdash; the source to be used for the source- mapping, in case the code that&rsquo;s passed in has already been mingled.</li>
</ul>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>code:</tt>
<tt>String</tt>
&mdash;&nbsp;the PaperScript code
</li>
<li>
<tt>option:</tt>
<tt>Object</tt>
&mdash;&nbsp;the compilation options
&mdash;&nbsp;optional
</li>
</ul>
</div>
</div>
</div>
<div id="install-scope" class="member">
<div class="member-link">
<a name="install-scope" href="#install-scope"><tt><b>install</b>(scope)</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Injects the paper scope into any other given scope. Can be used for example to inject the currently active PaperScope into the window&rsquo;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>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>scope:</tt>
</li>
</ul>
<h4>Example:</h4>
<pre><code>paper.install(window);</code></pre>
</div>
</div>
</div>
<div id="setup-element" class="member">
<div class="member-link">
<a name="setup-element" href="#setup-element"><tt><b>setup</b>(element)</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Sets up an empty project for us. If a canvas is provided, it also creates a <a href="../classes/View.html"><tt>View</tt></a> for it, both linked to this scope.</p>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>element:</tt>
<tt>HTMLCanvasElement</tt><tt>String</tt>
&mdash;&nbsp;the HTML canvas element this scope should be associated with, or an ID string by which to find the element.
</li>
</ul>
</div>
</div>
</div>
<div id="activate" class="member">
<div class="member-link">
<a name="activate" href="#activate"><tt><b>activate</b>()</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Activates this PaperScope, so all newly created items will be placed in its active project.</p>
</div>
</div>
</div>
</div>
<div class="reference-members">
<h2>Static Methods</h2>
<div id="get-id" class="member">
<div class="member-link">
<a name="get-id" href="#get-id"><tt><b>PaperScope.get</b>(id)</tt></a>
</div>
<div class="member-description hidden">
<div class="member-text">
<p>Retrieves a PaperScope object with the given scope id.</p>
<ul class="member-list">
<h4>Parameters:</h4>
<li>
<tt>id:</tt>
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- =========================== copyright notice ========================== -->
<p class="footer">
Paper.js v0.9.25 (HEAD)<br>
Copyright &#169; 2011—2016 <a href="http://www.lehni.org" target="_blank">J&uuml;rg Lehni</a> &amp; <a href="http://www.jonathanpuckey.com" target="_blank">Jonathan Puckey</a>. All Rights Reserved.</p>
<div class="content-end"></div>
</article>
</body>