paper 0.13.0 → 0.15.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 (57) hide show
  1. package/CHANGELOG.md +337 -0
  2. package/README.md +19 -14
  3. package/dist/docs/assets/js/paper.js +7351 -1706
  4. package/dist/docs/classes/AreaText.html +8658 -0
  5. package/dist/docs/classes/ChangeFlag.html +385 -0
  6. package/dist/docs/classes/Color.html +2 -1
  7. package/dist/docs/classes/CompoundPath.html +208 -69
  8. package/dist/docs/classes/Curve.html +2 -1
  9. package/dist/docs/classes/CurveLocation.html +2 -1
  10. package/dist/docs/classes/Event.html +5 -4
  11. package/dist/docs/classes/Gradient.html +2 -1
  12. package/dist/docs/classes/GradientStop.html +2 -1
  13. package/dist/docs/classes/Group.html +204 -17
  14. package/dist/docs/classes/HitResult.html +4 -2
  15. package/dist/docs/classes/HostItem.html +6786 -0
  16. package/dist/docs/classes/Item.html +193 -17
  17. package/dist/docs/classes/Key.html +2 -1
  18. package/dist/docs/classes/KeyEvent.html +5 -4
  19. package/dist/docs/classes/Layer.html +201 -17
  20. package/dist/docs/classes/Matrix.html +2 -1
  21. package/dist/docs/classes/MouseEvent.html +5 -4
  22. package/dist/docs/classes/PaperScope.html +5 -2
  23. package/dist/docs/classes/PaperScript.html +6 -2
  24. package/dist/docs/classes/Path.html +183 -70
  25. package/dist/docs/classes/PathItem.html +326 -187
  26. package/dist/docs/classes/PathText.html +8528 -0
  27. package/dist/docs/classes/Point.html +13 -2
  28. package/dist/docs/classes/PointText.html +1404 -63
  29. package/dist/docs/classes/Project.html +221 -1
  30. package/dist/docs/classes/Raster.html +136 -17
  31. package/dist/docs/classes/Rectangle.html +3 -2
  32. package/dist/docs/classes/Segment.html +2 -1
  33. package/dist/docs/classes/Shape.html +136 -17
  34. package/dist/docs/classes/Size.html +4 -2
  35. package/dist/docs/classes/Style.html +768 -15
  36. package/dist/docs/classes/SymbolDefinition.html +2 -1
  37. package/dist/docs/classes/SymbolItem.html +136 -17
  38. package/dist/docs/classes/TextItem.html +1566 -222
  39. package/dist/docs/classes/TextRange.html +186 -0
  40. package/dist/docs/classes/TextStory.html +355 -0
  41. package/dist/docs/classes/Tool.html +127 -1
  42. package/dist/docs/classes/ToolEvent.html +57 -4
  43. package/dist/docs/classes/Tween.html +17 -1
  44. package/dist/docs/classes/View.html +148 -5
  45. package/dist/docs/classes/global.html +2 -1
  46. package/dist/docs/classes/index.html +2 -2
  47. package/dist/docs/index.html +1 -1
  48. package/dist/paper-core.js +7160 -1663
  49. package/dist/paper-core.min.js +3 -3
  50. package/dist/paper-full.js +7351 -1706
  51. package/dist/paper-full.min.js +3 -3
  52. package/dist/paper-hosted.js +24058 -0
  53. package/dist/paper.d.ts +1996 -155
  54. package/examples/Scripts/AreaText.html +65 -0
  55. package/examples/Scripts/PathText.html +48 -0
  56. package/examples/Scripts/TextRanges.html +51 -0
  57. package/package.json +8 -11
@@ -19,6 +19,7 @@
19
19
 
20
20
  <p>The path item represents a path in a Paper.js project.</p>
21
21
 
22
+
22
23
  </div>
23
24
 
24
25
  <!-- =============================== constructors ========================== -->
@@ -1069,7 +1070,7 @@ var path = new Path.Arc({
1069
1070
  </div>
1070
1071
  <div class="member-description hidden">
1071
1072
  <div class="member-text">
1072
- <p>Creates a regular polygon shaped path item.</p>
1073
+ <p>Creates a regular polygon shaped path item. As in Illustrator, it stands on a flat bottom edge, and its segments run counterclockwise from its top vertex, or with an even number of sides, from the right end of its top edge.</p>
1073
1074
 
1074
1075
 
1075
1076
  <ul class="member-list">
@@ -3345,6 +3346,32 @@ for (var i = 0; i < amount + 1; i++) {
3345
3346
  <div class="reference-members"><h2>Properties inherited from <a href="../classes/Item.html"><tt>Item</tt></a></h2>
3346
3347
 
3347
3348
 
3349
+ <div id="key" class="member">
3350
+ <div class="member-link">
3351
+ <a name="key" href="#key"><tt><b>key</b></tt></a>
3352
+ </div>
3353
+ <div class="member-description hidden">
3354
+
3355
+ <div class="member-text">
3356
+ <p>The key of the host&rsquo;s node that the item represents, in a project backed by a host document, see <a href="../classes/Project.html#host"><tt>project.host</tt></a>. It can only be set once, on an item created by a script, to register the key that the host gave its new node.</p>
3357
+
3358
+
3359
+
3360
+ <ul class="member-list">
3361
+ <h4>Type:</h4>
3362
+ <li>
3363
+ <tt>Number</tt>
3364
+ </li>
3365
+ </ul>
3366
+
3367
+
3368
+
3369
+ </div>
3370
+
3371
+ </div>
3372
+ </div>
3373
+
3374
+
3348
3375
  <div id="id" class="member">
3349
3376
  <div class="member-link">
3350
3377
  <a name="id" href="#id"><tt><b>id</b></tt></a>
@@ -3691,7 +3718,7 @@ path.visible = false;
3691
3718
  <div class="member-description hidden">
3692
3719
 
3693
3720
  <div class="member-text">
3694
- <p>The blend mode with which the item is composited onto the canvas. Both the standard canvas compositing modes, as well as the new CSS blend modes are supported. If blend-modes cannot be rendered natively, they are emulated. Be aware that emulation can have an impact on performance.</p>
3721
+ <p>The blend mode with which the item is composited onto the canvas. Both the standard canvas compositing modes, as well as the new CSS blend modes are supported. Where the canvas doesn&rsquo;t support a CSS blend mode natively, it draws as <code>&#39;normal&#39;</code>. Paper.js&rsquo;s own modes <code>&#39;add&#39;</code>, <code>&#39;subtract&#39;</code>, <code>&#39;average&#39;</code>, <code>&#39;pin-light&#39;</code> and <code>&#39;negation&#39;</code> are emulated, which can have an impact on performance.</p>
3695
3722
 
3696
3723
 
3697
3724
  <ul class="member-list">
@@ -3844,6 +3871,42 @@ circle2.opacity = 0.5;
3844
3871
  </div>
3845
3872
 
3846
3873
 
3874
+ <div id="textwrap" class="member">
3875
+ <div class="member-link">
3876
+ <a name="textwrap" href="#textwrap"><tt><b>textWrap</b></tt></a>
3877
+ </div>
3878
+ <div class="member-description hidden">
3879
+
3880
+ <div class="member-text">
3881
+ <p>Specifies whether, and how, the item pushes aside the text of the <a href="../classes/AreaText.html"><tt>AreaText</tt></a> items below it in its layer: <code>null</code>, or an object with <code>offset</code>, the space kept between them, and <code>invert</code>, to let the text flow inside it instead. <code>true</code> sets the defaults.</p>
3882
+
3883
+
3884
+
3885
+ <ul class="member-list">
3886
+ <h4>Default:</h4>
3887
+ <li><tt>null</tt></li>
3888
+ </ul>
3889
+
3890
+ <ul class="member-list">
3891
+ <h4>Type:</h4>
3892
+ <li>
3893
+ <tt>Object</tt>
3894
+ </li>
3895
+ </ul>
3896
+
3897
+
3898
+ <h4>Example:</h4>
3899
+
3900
+
3901
+ <pre><code>var circle = new Path.Circle({ center: [100, 100], radius: 40 });
3902
+ circle.textWrap = { offset: 10 };</code></pre>
3903
+
3904
+ </div>
3905
+
3906
+ </div>
3907
+ </div>
3908
+
3909
+
3847
3910
  <div id="selected" class="member">
3848
3911
  <div class="member-link">
3849
3912
  <a name="selected" href="#selected"><tt><b>selected</b></tt></a>
@@ -4140,6 +4203,7 @@ circle.position.x += 100;
4140
4203
 
4141
4204
  <div class="member-text">
4142
4205
  <p>The bounding rectangle of the item including stroke width.</p>
4206
+ <p>Setting it fits the item&rsquo;s <a href="../classes/Item.html#bounds"><tt>bounds</tt></a> into the given rectangle minus the extent of the stroke on each side, also where this extent changes with the item&rsquo;s proportions, as with miters. A rectangle smaller than the stroke itself shrinks the bounds to its center.</p>
4143
4207
 
4144
4208
 
4145
4209
 
@@ -4428,6 +4492,34 @@ circle.position.x += 100;
4428
4492
 
4429
4493
 
4430
4494
 
4495
+ </div>
4496
+
4497
+ </div>
4498
+ </div>
4499
+
4500
+
4501
+ <div id="scope" class="member">
4502
+ <div class="member-link">
4503
+ <a name="scope" href="#scope"><tt><b>scope</b></tt></a>
4504
+ </div>
4505
+ <div class="member-description hidden">
4506
+
4507
+ <div class="member-text">
4508
+ <p>The scope that this item belongs to, through its project.</p>
4509
+
4510
+ <p>Read only.</p>
4511
+
4512
+
4513
+
4514
+ <ul class="member-list">
4515
+ <h4>Type:</h4>
4516
+ <li>
4517
+ <a href="../classes/PaperScope.html"><tt>PaperScope</tt></a>
4518
+ </li>
4519
+ </ul>
4520
+
4521
+
4522
+
4431
4523
  </div>
4432
4524
 
4433
4525
  </div>
@@ -5043,7 +5135,7 @@ path3.strokeJoin = 'bevel';
5043
5135
  <div class="member-description hidden">
5044
5136
 
5045
5137
  <div class="member-text">
5046
- <p>Specifies whether the stroke is to be drawn taking the current affine transformation into account (the default behavior), or whether it should appear as a non-scaling stroke.</p>
5138
+ <p>Specifies whether the stroke is to be drawn taking the current affine transformation into account (the default behavior), or whether it should appear as a non-scaling stroke. On text, non-scaling strokes are exact for uniform scaling only, as the glyphs are always stroked through the transformation.</p>
5047
5139
 
5048
5140
 
5049
5141
 
@@ -6251,9 +6343,9 @@ for (var i = 0; i < 20; i++) {
6251
6343
  <p>Rasterizes the item into a newly created Raster object. The item itself is not removed after rasterization.</p>
6252
6344
  <ul class="member-list">
6253
6345
  <h4>Options:</h4>
6254
- <li><tt>resolution: <tt>Number</tt></tt> &mdash; the desired resolution to be used when rasterizing, in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used by default. &mdash;&nbsp;default: <tt>view.resolution</tt></li>
6255
- <li><tt>raster: <a href="../classes/Raster.html"><tt>Raster</tt></a></tt> &mdash; specifies a raster to be reused when rasterizing. If the raster has the desired size already, then the underlying canvas is reused and no new memory needs to be allocated. If no raster is provided, a new raster item is created and returned instead. &mdash;&nbsp;default: <tt>null</tt></li>
6256
- <li><tt>insert: <tt>Boolean</tt></tt> &mdash; specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the rasterized item. &mdash;&nbsp;default: <tt>true</tt></li>
6346
+ <li><tt>options.resolution: <tt>Number</tt></tt> &mdash; the desired resolution to be used when rasterizing, in pixels per inch (DPI). If not specified, the value of <code>view.resolution</code> is used by default. &mdash;&nbsp;default: <tt>view.resolution</tt></li>
6347
+ <li><tt>options.raster: <a href="../classes/Raster.html"><tt>Raster</tt></a></tt> &mdash; specifies a raster to be reused when rasterizing. If the raster has the desired size already, then the underlying canvas is reused and no new memory needs to be allocated. If no raster is provided, a new raster item is created and returned instead. &mdash;&nbsp;default: <tt>null</tt></li>
6348
+ <li><tt>options.insert: <tt>Boolean</tt></tt> &mdash; specifies whether the raster should be inserted into the scene graph. When set to <code>true</code>, it is inserted above the rasterized item. &mdash;&nbsp;default: <tt>true</tt></li>
6257
6349
  </ul>
6258
6350
 
6259
6351
  <ul class="member-list">
@@ -6438,7 +6530,7 @@ function onMouseDown(event) {
6438
6530
  </div>
6439
6531
  <div class="member-description hidden">
6440
6532
  <div class="member-text">
6441
-
6533
+ <p>Checks whether the item overlaps with the given item: whether their outlines cross, or one contains the other, as <a href="../classes/Rectangle.html#intersects-rect"><tt>rectangle.intersects(rect)</tt></a> does for rectangles. Items other than paths and shapes are checked through their bounds. To only check whether outlines cross, use <a href="../classes/PathItem.html#getintersections-path"><tt>pathItem.getIntersections(path)</tt></a>.</p>
6442
6534
 
6443
6535
 
6444
6536
  <ul class="member-list">
@@ -6458,7 +6550,7 @@ function onMouseDown(event) {
6458
6550
  <h4>Returns:</h4>
6459
6551
 
6460
6552
  <li>
6461
- <tt><tt>Boolean</tt></tt>
6553
+ <tt><tt>Boolean</tt></tt>&nbsp;&mdash;&nbsp;<tt>true</tt> if the items overlap, <tt>false</tt> otherwise
6462
6554
  </li>
6463
6555
 
6464
6556
 
@@ -6954,6 +7046,7 @@ function onMouseDown(event) {
6954
7046
  <div class="member-text">
6955
7047
  <p>Converts the provided SVG content into Paper.js items and adds them to the this item&rsquo;s children list. Note that the item is not cleared first. You can call <a href="../classes/Item.html#removechildren"><tt>item.removeChildren</tt></a>() to do so.</p>
6956
7048
  <p><code>&lt;symbol&gt;</code> elements are imported as <a href="../classes/SymbolDefinition.html"><tt>SymbolDefinition</tt></a> items, and the <code>&lt;use&gt;</code> elements that place them as <a href="../classes/SymbolItem.html"><tt>SymbolItem</tt></a> items. The styles that <code>&lt;use&gt;</code> elements inherit don&rsquo;t reach the symbols&rsquo; content.</p>
7049
+ <p>URLs are fetched as they are, so validate URLs that come from untrusted sources first, especially on servers, where they could reach internal addresses.</p>
6957
7050
  <ul class="member-list">
6958
7051
  <h4>Options:</h4>
6959
7052
  <li><tt>options.expandShapes: <tt>Boolean</tt></tt> &mdash; whether imported shape items should be expanded to path items &mdash;&nbsp;default: <tt>false</tt></li>
@@ -7466,11 +7559,11 @@ Array of <a href="../classes/Item.html"><tt>Item</tt></a> objects
7466
7559
 
7467
7560
  <div id="replacewith-item" class="member">
7468
7561
  <div class="member-link">
7469
- <a name="replacewith-item" href="#replacewith-item"><tt><b>replaceWith</b>(item)</tt></a>
7562
+ <a name="replacewith-item" href="#replacewith-item"><tt><b>replaceWith</b>(...item)</tt></a>
7470
7563
  </div>
7471
7564
  <div class="member-description hidden">
7472
7565
  <div class="member-text">
7473
- <p>Replaces this item with the provided new item which will takes its place in the project hierarchy instead.</p>
7566
+ <p>Replaces this item with the provided new items which will take its place in the project hierarchy instead, in the given order. This also ungroups a group, e.g. <code>group.replaceWith(…group.children)</code>, but note that the items keep their own matrices, see <a href="../classes/Group.html#ungroup"><tt>group.ungroup</tt></a>().</p>
7474
7567
 
7475
7568
 
7476
7569
  <ul class="member-list">
@@ -7479,7 +7572,7 @@ Array of <a href="../classes/Item.html"><tt>Item</tt></a> objects
7479
7572
  <li>
7480
7573
  <tt>item:</tt>
7481
7574
  <a href="../classes/Item.html"><tt>Item</tt></a>
7482
- &mdash;&nbsp;the item that will replace this item
7575
+ &mdash;&nbsp;the items that will replace this item
7483
7576
 
7484
7577
  </li>
7485
7578
 
@@ -7652,7 +7745,7 @@ Array of <a href="../classes/Item.html"><tt>Item</tt></a> objects
7652
7745
  </div>
7653
7746
  <div class="member-description hidden">
7654
7747
  <div class="member-text">
7655
- <p>Checks whether the item has a fill.</p>
7748
+ <p>Checks whether the item has a visible fill, a fill color with an alpha above 0. Hit-tests also hit transparent fills, see <a href="../classes/Item.html#hittest"><tt>hitTest</tt></a>.</p>
7656
7749
 
7657
7750
 
7658
7751
 
@@ -7660,7 +7753,7 @@ Array of <a href="../classes/Item.html"><tt>Item</tt></a> objects
7660
7753
  <h4>Returns:</h4>
7661
7754
 
7662
7755
  <li>
7663
- <tt><tt>Boolean</tt></tt>&nbsp;&mdash;&nbsp;<tt>true</tt> if the item has a fill, <tt>false</tt> otherwise
7756
+ <tt><tt>Boolean</tt></tt>&nbsp;&mdash;&nbsp;<tt>true</tt> if the item has a visible fill, <tt>false</tt> otherwise
7664
7757
  </li>
7665
7758
 
7666
7759
 
@@ -9294,10 +9387,10 @@ function onMouseDown(event) {
9294
9387
  <p>Removes the item when the events specified in the passed options object occur.</p>
9295
9388
  <ul class="member-list">
9296
9389
  <h4>Options:</h4>
9297
- <li><tt>options.move: undefined</tt> &mdash; {Boolean) remove the item when the next <a href="../classes/Tool.html#onmousemove"><tt>tool.onMouseMove</tt></a> event is fired.</li>
9298
- <li><tt>options.drag: undefined</tt> &mdash; {Boolena) remove the item when the next <a href="../classes/Tool.html#onmousedrag"><tt>tool.onMouseDrag</tt></a> event is fired.</li>
9299
- <li><tt>options.down: undefined</tt> &mdash; {Boolean) remove the item when the next <a href="../classes/Tool.html#onmousedown"><tt>tool.onMouseDown</tt></a> event is fired.</li>
9300
- <li><tt>options.up: undefined</tt> &mdash; {Boolean) remove the item when the next <a href="../classes/Tool.html#onmouseup"><tt>tool.onMouseUp</tt></a> event is fired.</li>
9390
+ <li><tt>options.move: <tt>Boolean</tt></tt> &mdash; remove the item when the next <a href="../classes/Tool.html#onmousemove"><tt>tool.onMouseMove</tt></a> event is fired.</li>
9391
+ <li><tt>options.drag: <tt>Boolean</tt></tt> &mdash; remove the item when the next <a href="../classes/Tool.html#onmousedrag"><tt>tool.onMouseDrag</tt></a> event is fired.</li>
9392
+ <li><tt>options.down: <tt>Boolean</tt></tt> &mdash; remove the item when the next <a href="../classes/Tool.html#onmousedown"><tt>tool.onMouseDown</tt></a> event is fired.</li>
9393
+ <li><tt>options.up: <tt>Boolean</tt></tt> &mdash; remove the item when the next <a href="../classes/Tool.html#onmouseup"><tt>tool.onMouseUp</tt></a> event is fired.</li>
9301
9394
  </ul>
9302
9395
 
9303
9396
  <ul class="member-list">
@@ -10031,10 +10124,10 @@ path.tweenFrom({ fillColor: 'red' }, { duration: 1000 });
10031
10124
  </div>
10032
10125
  <div class="member-description hidden">
10033
10126
  <div class="member-text">
10034
- <p>Unites the geometry of the specified path with this path&rsquo;s geometry and returns the result as a new path item.</p>
10127
+ <p>Unites the geometry of the specified path with this path&rsquo;s geometry and returns the result as a new path item. With an array of paths, the result covers the areas inside any of them or this path. Each path keeps its own fill rule.</p>
10035
10128
  <ul class="member-list">
10036
10129
  <h4>Options:</h4>
10037
- <li><tt>options.insert: <tt>Boolean</tt></tt> &mdash; whether the resulting item should be inserted back into the scene graph, above both paths involved in the operation &mdash;&nbsp;default: <tt>true</tt></li>
10130
+ <li><tt>options.insert: <tt>Boolean</tt></tt> &mdash; whether the resulting item should be inserted back into the scene graph, above all paths involved in the operation &mdash;&nbsp;default: <tt>true</tt></li>
10038
10131
  </ul>
10039
10132
 
10040
10133
  <ul class="member-list">
@@ -10042,8 +10135,8 @@ path.tweenFrom({ fillColor: 'red' }, { duration: 1000 });
10042
10135
 
10043
10136
  <li>
10044
10137
  <tt>path:</tt>
10045
- <a href="../classes/PathItem.html"><tt>PathItem</tt></a>
10046
- &mdash;&nbsp;the path to unite with
10138
+ <a href="../classes/PathItem.html"><tt>PathItem</tt></a>⟋Array of <a href="../classes/PathItem.html"><tt>PathItem</tt></a> objects
10139
+ &mdash;&nbsp;the path or paths to unite with
10047
10140
 
10048
10141
  </li>
10049
10142
 
@@ -10087,6 +10180,26 @@ result.fillColor = 'red';
10087
10180
  </div>
10088
10181
 
10089
10182
 
10183
+ <h4>Example:<span class="description">Uniting many paths at once:</span></h4>
10184
+
10185
+ <div class="paperscript split">
10186
+
10187
+ <div class="buttons">
10188
+ <div class="button run">Run</div>
10189
+ </div>
10190
+
10191
+ <script type="text/paperscript" canvas="canvas-109">
10192
+ var circles = [];
10193
+ for (var i = 0; i < 6; i++) {
10194
+ circles.push(new Path.Circle([30 + i * 20, 50], 20));
10195
+ }
10196
+ var result = circles[0].unite(circles.slice(1));
10197
+ result.fillColor = 'red';
10198
+ </script>
10199
+ <div class="canvas"><canvas width="516" height="100" id="canvas-109"></canvas></div>
10200
+ </div>
10201
+
10202
+
10090
10203
  </div>
10091
10204
  </div>
10092
10205
  </div>
@@ -10098,11 +10211,11 @@ result.fillColor = 'red';
10098
10211
  </div>
10099
10212
  <div class="member-description hidden">
10100
10213
  <div class="member-text">
10101
- <p>Intersects the geometry of the specified path with this path&rsquo;s geometry and returns the result as a new path item.</p>
10214
+ <p>Intersects the geometry of the specified path with this path&rsquo;s geometry and returns the result as a new path item. With an array of paths, the result covers the areas inside all of them and this path. Each path keeps its own fill rule.</p>
10102
10215
  <ul class="member-list">
10103
10216
  <h4>Options:</h4>
10104
- <li><tt>options.insert: <tt>Boolean</tt></tt> &mdash; whether the resulting item should be inserted back into the scene graph, above both paths involved in the operation &mdash;&nbsp;default: <tt>true</tt></li>
10105
- <li><tt>options.trace: <tt>Boolean</tt></tt> &mdash; whether the tracing method is used, treating both paths as areas when determining which parts of the paths are to be kept in the result, or whether the first path is only to be split at intersections, keeping the parts of the curves that intersect with the area of the second path. &mdash;&nbsp;default: <tt>true</tt></li>
10217
+ <li><tt>options.insert: <tt>Boolean</tt></tt> &mdash; whether the resulting item should be inserted back into the scene graph, above all paths involved in the operation &mdash;&nbsp;default: <tt>true</tt></li>
10218
+ <li><tt>options.trace: <tt>Boolean</tt></tt> &mdash; whether the tracing method is used, treating all paths as areas when determining which parts of the paths are to be kept in the result, or whether the first path is only to be split at intersections, keeping the parts of the curves that intersect with the areas of all other paths. &mdash;&nbsp;default: <tt>true</tt></li>
10106
10219
  </ul>
10107
10220
 
10108
10221
  <ul class="member-list">
@@ -10110,8 +10223,8 @@ result.fillColor = 'red';
10110
10223
 
10111
10224
  <li>
10112
10225
  <tt>path:</tt>
10113
- <a href="../classes/PathItem.html"><tt>PathItem</tt></a>
10114
- &mdash;&nbsp;the path to intersect with
10226
+ <a href="../classes/PathItem.html"><tt>PathItem</tt></a>⟋Array of <a href="../classes/PathItem.html"><tt>PathItem</tt></a> objects
10227
+ &mdash;&nbsp;the path or paths to intersect with
10115
10228
 
10116
10229
  </li>
10117
10230
 
@@ -10146,12 +10259,12 @@ result.fillColor = 'red';
10146
10259
  <div class="button run">Run</div>
10147
10260
  </div>
10148
10261
 
10149
- <script type="text/paperscript" canvas="canvas-109">
10262
+ <script type="text/paperscript" canvas="canvas-110">
10150
10263
  var result = new Path.RegularPolygon([50, 50], 3, 40)
10151
10264
  .intersect(new Path.Circle([50, 50], 25));
10152
10265
  result.fillColor = 'red';
10153
10266
  </script>
10154
- <div class="canvas"><canvas width="516" height="100" id="canvas-109"></canvas></div>
10267
+ <div class="canvas"><canvas width="516" height="100" id="canvas-110"></canvas></div>
10155
10268
  </div>
10156
10269
 
10157
10270
 
@@ -10166,11 +10279,11 @@ result.fillColor = 'red';
10166
10279
  </div>
10167
10280
  <div class="member-description hidden">
10168
10281
  <div class="member-text">
10169
- <p>Subtracts the geometry of the specified path from this path&rsquo;s geometry and returns the result as a new path item.</p>
10282
+ <p>Subtracts the geometry of the specified path from this path&rsquo;s geometry and returns the result as a new path item. With an array of paths, the result covers the areas inside this path and outside all of them. Each path keeps its own fill rule.</p>
10170
10283
  <ul class="member-list">
10171
10284
  <h4>Options:</h4>
10172
- <li><tt>options.insert: <tt>Boolean</tt></tt> &mdash; whether the resulting item should be inserted back into the scene graph, above both paths involved in the operation &mdash;&nbsp;default: <tt>true</tt></li>
10173
- <li><tt>options.trace: <tt>Boolean</tt></tt> &mdash; whether the tracing method is used, treating both paths as areas when determining which parts of the paths are to be kept in the result, or whether the first path is only to be split at intersections, removing the parts of the curves that intersect with the area of the second path. &mdash;&nbsp;default: <tt>true</tt></li>
10285
+ <li><tt>options.insert: <tt>Boolean</tt></tt> &mdash; whether the resulting item should be inserted back into the scene graph, above all paths involved in the operation &mdash;&nbsp;default: <tt>true</tt></li>
10286
+ <li><tt>options.trace: <tt>Boolean</tt></tt> &mdash; whether the tracing method is used, treating all paths as areas when determining which parts of the paths are to be kept in the result, or whether the first path is only to be split at intersections, removing the parts of the curves that intersect with the area of any other path. &mdash;&nbsp;default: <tt>true</tt></li>
10174
10287
  </ul>
10175
10288
 
10176
10289
  <ul class="member-list">
@@ -10178,8 +10291,8 @@ result.fillColor = 'red';
10178
10291
 
10179
10292
  <li>
10180
10293
  <tt>path:</tt>
10181
- <a href="../classes/PathItem.html"><tt>PathItem</tt></a>
10182
- &mdash;&nbsp;the path to subtract
10294
+ <a href="../classes/PathItem.html"><tt>PathItem</tt></a>⟋Array of <a href="../classes/PathItem.html"><tt>PathItem</tt></a> objects
10295
+ &mdash;&nbsp;the path or paths to subtract
10183
10296
 
10184
10297
  </li>
10185
10298
 
@@ -10214,12 +10327,12 @@ result.fillColor = 'red';
10214
10327
  <div class="button run">Run</div>
10215
10328
  </div>
10216
10329
 
10217
- <script type="text/paperscript" canvas="canvas-110">
10330
+ <script type="text/paperscript" canvas="canvas-111">
10218
10331
  var result = new Path.RegularPolygon([50, 50], 3, 40)
10219
10332
  .subtract(new Path.Circle([50, 50], 25));
10220
10333
  result.fillColor = 'red';
10221
10334
  </script>
10222
- <div class="canvas"><canvas width="516" height="100" id="canvas-110"></canvas></div>
10335
+ <div class="canvas"><canvas width="516" height="100" id="canvas-111"></canvas></div>
10223
10336
  </div>
10224
10337
 
10225
10338
 
@@ -10234,10 +10347,10 @@ result.fillColor = 'red';
10234
10347
  </div>
10235
10348
  <div class="member-description hidden">
10236
10349
  <div class="member-text">
10237
- <p>Excludes the intersection of the geometry of the specified path with this path&rsquo;s geometry and returns the result as a new path item.</p>
10350
+ <p>Excludes the intersection of the geometry of the specified path with this path&rsquo;s geometry and returns the result as a new path item. With an array of paths, the result covers the areas inside an odd number of the paths, this one included. Each path keeps its own fill rule.</p>
10238
10351
  <ul class="member-list">
10239
10352
  <h4>Options:</h4>
10240
- <li><tt>options.insert: <tt>Boolean</tt></tt> &mdash; whether the resulting item should be inserted back into the scene graph, above both paths involved in the operation &mdash;&nbsp;default: <tt>true</tt></li>
10353
+ <li><tt>options.insert: <tt>Boolean</tt></tt> &mdash; whether the resulting item should be inserted back into the scene graph, above all paths involved in the operation &mdash;&nbsp;default: <tt>true</tt></li>
10241
10354
  </ul>
10242
10355
 
10243
10356
  <ul class="member-list">
@@ -10245,8 +10358,8 @@ result.fillColor = 'red';
10245
10358
 
10246
10359
  <li>
10247
10360
  <tt>path:</tt>
10248
- <a href="../classes/PathItem.html"><tt>PathItem</tt></a>
10249
- &mdash;&nbsp;the path to exclude the intersection of
10361
+ <a href="../classes/PathItem.html"><tt>PathItem</tt></a>⟋Array of <a href="../classes/PathItem.html"><tt>PathItem</tt></a> objects
10362
+ &mdash;&nbsp;the path or paths to exclude the intersection of
10250
10363
 
10251
10364
  </li>
10252
10365
 
@@ -10281,12 +10394,12 @@ result.fillColor = 'red';
10281
10394
  <div class="button run">Run</div>
10282
10395
  </div>
10283
10396
 
10284
- <script type="text/paperscript" canvas="canvas-111">
10397
+ <script type="text/paperscript" canvas="canvas-112">
10285
10398
  var result = new Path.RegularPolygon([50, 50], 3, 40)
10286
10399
  .exclude(new Path.Circle([50, 50], 25));
10287
10400
  result.fillColor = 'red';
10288
10401
  </script>
10289
- <div class="canvas"><canvas width="516" height="100" id="canvas-111"></canvas></div>
10402
+ <div class="canvas"><canvas width="516" height="100" id="canvas-112"></canvas></div>
10290
10403
  </div>
10291
10404
 
10292
10405
 
@@ -10454,7 +10567,7 @@ result.fillColor = 'red';
10454
10567
  <div class="button run">Run</div>
10455
10568
  </div>
10456
10569
 
10457
- <script type="text/paperscript" canvas="canvas-112">
10570
+ <script type="text/paperscript" canvas="canvas-113">
10458
10571
  var path = new Path.Rectangle(new Point(30, 25), new Size(50, 50));
10459
10572
  path.strokeColor = 'black';
10460
10573
 
@@ -10477,7 +10590,7 @@ function onFrame(event) {
10477
10590
  }
10478
10591
  }
10479
10592
  </script>
10480
- <div class="canvas"><canvas width="516" height="100" id="canvas-112"></canvas></div>
10593
+ <div class="canvas"><canvas width="516" height="100" id="canvas-113"></canvas></div>
10481
10594
  </div>
10482
10595
 
10483
10596
 
@@ -10618,7 +10731,7 @@ function onFrame(event) {
10618
10731
  <div class="button run">Run</div>
10619
10732
  </div>
10620
10733
 
10621
- <script type="text/paperscript" canvas="canvas-113">
10734
+ <script type="text/paperscript" canvas="canvas-114">
10622
10735
  var star = new Path.Star({
10623
10736
  center: view.center,
10624
10737
  points: 10,
@@ -10642,7 +10755,7 @@ function onMouseMove(event) {
10642
10755
  circle.position = nearestPoint;
10643
10756
  }
10644
10757
  </script>
10645
- <div class="canvas"><canvas width="516" height="200" id="canvas-113"></canvas></div>
10758
+ <div class="canvas"><canvas width="516" height="200" id="canvas-114"></canvas></div>
10646
10759
  </div>
10647
10760
 
10648
10761
 
@@ -10705,7 +10818,7 @@ function onMouseMove(event) {
10705
10818
  <div class="button run">Run</div>
10706
10819
  </div>
10707
10820
 
10708
- <script type="text/paperscript" canvas="canvas-114">
10821
+ <script type="text/paperscript" canvas="canvas-115">
10709
10822
  // Create a circle shaped path at { x: 80, y: 50 }
10710
10823
  // with a radius of 35:
10711
10824
  var path = new Path.Circle({
@@ -10723,7 +10836,7 @@ copy.position.x += 150;
10723
10836
  // Flatten the copied path, with a maximum error of 4 points:
10724
10837
  copy.flatten(4);
10725
10838
  </script>
10726
- <div class="canvas"><canvas width="516" height="100" id="canvas-114"></canvas></div>
10839
+ <div class="canvas"><canvas width="516" height="100" id="canvas-115"></canvas></div>
10727
10840
  </div>
10728
10841
 
10729
10842
 
@@ -10801,7 +10914,7 @@ copy.flatten(4);
10801
10914
  <div class="button run">Run</div>
10802
10915
  </div>
10803
10916
 
10804
- <script type="text/paperscript" canvas="canvas-115">
10917
+ <script type="text/paperscript" canvas="canvas-116">
10805
10918
  // Create a rectangular path with its top-left point at
10806
10919
  // {x: 30, y: 25} and a size of {width: 50, height: 50}:
10807
10920
  var path = new Path.Rectangle({
@@ -10820,7 +10933,7 @@ copy.position.x += 100;
10820
10933
  // Smooth the segments of the copy:
10821
10934
  copy.smooth({ type: 'continuous' });
10822
10935
  </script>
10823
- <div class="canvas"><canvas width="516" height="100" id="canvas-115"></canvas></div>
10936
+ <div class="canvas"><canvas width="516" height="100" id="canvas-116"></canvas></div>
10824
10937
  </div>
10825
10938
 
10826
10939
 
@@ -10832,7 +10945,7 @@ copy.smooth({ type: 'continuous' });
10832
10945
  <div class="button run">Run</div>
10833
10946
  </div>
10834
10947
 
10835
- <script type="text/paperscript" canvas="canvas-116">
10948
+ <script type="text/paperscript" canvas="canvas-117">
10836
10949
  var path = new Path();
10837
10950
  path.strokeColor = 'black';
10838
10951
 
@@ -10857,7 +10970,7 @@ copy.fullySelected = true;
10857
10970
  // Smooth the path using centripetal Catmull-Rom splines:
10858
10971
  copy.smooth({ type: 'catmull-rom', factor: 0.5 });
10859
10972
  </script>
10860
- <div class="canvas"><canvas width="516" height="220" id="canvas-116"></canvas></div>
10973
+ <div class="canvas"><canvas width="516" height="220" id="canvas-117"></canvas></div>
10861
10974
  </div>
10862
10975
 
10863
10976
 
@@ -10869,7 +10982,7 @@ copy.smooth({ type: 'catmull-rom', factor: 0.5 });
10869
10982
  <div class="button run">Run</div>
10870
10983
  </div>
10871
10984
 
10872
- <script type="text/paperscript" canvas="canvas-117">
10985
+ <script type="text/paperscript" canvas="canvas-118">
10873
10986
  // Create 5 rectangles, next to each other:
10874
10987
  var paths = [];
10875
10988
  for (var i = 0; i < 5; i++) {
@@ -10899,7 +11012,7 @@ paths[3].smooth({ type: 'continuous', from: 0, to: 2 });
10899
11012
  // Smooth a range, using negative indices:
10900
11013
  paths[4].smooth({ type: 'continuous', from: -1, to: 1 });
10901
11014
  </script>
10902
- <div class="canvas"><canvas width="516" height="110" id="canvas-117"></canvas></div>
11015
+ <div class="canvas"><canvas width="516" height="110" id="canvas-118"></canvas></div>
10903
11016
  </div>
10904
11017
 
10905
11018
 
@@ -10952,7 +11065,7 @@ paths[4].smooth({ type: 'continuous', from: -1, to: 1 });
10952
11065
  <div class="button run">Run</div>
10953
11066
  </div>
10954
11067
 
10955
- <script type="text/paperscript" canvas="canvas-118">
11068
+ <script type="text/paperscript" canvas="canvas-119">
10956
11069
  var path;
10957
11070
  function onMouseDown(event) {
10958
11071
  // If we already made a path before, deselect it:
@@ -10982,7 +11095,7 @@ function onMouseUp(event) {
10982
11095
  path.selected = true;
10983
11096
  }
10984
11097
  </script>
10985
- <div class="canvas"><canvas width="516" height="300" id="canvas-118"></canvas></div>
11098
+ <div class="canvas"><canvas width="516" height="300" id="canvas-119"></canvas></div>
10986
11099
  </div>
10987
11100
 
10988
11101
 
@@ -11181,7 +11294,7 @@ function onMouseUp(event) {
11181
11294
  <div class="button run">Run</div>
11182
11295
  </div>
11183
11296
 
11184
- <script type="text/paperscript" canvas="canvas-119">
11297
+ <script type="text/paperscript" canvas="canvas-120">
11185
11298
  var path = new Path();
11186
11299
  path.strokeColor = 'black';
11187
11300
 
@@ -11201,7 +11314,7 @@ path.arcTo(throughPoint, toPoint);
11201
11314
  var circle = new Path.Circle(throughPoint, 3);
11202
11315
  circle.fillColor = 'red';
11203
11316
  </script>
11204
- <div class="canvas"><canvas width="516" height="100" id="canvas-119"></canvas></div>
11317
+ <div class="canvas"><canvas width="516" height="100" id="canvas-120"></canvas></div>
11205
11318
  </div>
11206
11319
 
11207
11320
 
@@ -11213,7 +11326,7 @@ circle.fillColor = 'red';
11213
11326
  <div class="button run">Run</div>
11214
11327
  </div>
11215
11328
 
11216
- <script type="text/paperscript" canvas="canvas-120">
11329
+ <script type="text/paperscript" canvas="canvas-121">
11217
11330
  var myPath;
11218
11331
  function onMouseDrag(event) {
11219
11332
  // If we created a path before, remove it:
@@ -11241,7 +11354,7 @@ function onMouseUp(event) {
11241
11354
  myPath.fillColor = 'black';
11242
11355
  }
11243
11356
  </script>
11244
- <div class="canvas"><canvas width="516" height="300" id="canvas-120"></canvas></div>
11357
+ <div class="canvas"><canvas width="516" height="300" id="canvas-121"></canvas></div>
11245
11358
  </div>
11246
11359
 
11247
11360
 
@@ -11290,7 +11403,7 @@ function onMouseUp(event) {
11290
11403
  <div class="button run">Run</div>
11291
11404
  </div>
11292
11405
 
11293
- <script type="text/paperscript" canvas="canvas-121">
11406
+ <script type="text/paperscript" canvas="canvas-122">
11294
11407
  var path = new Path();
11295
11408
  path.strokeColor = 'black';
11296
11409
 
@@ -11305,7 +11418,7 @@ path2.add(new Point(180, 25));
11305
11418
  // we pass `false` as the second argument to arcTo:
11306
11419
  path2.arcTo(new Point(280, 25), false);
11307
11420
  </script>
11308
- <div class="canvas"><canvas width="516" height="100" id="canvas-121"></canvas></div>
11421
+ <div class="canvas"><canvas width="516" height="100" id="canvas-122"></canvas></div>
11309
11422
  </div>
11310
11423
 
11311
11424
 
@@ -11317,7 +11430,7 @@ path2.arcTo(new Point(280, 25), false);
11317
11430
  <div class="button run">Run</div>
11318
11431
  </div>
11319
11432
 
11320
- <script type="text/paperscript" canvas="canvas-122">
11433
+ <script type="text/paperscript" canvas="canvas-123">
11321
11434
  var myPath;
11322
11435
 
11323
11436
  // The mouse has to move at least 20 points before
@@ -11338,7 +11451,7 @@ function onMouseDrag(event) {
11338
11451
  myPath.arcTo(event.point);
11339
11452
  }
11340
11453
  </script>
11341
- <div class="canvas"><canvas width="516" height="300" id="canvas-122"></canvas></div>
11454
+ <div class="canvas"><canvas width="516" height="300" id="canvas-123"></canvas></div>
11342
11455
  </div>
11343
11456
 
11344
11457
 
@@ -11394,7 +11507,7 @@ function onMouseDrag(event) {
11394
11507
  <div class="button run">Run</div>
11395
11508
  </div>
11396
11509
 
11397
- <script type="text/paperscript" canvas="canvas-123">
11510
+ <script type="text/paperscript" canvas="canvas-124">
11398
11511
  var myPath;
11399
11512
  function onMouseMove(event) {
11400
11513
  // If we created a path before, remove it:
@@ -11415,7 +11528,7 @@ function onMouseMove(event) {
11415
11528
  myPath.selected = true;
11416
11529
  }
11417
11530
  </script>
11418
- <div class="canvas"><canvas width="516" height="300" id="canvas-123"></canvas></div>
11531
+ <div class="canvas"><canvas width="516" height="300" id="canvas-124"></canvas></div>
11419
11532
  </div>
11420
11533
 
11421
11534
 
@@ -11600,7 +11713,7 @@ function onMouseMove(event) {
11600
11713
  <div class="button run">Run</div>
11601
11714
  </div>
11602
11715
 
11603
- <script type="text/paperscript" canvas="canvas-124">
11716
+ <script type="text/paperscript" canvas="canvas-125">
11604
11717
  var path = new Path();
11605
11718
  path.strokeColor = 'black';
11606
11719
 
@@ -11614,7 +11727,7 @@ path.lineBy(50, 0);
11614
11727
  // 0 in x direction and 50 in y direction, becomes {x: 75, y: 75}
11615
11728
  path.lineBy(0, 50);
11616
11729
  </script>
11617
- <div class="canvas"><canvas width="516" height="100" id="canvas-124"></canvas></div>
11730
+ <div class="canvas"><canvas width="516" height="100" id="canvas-125"></canvas></div>
11618
11731
  </div>
11619
11732
 
11620
11733
 
@@ -11626,7 +11739,7 @@ path.lineBy(0, 50);
11626
11739
  <div class="button run">Run</div>
11627
11740
  </div>
11628
11741
 
11629
- <script type="text/paperscript" canvas="canvas-125">
11742
+ <script type="text/paperscript" canvas="canvas-126">
11630
11743
  var path = new Path();
11631
11744
  path.strokeColor = 'black';
11632
11745
 
@@ -11652,7 +11765,7 @@ path.smooth();
11652
11765
  // the construction of the path:
11653
11766
  // path.selected = true;
11654
11767
  </script>
11655
- <div class="canvas"><canvas width="516" height="300" id="canvas-125"></canvas></div>
11768
+ <div class="canvas"><canvas width="516" height="300" id="canvas-126"></canvas></div>
11656
11769
  </div>
11657
11770
 
11658
11771
 
@@ -11871,7 +11984,7 @@ path.smooth();
11871
11984
 
11872
11985
  <!-- =========================== copyright notice ========================== -->
11873
11986
  <p class="footer">
11874
- Paper.js v0.13.0<br>
11987
+ Paper.js v0.15.0<br>
11875
11988
  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>
11876
11989
  <div class="content-end"></div>
11877
11990