paper 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/dist/docs/assets/js/paper.js +4565 -733
  3. package/dist/docs/classes/AreaText.html +720 -242
  4. package/dist/docs/classes/ChangeFlag.html +1 -1
  5. package/dist/docs/classes/Color.html +218 -21
  6. package/dist/docs/classes/CompoundPath.html +1146 -296
  7. package/dist/docs/classes/Curve.html +1 -1
  8. package/dist/docs/classes/CurveLocation.html +1 -1
  9. package/dist/docs/classes/DrawEvent.html +69 -0
  10. package/dist/docs/classes/Effect.html +434 -0
  11. package/dist/docs/classes/EffectInstance.html +304 -0
  12. package/dist/docs/classes/Event.html +1 -1
  13. package/dist/docs/classes/Gradient.html +1 -1
  14. package/dist/docs/classes/GradientStop.html +1 -1
  15. package/dist/docs/classes/Group.html +792 -243
  16. package/dist/docs/classes/HitResult.html +1 -1
  17. package/dist/docs/classes/HostItem.html +720 -242
  18. package/dist/docs/classes/Item.html +777 -242
  19. package/dist/docs/classes/Key.html +1 -1
  20. package/dist/docs/classes/KeyEvent.html +1 -1
  21. package/dist/docs/classes/Layer.html +734 -185
  22. package/dist/docs/classes/Matrix.html +1 -1
  23. package/dist/docs/classes/MouseEvent.html +1 -1
  24. package/dist/docs/classes/PaperScope.html +1 -1
  25. package/dist/docs/classes/PaperScript.html +4 -2
  26. package/dist/docs/classes/Path.html +1195 -252
  27. package/dist/docs/classes/PathItem.html +1148 -298
  28. package/dist/docs/classes/PathText.html +720 -242
  29. package/dist/docs/classes/PatternDefinition.html +367 -0
  30. package/dist/docs/classes/Point.html +1 -1
  31. package/dist/docs/classes/PointText.html +720 -242
  32. package/dist/docs/classes/Project.html +177 -7
  33. package/dist/docs/classes/Raster.html +720 -242
  34. package/dist/docs/classes/Rectangle.html +1 -1
  35. package/dist/docs/classes/Segment.html +3 -3
  36. package/dist/docs/classes/Shape.html +720 -242
  37. package/dist/docs/classes/Size.html +1 -1
  38. package/dist/docs/classes/StrokeProfileStop.html +346 -0
  39. package/dist/docs/classes/Style.html +1 -1
  40. package/dist/docs/classes/SymbolDefinition.html +28 -2
  41. package/dist/docs/classes/SymbolItem.html +720 -242
  42. package/dist/docs/classes/TextItem.html +720 -242
  43. package/dist/docs/classes/TextRange.html +1 -1
  44. package/dist/docs/classes/TextStory.html +1 -1
  45. package/dist/docs/classes/Tool.html +2 -2
  46. package/dist/docs/classes/ToolEvent.html +1 -1
  47. package/dist/docs/classes/Tween.html +1 -1
  48. package/dist/docs/classes/View.html +2 -2
  49. package/dist/docs/classes/global.html +1 -1
  50. package/dist/docs/classes/index.html +2 -2
  51. package/dist/docs/index.html +1 -1
  52. package/dist/node/browser.js +15 -0
  53. package/dist/paper-core.js +4476 -674
  54. package/dist/paper-core.min.js +3 -3
  55. package/dist/paper-full.js +4565 -733
  56. package/dist/paper-full.min.js +3 -3
  57. package/dist/paper-hosted.js +5111 -823
  58. package/dist/paper.d.ts +898 -47
  59. package/examples/Paperjs.org/LiveEffects.html +366 -0
  60. package/examples/Paperjs.org/Offsetting.html +379 -0
  61. package/examples/Paperjs.org/StrokeProfiles.html +706 -0
  62. package/examples/Scripts/Patterns.html +57 -0
  63. package/package.json +5 -3
@@ -113,10 +113,14 @@
113
113
  <div class="member-description hidden">
114
114
 
115
115
  <div class="member-text">
116
- <p>The host document that the project&rsquo;s items come from. Setting it creates the project&rsquo;s layers from the host&rsquo;s records. All items are created as shells that load their content and children from the host on first access.</p>
117
- <p>The host provides: - <code>getChildren(key)</code>, which returns the records of the children of the node with the given key, or of the top level for <code>null</code>, as columns: <code>keys</code>, <code>types</code> (indices into <code>typeNames</code>), <code>typeNames</code>, <code>flags</code> (selected: 1, visible: 2, locked: 4, strokeScaling: 8, clipMask: 64, guide: 128, empty: 256), <code>boxes</code> (bounds, strokeBounds and roughBounds in the item&rsquo;s coordinates, 12 numbers per item), and the sparse objects <code>names</code> and <code>matrices</code>. - <code>getItem(key)</code>, which returns the node&rsquo;s own content in the form of <a href="../classes/Item.html#importjson-json"><tt>item.importJSON(json)</tt></a>, without children. Linked text gives <code>linked</code>, the keys of its story&rsquo;s text items in order, and leaves out its story. - <code>getStory(key)</code>, for linked text, which returns its story with the key of any of its text items: <code>content</code> or <code>runs</code>, <code>paragraphs</code>, and the character and paragraph styles, as <a href="../classes/Item.html#exportjson-options"><tt>item.exportJSON(options)</tt></a> writes them in the JSON of a text item. - <code>getAncestorKeys(key)</code>, which returns the keys from the top level down to the node&rsquo;s parent. - Optionally <code>layOut(json, start, key)</code>, which lays out a text item from <code>start</code> in its story, given as the JSON string that <a href="../classes/Item.html#exportjson-options"><tt>item.exportJSON(options)</tt></a> writes of it as the script holds it, or as <code>null</code> where the script didn&rsquo;t change it since it loaded or the host took its changes with <a href="../classes/Project.html#takechanges"><tt>project.takeChanges</tt></a>(), for the host to lay out its own node, and returns <code>{ end, lines }</code>: where its visible text ends, and its lines, each <code>{ start, end, x, y, width, lineHeight, ascent,
116
+ <p>The host document that the project&rsquo;s items come from. Setting it creates the project&rsquo;s layers from the host&rsquo;s records. All items are created as shells that load their content and children from the host on first access. The host draws its items, so setting it also turns off <a href="../classes/View.html#autoupdate"><tt>view.autoUpdate</tt></a>, which would draw them all and load them in full.</p>
117
+ <p>The host provides: - <code>getChildren(key)</code>, which returns the records of the children of the node with the given key, or of the top level for <code>null</code>, as columns: <code>keys</code>, <code>types</code> (indices into <code>typeNames</code>), <code>typeNames</code>, <code>flags</code> (selected: 1, visible: 2, locked: 4, strokeScaling: 8, clipMask: 64, guide: 128, empty: 256), optionally <code>boxes</code> (bounds, strokeBounds and roughBounds in the item&rsquo;s coordinates, 12 numbers per item), and the sparse objects <code>names</code> and <code>matrices</code>. - <code>getBounds(key)</code>, for hosts that don&rsquo;t send <code>boxes</code>, which returns the node&rsquo;s 12 numbers, or <code>null</code> for an empty node. Items ask for them when their bounds are needed, and again after the host sent their record again. - <code>getItem(key)</code>, which returns the node&rsquo;s own content in the form of <a href="../classes/Item.html#importjson-json"><tt>item.importJSON(json)</tt></a>, without children. Linked text gives <code>linked</code>, the keys of its story&rsquo;s text items in order, and leaves out its story. Rasters give their <code>size</code> without a <code>source</code> and <code>crossOrigin</code>. - <code>getImage(key)</code>, for rasters, which returns the node&rsquo;s pixels as a canvas with a 2D context, of the size that <code>getItem()</code> gives. Rasters load them on first access to their pixels, and Paper.js never loads them by itself, except to draw them. Rasters whose pixels the host fails to give draw nothing. - <code>getStory(key)</code>, for linked text, which returns its story with the key of any of its text items: <code>content</code> or <code>runs</code>, <code>paragraphs</code>, and the character and paragraph styles, as <a href="../classes/Item.html#exportjson-options"><tt>item.exportJSON(options)</tt></a> writes them in the JSON of a text item. - <code>getAncestorKeys(key)</code>, which returns the keys from the top level down to the node&rsquo;s parent. - Optionally <code>layOut(json, start, key)</code>, which lays out a text item from <code>start</code> in its story, given as the JSON string that <a href="../classes/Item.html#exportjson-options"><tt>item.exportJSON(options)</tt></a> writes of it as the script holds it, or as <code>null</code> where the script didn&rsquo;t change it since it loaded or the host took its changes with <a href="../classes/Project.html#takechanges"><tt>project.takeChanges</tt></a>(), for the host to lay out its own node, and returns <code>{ end, lines }</code>: where its visible text ends, and its lines, each <code>{ start, end, x, y, width, lineHeight, ascent,
118
118
  descent, pieces }</code>, with pieces <code>{ start, end, x, y, dx, width,
119
- rotation, size, ascent, descent, lineHeight }</code> and an optional <code>content</code>, as for a hyphen, all in the item&rsquo;s coordinates. <code>key</code> is null for text that the host doesn&rsquo;t know yet. Without it, Paper.js lays out text itself.</p>
119
+ rotation, size, ascent, descent, lineHeight }</code> and an optional <code>content</code>, as for a hyphen, all in the item&rsquo;s coordinates. <code>key</code> is null for text that the host doesn&rsquo;t know yet. Without it, Paper.js lays out text itself. - <code>getDefinition(key)</code>, for the pattern and symbol definitions that the host shares between its items, which the JSON of its items refers to as <code>[&#39;@key&#39;]</code>, as in <code>fillColor: [&#39;pattern&#39;,
120
+ [&#39;@pattern/Dots&#39;], matrix]</code> or <code>definition: [&#39;@symbol/Star&#39;]</code>. It returns the definition in the form of <a href="../classes/Item.html#exportjson-options"><tt>item.exportJSON(options)</tt></a>, with its whole item: <code>[&#39;PatternDefinition&#39;, item, { tile, spacing }]</code> or <code>[&#39;SymbolDefinition&#39;, item]</code>, always: for a key that it has no definition of, an empty one of the type, as <code>[&#39;SymbolDefinition&#39;, [&#39;Group&#39;, {}]]</code>. Each definition loads once, and the JSON of the items that use it, as <a href="../classes/Item.html#exportjson-options"><tt>item.exportJSON(options)</tt></a> writes it, refers to it by its key again. Definitions that scripts create have no key, and are written out whole, until the host sets their <code>key</code>, which it can only set once. <a href="../classes/Project.html#takechanges"><tt>project.takeChanges</tt></a>() lists those that the changed items use first, nested ones first, as <code>{ definition, flags }</code> with the <code>ChangeFlag.INSERTION</code> flag, followed by the changes of the host&rsquo;s definitions. Renaming those isn&rsquo;t supported. - <code>getDefinitionKeys(type)</code>, which returns the keys of all the host&rsquo;s definitions of the type, <code>&#39;SymbolDefinition&#39;</code> or <code>&#39;PatternDefinition&#39;</code>, for <a href="../classes/Project.html#symboldefinitions"><tt>symbolDefinitions</tt></a> and <a href="../classes/Project.html#patterndefinitions"><tt>patternDefinitions</tt></a>.</p>
121
+ <p>Items that move into a project with another host load in full from their own host first, and drop their keys, so they are new items there. They bring copies without keys of the symbol and pattern definitions of their host along, shared by the items of one insertion or copy, so the new host takes them as new ones too. Linked text brings a copy of its story along, which flows on through the items that stay. Host items can&rsquo;t enter the project of another host.</p>
122
+ <p>The host draws the items, and the selection. To show what scripts draw in <a href="../classes/Item.html#ondraw"><tt>item.onDraw</tt></a> and <a href="../classes/Item.html#ondrawselection"><tt>item.onDrawSelection</tt></a>, it calls <code>project.draw(ctx, matrix, pixelRatio)</code>, which in a hosted project only calls these handlers, with the context, the view&rsquo;s matrix and pixel ratio that the host gives, for the visible items that have them, and for the selected ones. Handlers of classes, such as <code>Path.onDraw</code>, load all items once. The host asks <a href="../classes/Project.html#hasdrawhandlers"><tt>hasDrawHandlers</tt></a>() whether it needs to call it.</p>
123
+ <p><a href="../classes/Project.html#takechanges"><tt>project.takeChanges</tt></a>() marks the changes of the items whose children changed in order other than by new items inserted and items removed, which the other changes don&rsquo;t tell, with <code>reordered: true</code>: the host reads their children whole, and can place the others&rsquo; new items by their indices.</p>
120
124
 
121
125
 
122
126
 
@@ -160,6 +164,58 @@
160
164
 
161
165
 
162
166
 
167
+ </div>
168
+
169
+ </div>
170
+ </div>
171
+
172
+
173
+ <div id="onactivate" class="member">
174
+ <div class="member-link">
175
+ <a name="onactivate" href="#onactivate"><tt><b>onActivate</b></tt></a>
176
+ </div>
177
+ <div class="member-description hidden">
178
+
179
+ <div class="member-text">
180
+ <p>The function to be called when the project is activated through <a href="../classes/Project.html#activate"><tt>activate</tt></a>(). The function receives the previously active project, which is the project itself when it was already active.</p>
181
+
182
+
183
+
184
+ <ul class="member-list">
185
+ <h4>Type:</h4>
186
+ <li>
187
+ <tt>Function</tt>⟋<tt>null</tt>
188
+ </li>
189
+ </ul>
190
+
191
+
192
+
193
+ </div>
194
+
195
+ </div>
196
+ </div>
197
+
198
+
199
+ <div id="ondeactivate" class="member">
200
+ <div class="member-link">
201
+ <a name="ondeactivate" href="#ondeactivate"><tt><b>onDeactivate</b></tt></a>
202
+ </div>
203
+ <div class="member-description hidden">
204
+
205
+ <div class="member-text">
206
+ <p>The function to be called when another project is activated through <a href="../classes/Project.html#activate"><tt>activate</tt></a>() while this one is active, or when this one is removed while active.</p>
207
+
208
+
209
+
210
+ <ul class="member-list">
211
+ <h4>Type:</h4>
212
+ <li>
213
+ <tt>Function</tt>⟋<tt>null</tt>
214
+ </li>
215
+ </ul>
216
+
217
+
218
+
163
219
  </div>
164
220
 
165
221
  </div>
@@ -398,6 +454,34 @@ var path2 = new Path.Circle(new Point(175, 50), 20);
398
454
 
399
455
 
400
456
 
457
+ </div>
458
+
459
+ </div>
460
+ </div>
461
+
462
+
463
+ <div id="patterndefinitions" class="member">
464
+ <div class="member-link">
465
+ <a name="patterndefinitions" href="#patterndefinitions"><tt><b>patternDefinitions</b></tt></a>
466
+ </div>
467
+ <div class="member-description hidden">
468
+
469
+ <div class="member-text">
470
+ <p>The pattern definitions that the fill and stroke colors of the items in the project use.</p>
471
+
472
+ <p>Read only.</p>
473
+
474
+
475
+
476
+ <ul class="member-list">
477
+ <h4>Type:</h4>
478
+ <li>
479
+ Array of <a href="../classes/PatternDefinition.html"><tt>PatternDefinition</tt></a> objects
480
+ </li>
481
+ </ul>
482
+
483
+
484
+
401
485
  </div>
402
486
 
403
487
  </div>
@@ -435,6 +519,63 @@ var path2 = new Path.Circle(new Point(175, 50), 20);
435
519
 
436
520
 
437
521
 
522
+ <div class="reference-members">
523
+ <h2>Static Properties</h2>
524
+
525
+
526
+ <div id="onactivate" class="member">
527
+ <div class="member-link">
528
+ <a name="onactivate" href="#onactivate"><tt><b>Project.onActivate</b></tt></a>
529
+ </div>
530
+ <div class="member-description hidden">
531
+
532
+ <div class="member-text">
533
+ <p>The function to be called when any project is activated, as <a href="../classes/Project.html#onactivate"><tt>onActivate</tt></a> is for a single project, including the projects that activate themselves when they are created, with <code>this</code> set to the project. <code>Project.on(&#39;activate&#39;, handler)</code> and <code>Project.off(&#39;activate&#39;, handler)</code> attach and detach them too. Classes are shared by all <a href="../classes/PaperScope.html"><tt>PaperScope</tt></a> objects, and so are their handlers.</p>
534
+
535
+
536
+
537
+ <ul class="member-list">
538
+ <h4>Type:</h4>
539
+ <li>
540
+ <tt>Function</tt>⟋<tt>null</tt>
541
+ </li>
542
+ </ul>
543
+
544
+
545
+
546
+ </div>
547
+
548
+ </div>
549
+ </div>
550
+
551
+
552
+ <div id="ondeactivate" class="member">
553
+ <div class="member-link">
554
+ <a name="ondeactivate" href="#ondeactivate"><tt><b>Project.onDeactivate</b></tt></a>
555
+ </div>
556
+ <div class="member-description hidden">
557
+
558
+ <div class="member-text">
559
+ <p>The function to be called when any project is deactivated, as <a href="../classes/Project.html#ondeactivate"><tt>onDeactivate</tt></a> is for a single project, see <a href="../classes/Project.html#onactivate"><tt>Project.onActivate</tt></a>.</p>
560
+
561
+
562
+
563
+ <ul class="member-list">
564
+ <h4>Type:</h4>
565
+ <li>
566
+ <tt>Function</tt>⟋<tt>null</tt>
567
+ </li>
568
+ </ul>
569
+
570
+
571
+
572
+ </div>
573
+
574
+ </div>
575
+ </div>
576
+
577
+ </div>
578
+
438
579
 
439
580
 
440
581
  <!-- ============================== methods ================================ -->
@@ -478,6 +619,35 @@ var path2 = new Path.Circle(new Point(175, 50), 20);
478
619
 
479
620
 
480
621
 
622
+ </div>
623
+ </div>
624
+ </div>
625
+
626
+
627
+ <div id="hasdrawhandlers" class="member">
628
+ <div class="member-link">
629
+ <a name="hasdrawhandlers" href="#hasdrawhandlers"><tt><b>hasDrawHandlers</b>()</tt></a>
630
+ </div>
631
+ <div class="member-description hidden">
632
+ <div class="member-text">
633
+ <p>Checks whether any item of the project or class has draw handlers, <a href="../classes/Item.html#ondraw"><tt>item.onDraw</tt></a> or, for the selected items, <a href="../classes/Item.html#ondrawselection"><tt>item.onDrawSelection</tt></a>, for hosts that draw the items themselves, see <a href="../classes/Project.html#host"><tt>host</tt></a>.</p>
634
+
635
+
636
+
637
+ <ul class="member-list">
638
+ <h4>Returns:</h4>
639
+
640
+ <li>
641
+ <tt><tt>Boolean</tt></tt>&nbsp;&mdash;&nbsp;<tt>true</tt> if drawing the project calls any handlers, <tt>false</tt> otherwise
642
+ </li>
643
+
644
+
645
+ </ul>
646
+
647
+
648
+
649
+
650
+
481
651
  </div>
482
652
  </div>
483
653
  </div>
@@ -489,7 +659,7 @@ var path2 = new Path.Circle(new Point(175, 50), 20);
489
659
  </div>
490
660
  <div class="member-description hidden">
491
661
  <div class="member-text">
492
- <p>Updates the items of changed host nodes, given in the column format of the host&rsquo;s <code>getChildren()</code>, with two more flags: 16 when the node&rsquo;s own content changed, so the item loads it again on next access, and 32 when its list of children changed, so it loads them again right away if it had loaded them, keeping the items of nodes that remain. Nodes without items are skipped.</p>
662
+ <p>Updates the items of changed host nodes, given in the column format of the host&rsquo;s <code>getChildren()</code>, with two more flags: 16 when the node&rsquo;s own content changed, so the item loads it again on next access, and 32 when its list of children changed, so it loads them again right away if it had loaded them, keeping the items of nodes that remain. Nodes without items are skipped. <code>definitions</code> lists the keys of changed definitions of the host&rsquo;s <code>getDefinition()</code>, which load again right away into the same objects, so the colors and symbol items that use them change along. A definition that the host no longer has, for which <code>getDefinition()</code> may return <code>null</code> here, is emptied and draws nothing. The columns may hold only definitions.</p>
493
663
 
494
664
 
495
665
  <ul class="member-list">
@@ -520,7 +690,7 @@ var path2 = new Path.Circle(new Point(175, 50), 20);
520
690
  </div>
521
691
  <div class="member-description hidden">
522
692
  <div class="member-text">
523
- <p>Returns the changes logged since tracking was activated or since the last call, and clears the log. Each item is listed once, with the <a href="../classes/ChangeFlag.html"><tt>ChangeFlag</tt></a> values of all its changes combined. Removed items are listed with the <code>ChangeFlag.INSERTION</code> flag.</p>
693
+ <p>Returns the changes logged since tracking was activated or since the last call, and clears the log. Each item is listed once, with the <a href="../classes/ChangeFlag.html"><tt>ChangeFlag</tt></a> values of all its changes combined. Removed items are listed with the <code>ChangeFlag.INSERTION</code> flag, and items that moved to another project are left out, as that one lists them. Symbol and pattern definitions whose item, tile, spacing or name changed are listed too, as <code>{ definition, flags }</code>.</p>
524
694
 
525
695
 
526
696
 
@@ -528,7 +698,7 @@ var path2 = new Path.Circle(new Point(175, 50), 20);
528
698
  <h4>Returns:</h4>
529
699
 
530
700
  <li>
531
- <tt>Array of <tt>Object</tt> objects</tt>&nbsp;&mdash;&nbsp;the changes as <code>{ item, flags }</code> objects, or <code>null</code> if <a href="../classes/Project.html#trackchanges"><tt>trackChanges</tt></a> is off
701
+ <tt>Array of <tt>Object</tt> objects</tt>&nbsp;&mdash;&nbsp;the changes as <code>{ item, flags }</code> and <code>{ definition, flags }</code> objects, or <code>null</code> if <a href="../classes/Project.html#trackchanges"><tt>trackChanges</tt></a> is off
532
702
  </li>
533
703
 
534
704
 
@@ -1595,7 +1765,7 @@ var exported = project.exportSVG({
1595
1765
 
1596
1766
  <!-- =========================== copyright notice ========================== -->
1597
1767
  <p class="footer">
1598
- Paper.js v0.16.0<br>
1768
+ Paper.js v0.17.0<br>
1599
1769
  Copyright &#169; 2011—2026 <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>
1600
1770
  <div class="content-end"></div>
1601
1771