mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
459 lines
No EOL
10 KiB
HTML
459 lines
No EOL
10 KiB
HTML
<!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>
|
||
|
||
<p>Read only.</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’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.insertItems: <tt>Boolean</tt></tt> — controls whether newly created items are automatically inserted into the scene graph, by adding them to <a href="../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 <a href="../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>
|
||
</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’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[, options])</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> — 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>
|
||
</ul>
|
||
|
||
<ul class="member-list">
|
||
<h4>Parameters:</h4>
|
||
|
||
<li>
|
||
<tt>code:</tt>
|
||
<tt>String</tt>
|
||
— the PaperScript code
|
||
|
||
</li>
|
||
|
||
<li>
|
||
<tt>options:</tt>
|
||
<tt>Object</tt>
|
||
— the compilation options
|
||
— 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’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>⟋<a href="../classes/Size.html"><tt>Size</tt></a>
|
||
— the HTML canvas element this scope should be associated with, or an ID string by which to find the element, or the size of the canvas to be created for usage in a web worker.
|
||
|
||
</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>
|
||
|
||
|
||
<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>
|
||
|
||
|
||
|
||
<!-- =========================== copyright notice ========================== -->
|
||
<p class="footer">
|
||
Paper.js v0.12.7<br>
|
||
Copyright © 2011—2024 <a href="http://www.lehni.org" target="_blank">Jürg Lehni</a> & <a href="http://www.jonathanpuckey.com" target="_blank">Jonathan Puckey</a>. All Rights Reserved.</p>
|
||
<div class="content-end"></div>
|
||
|
||
|
||
</article>
|
||
</body> |