paper 0.12.19 → 0.13.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 (51) hide show
  1. package/CHANGELOG.md +250 -0
  2. package/README.md +34 -27
  3. package/dist/docs/assets/js/paper.js +791 -366
  4. package/dist/docs/classes/Color.html +63 -47
  5. package/dist/docs/classes/CompoundPath.html +162 -59
  6. package/dist/docs/classes/Curve.html +9 -7
  7. package/dist/docs/classes/CurveLocation.html +1 -1
  8. package/dist/docs/classes/Event.html +1 -1
  9. package/dist/docs/classes/Gradient.html +1 -1
  10. package/dist/docs/classes/GradientStop.html +1 -1
  11. package/dist/docs/classes/Group.html +63 -24
  12. package/dist/docs/classes/HitResult.html +1 -1
  13. package/dist/docs/classes/Item.html +63 -24
  14. package/dist/docs/classes/Key.html +1 -1
  15. package/dist/docs/classes/KeyEvent.html +1 -1
  16. package/dist/docs/classes/Layer.html +63 -24
  17. package/dist/docs/classes/Matrix.html +1 -1
  18. package/dist/docs/classes/MouseEvent.html +1 -1
  19. package/dist/docs/classes/PaperScope.html +87 -1
  20. package/dist/docs/classes/PaperScript.html +1 -1
  21. package/dist/docs/classes/Path.html +174 -68
  22. package/dist/docs/classes/PathItem.html +280 -177
  23. package/dist/docs/classes/Point.html +143 -21
  24. package/dist/docs/classes/PointText.html +94 -24
  25. package/dist/docs/classes/Project.html +14 -8
  26. package/dist/docs/classes/Raster.html +93 -35
  27. package/dist/docs/classes/Rectangle.html +12 -11
  28. package/dist/docs/classes/Segment.html +1 -1
  29. package/dist/docs/classes/Shape.html +63 -24
  30. package/dist/docs/classes/Size.html +81 -21
  31. package/dist/docs/classes/Style.html +34 -2
  32. package/dist/docs/classes/SymbolDefinition.html +1 -1
  33. package/dist/docs/classes/SymbolItem.html +64 -25
  34. package/dist/docs/classes/TextItem.html +94 -24
  35. package/dist/docs/classes/Tool.html +2 -1
  36. package/dist/docs/classes/ToolEvent.html +27 -1
  37. package/dist/docs/classes/Tween.html +1 -1
  38. package/dist/docs/classes/View.html +203 -10
  39. package/dist/docs/classes/global.html +1 -1
  40. package/dist/docs/classes/index.html +2 -2
  41. package/dist/docs/index.html +1 -1
  42. package/dist/node/canvas.js +10 -8
  43. package/dist/node/self.js +13 -4
  44. package/dist/paper-core.js +772 -355
  45. package/dist/paper-core.min.js +3 -3
  46. package/dist/paper-full.js +791 -366
  47. package/dist/paper-full.min.js +3 -3
  48. package/dist/paper.d.ts +324 -73
  49. package/examples/Rasters/Smoothing.html +1 -1
  50. package/package.json +5 -11
  51. package/dist/node/xml.js +0 -40
@@ -167,7 +167,7 @@ var path = new Path({
167
167
  </div>
168
168
  <div class="member-description hidden">
169
169
  <div class="member-text">
170
- <p>Creates a new path item from SVG path-data and places it at the top of the active layer.</p>
170
+ <p>Creates a new path item from SVG path-data and places it at the top of the active layer. A path holds a single sub-path: further <code>M</code> commands are ignored, and the commands that follow them continue the same path. Use <a href="../classes/CompoundPath.html"><tt>CompoundPath</tt></a> or <a href="../classes/PathItem.html#create-pathdata"><tt>PathItem.create(pathData)</tt></a> to create items with multiple sub-paths.</p>
171
171
 
172
172
 
173
173
  <ul class="member-list">
@@ -2186,7 +2186,7 @@ path.selected = true;
2186
2186
  </div>
2187
2187
  <div class="member-description hidden">
2188
2188
  <div class="member-text">
2189
- <p>Removes the segments from the specified <code>from</code> index to the <code>to</code> index from the path&rsquo;s <a href="../classes/Path.html#segments"><tt>segments</tt></a> array.</p>
2189
+ <p>Removes the segments from the specified <code>from</code> index to the <code>to</code> index from the path&rsquo;s <a href="../classes/Path.html#segments"><tt>segments</tt></a> array. On closed paths, <code>from</code> can be bigger than <code>to</code>, to remove the segments from <code>from</code> to the end and then from the beginning up to <code>to</code>, wrapping around the closing curve.</p>
2190
2190
 
2191
2191
 
2192
2192
  <ul class="member-list">
@@ -2213,7 +2213,7 @@ path.selected = true;
2213
2213
  <h4>Returns:</h4>
2214
2214
 
2215
2215
  <li>
2216
- <tt>Array of <a href="../classes/Segment.html"><tt>Segment</tt></a> objects</tt>&nbsp;&mdash;&nbsp;an array containing the removed segments
2216
+ <tt>Array of <a href="../classes/Segment.html"><tt>Segment</tt></a> objects</tt>&nbsp;&mdash;&nbsp;an array containing the removed segments, in the order in which they appeared along the path
2217
2217
  </li>
2218
2218
 
2219
2219
 
@@ -2385,7 +2385,7 @@ path.selected = true;
2385
2385
  <h4>Returns:</h4>
2386
2386
 
2387
2387
  <li>
2388
- <tt><a href="../classes/Path.html"><tt>Path</tt></a></tt>&nbsp;&mdash;&nbsp;the newly created path after splitting, if any
2388
+ <tt><a href="../classes/Path.html"><tt>Path</tt></a>⟋<tt>null</tt></tt>&nbsp;&mdash;&nbsp;the newly created path after splitting, if any
2389
2389
  </li>
2390
2390
 
2391
2391
 
@@ -2610,23 +2610,26 @@ path.selected = true;
2610
2610
  </div>
2611
2611
 
2612
2612
 
2613
- <div id="reduce-options" class="member">
2613
+ <div id="reduce" class="member">
2614
2614
  <div class="member-link">
2615
- <a name="reduce-options" href="#reduce-options"><tt><b>reduce</b>(options)</tt></a>
2615
+ <a name="reduce" href="#reduce"><tt><b>reduce</b>([options])</tt></a>
2616
2616
  </div>
2617
2617
  <div class="member-description hidden">
2618
2618
  <div class="member-text">
2619
- <p>Reduces the path by removing curves that have a length of 0, and unnecessary segments between two collinear flat curves.</p>
2620
-
2619
+ <p>Reduces the path by removing straight curves that have a length of 0. With <code>options.simplify</code>, it also removes straight curves that are almost 0 in length, and unnecessary segments between two collinear straight curves.</p>
2620
+ <ul class="member-list">
2621
+ <h4>Options:</h4>
2622
+ <li><tt>options.simplify: <tt>Boolean</tt></tt> &mdash; also remove almost zero-length curves and segments between collinear straight curves &mdash;&nbsp;default: <tt>false</tt></li>
2623
+ </ul>
2621
2624
 
2622
2625
  <ul class="member-list">
2623
2626
  <h4>Parameters:</h4>
2624
2627
 
2625
2628
  <li>
2626
2629
  <tt>options:</tt>
2627
-
2628
-
2629
-
2630
+ <tt>Object</tt>
2631
+ &mdash;&nbsp;the reduce options
2632
+ &mdash;&nbsp;optional
2630
2633
  </li>
2631
2634
 
2632
2635
  </ul>
@@ -2727,7 +2730,7 @@ path.selected = true;
2727
2730
  <h4>Returns:</h4>
2728
2731
 
2729
2732
  <li>
2730
- <tt><a href="../classes/CurveLocation.html"><tt>CurveLocation</tt></a></tt>&nbsp;&mdash;&nbsp;the curve location of the specified point
2733
+ <tt><a href="../classes/CurveLocation.html"><tt>CurveLocation</tt></a>⟋<tt>null</tt></tt>&nbsp;&mdash;&nbsp;the curve location of the specified point
2731
2734
  </li>
2732
2735
 
2733
2736
 
@@ -2768,7 +2771,7 @@ path.selected = true;
2768
2771
  <h4>Returns:</h4>
2769
2772
 
2770
2773
  <li>
2771
- <tt><tt>Number</tt></tt>&nbsp;&mdash;&nbsp;the length of the path up to the specified point
2774
+ <tt><tt>Number</tt>⟋<tt>null</tt></tt>&nbsp;&mdash;&nbsp;the length of the path up to the specified point
2772
2775
  </li>
2773
2776
 
2774
2777
 
@@ -2789,7 +2792,7 @@ path.selected = true;
2789
2792
  </div>
2790
2793
  <div class="member-description hidden">
2791
2794
  <div class="member-text">
2792
- <p>Returns the curve location of the specified offset on the path.</p>
2795
+ <p>Returns the curve location of the specified offset on the path, or <code>null</code> if the offset exceeds the length of the path.</p>
2793
2796
 
2794
2797
 
2795
2798
  <ul class="member-list">
@@ -3461,6 +3464,7 @@ group.children['example'].fillColor = 'red';
3461
3464
 
3462
3465
  <div class="member-text">
3463
3466
  <p>The path style of the item.</p>
3467
+ <p>Styles set on a <a href="../classes/Group.html"><tt>Group</tt></a> or <a href="../classes/Layer.html"><tt>Layer</tt></a> are applied to the children that it contains at that moment. Items added to it later do not receive them.</p>
3464
3468
 
3465
3469
 
3466
3470
 
@@ -3803,6 +3807,37 @@ circle2.opacity = 0.5;
3803
3807
  </div>
3804
3808
 
3805
3809
 
3810
+ </div>
3811
+
3812
+ </div>
3813
+ </div>
3814
+
3815
+
3816
+ <div id="guide" class="member">
3817
+ <div class="member-link">
3818
+ <a name="guide" href="#guide"><tt><b>guide</b></tt></a>
3819
+ </div>
3820
+ <div class="member-description hidden">
3821
+
3822
+ <div class="member-text">
3823
+ <p>Specifies whether the item functions as a guide. When set to <code>true</code>, the item is drawn as usual, but left out of hit-tests and mouse interactions. Hit-tests only find guides when <code>options.guides</code> is set, and then only them, see <a href="../classes/Item.html#hittest-point"><tt>hitTest(point[, options])</tt></a>.</p>
3824
+
3825
+
3826
+
3827
+ <ul class="member-list">
3828
+ <h4>Default:</h4>
3829
+ <li><tt>false</tt></li>
3830
+ </ul>
3831
+
3832
+ <ul class="member-list">
3833
+ <h4>Type:</h4>
3834
+ <li>
3835
+ <tt>Boolean</tt>
3836
+ </li>
3837
+ </ul>
3838
+
3839
+
3840
+
3806
3841
  </div>
3807
3842
 
3808
3843
  </div>
@@ -4506,6 +4541,7 @@ console.log(group.children[0] == path); // true</code></pre>
4506
4541
 
4507
4542
  <div class="member-text">
4508
4543
  <p>The children items contained within this item. Items that define a <a href="../classes/Item.html#name"><tt>name</tt></a> can also be accessed by name.</p>
4544
+ <p>Only <a href="../classes/Group.html"><tt>Group</tt></a>, <a href="../classes/Layer.html"><tt>Layer</tt></a> and <a href="../classes/CompoundPath.html"><tt>CompoundPath</tt></a> items can have children. On all other items, such as <a href="../classes/Path.html"><tt>Path</tt></a>, <a href="../classes/Shape.html"><tt>Shape</tt></a>, <a href="../classes/Raster.html"><tt>Raster</tt></a>, <a href="../classes/SymbolItem.html"><tt>SymbolItem</tt></a> and <a href="../classes/PointText.html"><tt>PointText</tt></a>, <code>children</code> is <code>undefined</code>.</p>
4509
4545
  <p><b>Please note:</b> The children array should not be modified directly using array functions. To remove single items from the children list, use <a href="../classes/Item.html#remove"><tt>item.remove</tt></a>(), to remove all items from the children list, use <a href="../classes/Item.html#removechildren"><tt>item.removeChildren</tt></a>(). To add items to the children list, use <a href="../classes/Item.html#addchild-item"><tt>item.addChild(item)</tt></a> or <a href="../classes/Item.html#insertchild-index-item"><tt>item.insertChild(index, item)</tt></a>.</p>
4510
4546
 
4511
4547
 
@@ -6446,22 +6482,22 @@ function onMouseDown(event) {
6446
6482
  <div class="member-description hidden">
6447
6483
  <div class="member-text">
6448
6484
  <p>Performs a hit-test on the item and its children (if it is a <a href="../classes/Group.html"><tt>Group</tt></a> or <a href="../classes/Layer.html"><tt>Layer</tt></a>) at the location of the specified point, returning the first found hit.</p>
6449
- <p>The options object allows you to control the specifics of the hit- test and may contain a combination of the following values:</p>
6485
+ <p>The options object allows you to control the specifics of the hit-test. Without options, <code>fill</code>, <code>stroke</code> and <code>segments</code> are hit-tested. As soon as an options object is passed, only the hit-tests that it sets to <code>true</code> are performed. It may contain a combination of the following values:</p>
6450
6486
  <ul class="member-list">
6451
6487
  <h4>Options:</h4>
6452
- <li><tt>options.tolerance: <tt>Number</tt></tt> &mdash; the tolerance of the hit-test &mdash;&nbsp;default: <tt><a href="../classes/PaperScope.html#settings"><tt>paperScope.settings</tt></a>.hitTolerance</tt></li>
6488
+ <li><tt>options.tolerance: <tt>Number</tt></tt> &mdash; the tolerance of the hit-test, in project coordinates &mdash;&nbsp;default: <tt><a href="../classes/PaperScope.html#settings"><tt>paperScope.settings</tt></a>.hitTolerance</tt></li>
6453
6489
  <li><tt>options.class: <tt>Function</tt></tt> &mdash; only hit-test against a specific item class, or any of its sub-classes, by providing the constructor function against which an <code>instanceof</code> check is performed: <tt>Group</tt>, <tt>Layer</tt>, <tt>Path</tt>, <tt>CompoundPath</tt>, <tt>Shape</tt>, <tt>Raster</tt>, <tt>SymbolItem</tt>, <tt>PointText</tt>, &hellip;</li>
6454
6490
  <li><tt>options.match: <tt>Function</tt></tt> &mdash; a match function to be called for each found hit result: Return <code>true</code> to return the result, <code>false</code> to keep searching</li>
6455
- <li><tt>options.fill: <tt>Boolean</tt></tt> &mdash; hit-test the fill of items &mdash;&nbsp;default: <tt>true</tt></li>
6456
- <li><tt>options.stroke: <tt>Boolean</tt></tt> &mdash; hit-test the stroke of path items, taking into account the setting of stroke color and width &mdash;&nbsp;default: <tt>true</tt></li>
6457
- <li><tt>options.segments: <tt>Boolean</tt></tt> &mdash; hit-test for <a href="../classes/Segment.html#point"><tt>segment.point</tt></a> of <a href="../classes/Path.html"><tt>Path</tt></a> items &mdash;&nbsp;default: <tt>true</tt></li>
6491
+ <li><tt>options.fill: <tt>Boolean</tt></tt> &mdash; hit-test the fill of items</li>
6492
+ <li><tt>options.stroke: <tt>Boolean</tt></tt> &mdash; hit-test the stroke of path items, taking into account the setting of stroke color and width</li>
6493
+ <li><tt>options.segments: <tt>Boolean</tt></tt> &mdash; hit-test for <a href="../classes/Segment.html#point"><tt>segment.point</tt></a> of <a href="../classes/Path.html"><tt>Path</tt></a> items</li>
6458
6494
  <li><tt>options.curves: <tt>Boolean</tt></tt> &mdash; hit-test the curves of path items, without taking the stroke color or width into account</li>
6459
6495
  <li><tt>options.handles: <tt>Boolean</tt></tt> &mdash; hit-test for the handles (<a href="../classes/Segment.html#handlein"><tt>segment.handleIn</tt></a> / <a href="../classes/Segment.html#handleout"><tt>segment.handleOut</tt></a>) of path segments.</li>
6460
6496
  <li><tt>options.ends: <tt>Boolean</tt></tt> &mdash; only hit-test for the first or last segment points of open path items</li>
6461
6497
  <li><tt>options.position: <tt>Boolean</tt></tt> &mdash; hit-test the <a href="../classes/Item.html#position"><tt>item.position</tt></a> of of items, which depends on the setting of <a href="../classes/Item.html#pivot"><tt>item.pivot</tt></a></li>
6462
6498
  <li><tt>options.center: <tt>Boolean</tt></tt> &mdash; hit-test the <a href="../classes/Rectangle.html#center"><tt>rectangle.center</tt></a> of the bounding rectangle of items (<a href="../classes/Item.html#bounds"><tt>item.bounds</tt></a>)</li>
6463
6499
  <li><tt>options.bounds: <tt>Boolean</tt></tt> &mdash; hit-test the corners and side-centers of the bounding rectangle of items (<a href="../classes/Item.html#bounds"><tt>item.bounds</tt></a>)</li>
6464
- <li><tt>options.guides: <tt>Boolean</tt></tt> &mdash; hit-test items that have <tt>Item#guide</tt> set to <code>true</code></li>
6500
+ <li><tt>options.guides: <tt>Boolean</tt></tt> &mdash; only hit-test items that have <a href="../classes/Item.html#guide"><tt>item.guide</tt></a> set to <code>true</code></li>
6465
6501
  <li><tt>options.selected: <tt>Boolean</tt></tt> &mdash; only hit selected items</li>
6466
6502
  </ul>
6467
6503
 
@@ -6700,7 +6736,7 @@ function onMouseDown(event) {
6700
6736
  <h4>Returns:</h4>
6701
6737
 
6702
6738
  <li>
6703
- <tt>Array of <a href="../classes/Item.html"><tt>Item</tt></a> objects</tt>&nbsp;&mdash;&nbsp;the list of matching descendant items
6739
+ <tt>Array of <a href="../classes/Item.html"><tt>Item</tt></a> objects</tt>&nbsp;&mdash;&nbsp;the list of matching descendant items, in their stacking order from bottom to top, with each item listed before its own descendants
6704
6740
  </li>
6705
6741
 
6706
6742
 
@@ -6873,6 +6909,8 @@ function onMouseDown(event) {
6873
6909
  <li><tt>options.precision: <tt>Number</tt></tt> &mdash; the amount of fractional digits in numbers used in SVG data &mdash;&nbsp;default: <tt>5</tt></li>
6874
6910
  <li><tt>options.matchShapes: <tt>Boolean</tt></tt> &mdash; whether path items should tried to be converted to SVG shape items (rect, circle, ellipse, line, polyline, polygon), if their geometries match &mdash;&nbsp;default: <tt>false</tt></li>
6875
6911
  <li><tt>options.embedImages: <tt>Boolean</tt></tt> &mdash; whether raster images should be embedded as base64 data inlined in the xlink:href attribute, or kept as a link to their external URL. &mdash;&nbsp;default: <tt>true</tt></li>
6912
+ <li><tt>options.reuseImages: <tt>Boolean</tt></tt> &mdash; whether raster images with the same content should only be exported once into the <code>&lt;defs&gt;</code> element, and placed through <code>&lt;use&gt;</code> elements referencing it &mdash;&nbsp;default: <tt>false</tt></li>
6913
+ <li><tt>options.idPrefix: <tt>String</tt></tt> &mdash; a prefix for the ids generated for definitions such as gradients, clip paths and symbols, to keep them unique when several exported SVGs are placed in one document &mdash;&nbsp;default: <tt>&rsquo;&rsquo;</tt></li>
6876
6914
  <li><tt>options.reduceAttributes: <tt>Boolean</tt></tt> &mdash; wether to only include style attributes in the SVG output that differ from their parents, or to always include them (much faster but leading to redundancies). &mdash;&nbsp;default: <tt>true</tt></li>
6877
6915
  </ul>
6878
6916
 
@@ -6915,9 +6953,13 @@ function onMouseDown(event) {
6915
6953
  <div class="member-description hidden">
6916
6954
  <div class="member-text">
6917
6955
  <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
+ <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>
6918
6957
  <ul class="member-list">
6919
6958
  <h4>Options:</h4>
6920
6959
  <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>
6960
+ <li>[options.crossOrigin] {String} the {@link Raster#crossOrigin}
6961
+ value of the rasters created for `<image>` elements, to load their
6962
+ images with CORS</li>
6921
6963
  <li><tt>options.onLoad: <tt>Function</tt></tt> &mdash; the callback function to call once the SVG content is loaded from the given URL receiving two arguments: the converted <code>item</code> and the original <code>svg</code> data as a string. Only required when loading from external resources.</li>
6922
6964
  <li><tt>options.onError: <tt>Function</tt></tt> &mdash; the callback function to call if an error occurs during loading. Only required when loading from external resources.</li>
6923
6965
  <li><tt>options.insert: <tt>Boolean</tt></tt> &mdash; whether the imported items should be added to the item that <code>importSVG()</code> is called on &mdash;&nbsp;default: <tt>true</tt></li>
@@ -7757,7 +7799,7 @@ Array of <a href="../classes/Item.html"><tt>Item</tt></a> objects
7757
7799
  </div>
7758
7800
  <div class="member-description hidden">
7759
7801
  <div class="member-text">
7760
- <p>Checks if this item is above the specified item in the stacking order of the project.</p>
7802
+ <p>Checks if this item is above the specified item in the stacking order of the project. If one item is a descendant of the other, neither is above the other and <code>false</code> is returned.</p>
7761
7803
 
7762
7804
 
7763
7805
  <ul class="member-list">
@@ -7798,7 +7840,7 @@ Array of <a href="../classes/Item.html"><tt>Item</tt></a> objects
7798
7840
  </div>
7799
7841
  <div class="member-description hidden">
7800
7842
  <div class="member-text">
7801
- <p>Checks if the item is below the specified item in the stacking order of the project.</p>
7843
+ <p>Checks if the item is below the specified item in the stacking order of the project. If one item is a descendant of the other, neither is below the other and <code>false</code> is returned.</p>
7802
7844
 
7803
7845
 
7804
7846
  <ul class="member-list">
@@ -8756,11 +8798,11 @@ circle.scale(3, 1);
8756
8798
 
8757
8799
  <div id="fitbounds-rectangle" class="member">
8758
8800
  <div class="member-link">
8759
- <a name="fitbounds-rectangle" href="#fitbounds-rectangle"><tt><b>fitBounds</b>(rectangle[, fill])</tt></a>
8801
+ <a name="fitbounds-rectangle" href="#fitbounds-rectangle"><tt><b>fitBounds</b>(rectangle[, fit])</tt></a>
8760
8802
  </div>
8761
8803
  <div class="member-description hidden">
8762
8804
  <div class="member-text">
8763
- <p>Transform the item so that its <a href="../classes/Item.html#bounds"><tt>bounds</tt></a> fit within the specified rectangle, without changing its aspect ratio.</p>
8805
+ <p>Transform the item so that its <a href="../classes/Item.html#bounds"><tt>bounds</tt></a> are centered in the specified rectangle and fitted to it as described by <code>fit</code>.</p>
8764
8806
 
8765
8807
 
8766
8808
  <ul class="member-list">
@@ -8774,10 +8816,10 @@ circle.scale(3, 1);
8774
8816
  </li>
8775
8817
 
8776
8818
  <li>
8777
- <tt>fill:</tt>
8778
- <tt>Boolean</tt>
8779
-
8780
- &mdash;&nbsp;optional, default: <tt>false</tt>
8819
+ <tt>fit:</tt>
8820
+ <tt>String</tt>⟋<tt>Boolean</tt>
8821
+ &mdash;&nbsp;how to fit the item, as in CSS&rsquo;s <code>object-fit</code>: <code>&#39;contain&#39;</code> fits all of it within the rectangle, <code>&#39;cover&#39;</code> makes it cover the whole rectangle, and <code>&#39;fill&#39;</code> stretches it to the rectangle, changing its aspect ratio. The deprecated <code>true</code> and <code>false</code> stand for <code>&#39;cover&#39;</code> and <code>&#39;contain&#39;</code>.
8822
+ &mdash;&nbsp;optional, default: <tt>&lsquo;contain&rsquo;</tt>
8781
8823
  </li>
8782
8824
 
8783
8825
  </ul>
@@ -8819,7 +8861,7 @@ circlePath.fitBounds(path.bounds);
8819
8861
  </div>
8820
8862
 
8821
8863
 
8822
- <h4>Example:<span class="description">Fitting an item to the bounding rectangle of another item's bounding rectangle with the fill parameter set to true:</span></h4>
8864
+ <h4>Example:<span class="description">Fitting an item to the bounding rectangle of another item's bounding rectangle, covering all of it:</span></h4>
8823
8865
 
8824
8866
  <div class="paperscript split">
8825
8867
 
@@ -8846,7 +8888,7 @@ var circlePath = new Path.Circle({
8846
8888
 
8847
8889
  // Fit the circlePath to the bounding rectangle of
8848
8890
  // the rectangular path:
8849
- circlePath.fitBounds(path.bounds, true);
8891
+ circlePath.fitBounds(path.bounds, 'cover');
8850
8892
  </script>
8851
8893
  <div class="canvas"><canvas width="516" height="100" id="canvas-93"></canvas></div>
8852
8894
  </div>
@@ -9496,7 +9538,7 @@ function onMouseDown(event) {
9496
9538
  <ul class="member-list">
9497
9539
  <h4>Options:</h4>
9498
9540
  <li><tt>options.duration: <tt>Number</tt></tt> &mdash; the duration of the tweening</li>
9499
- <li><tt>options.easing: <tt>Function</tt>⟋<tt>String</tt></tt> &mdash; an easing function or the type of the easing: <tt>&lsquo;linear&rsquo; &lsquo;easeInQuad&rsquo; &lsquo;easeOutQuad&rsquo; &lsquo;easeInOutQuad&rsquo; &lsquo;easeInCubic&rsquo; &lsquo;easeOutCubic&rsquo; &lsquo;easeInOutCubic&rsquo; &lsquo;easeInQuart&rsquo; &lsquo;easeOutQuart&rsquo; &lsquo;easeInOutQuart&rsquo; &lsquo;easeInQuint&rsquo; &lsquo;easeOutQuint&rsquo; &lsquo;easeInOutQuint&rsquo;</tt> &mdash;&nbsp;default: <tt>&lsquo;linear&rsquo;</tt></li>
9541
+ <li><tt>options.easing: <tt>Function</tt>⟋<tt>String</tt></tt> &mdash; an easing function or the type of the easing: <tt>&lsquo;linear&rsquo; &lsquo;easeInQuad&rsquo; &lsquo;easeOutQuad&rsquo; &lsquo;easeInOutQuad&rsquo; &lsquo;easeInCubic&rsquo; &lsquo;easeOutCubic&rsquo; &lsquo;easeInOutCubic&rsquo; &lsquo;easeInQuart&rsquo; &lsquo;easeOutQuart&rsquo; &lsquo;easeInOutQuart&rsquo; &lsquo;easeInQuint&rsquo; &lsquo;easeOutQuint&rsquo; &lsquo;easeInOutQuint&rsquo; &lsquo;easeInSine&rsquo; &lsquo;easeOutSine&rsquo; &lsquo;easeInOutSine&rsquo; &lsquo;easeInExpo&rsquo; &lsquo;easeOutExpo&rsquo; &lsquo;easeInOutExpo&rsquo; &lsquo;easeInCirc&rsquo; &lsquo;easeOutCirc&rsquo; &lsquo;easeInOutCirc&rsquo;</tt> &mdash;&nbsp;default: <tt>&lsquo;linear&rsquo;</tt></li>
9500
9542
  <li><tt>options.start: <tt>Boolean</tt></tt> &mdash; whether to start tweening automatically &mdash;&nbsp;default: <tt>true</tt></li>
9501
9543
  </ul>
9502
9544
 
@@ -10028,7 +10070,23 @@ path.tweenFrom({ fillColor: 'red' }, { duration: 1000 });
10028
10070
 
10029
10071
 
10030
10072
 
10031
-
10073
+ <h4>Example:</h4>
10074
+
10075
+ <div class="paperscript split">
10076
+
10077
+ <div class="buttons">
10078
+ <div class="button run">Run</div>
10079
+ </div>
10080
+
10081
+ <script type="text/paperscript" canvas="canvas-108">
10082
+ var result = new Path.RegularPolygon([50, 50], 3, 40)
10083
+ .unite(new Path.Circle([50, 50], 25));
10084
+ result.fillColor = 'red';
10085
+ </script>
10086
+ <div class="canvas"><canvas width="516" height="100" id="canvas-108"></canvas></div>
10087
+ </div>
10088
+
10089
+
10032
10090
  </div>
10033
10091
  </div>
10034
10092
  </div>
@@ -10080,7 +10138,23 @@ path.tweenFrom({ fillColor: 'red' }, { duration: 1000 });
10080
10138
 
10081
10139
 
10082
10140
 
10083
-
10141
+ <h4>Example:</h4>
10142
+
10143
+ <div class="paperscript split">
10144
+
10145
+ <div class="buttons">
10146
+ <div class="button run">Run</div>
10147
+ </div>
10148
+
10149
+ <script type="text/paperscript" canvas="canvas-109">
10150
+ var result = new Path.RegularPolygon([50, 50], 3, 40)
10151
+ .intersect(new Path.Circle([50, 50], 25));
10152
+ result.fillColor = 'red';
10153
+ </script>
10154
+ <div class="canvas"><canvas width="516" height="100" id="canvas-109"></canvas></div>
10155
+ </div>
10156
+
10157
+
10084
10158
  </div>
10085
10159
  </div>
10086
10160
  </div>
@@ -10132,7 +10206,23 @@ path.tweenFrom({ fillColor: 'red' }, { duration: 1000 });
10132
10206
 
10133
10207
 
10134
10208
 
10135
-
10209
+ <h4>Example:</h4>
10210
+
10211
+ <div class="paperscript split">
10212
+
10213
+ <div class="buttons">
10214
+ <div class="button run">Run</div>
10215
+ </div>
10216
+
10217
+ <script type="text/paperscript" canvas="canvas-110">
10218
+ var result = new Path.RegularPolygon([50, 50], 3, 40)
10219
+ .subtract(new Path.Circle([50, 50], 25));
10220
+ result.fillColor = 'red';
10221
+ </script>
10222
+ <div class="canvas"><canvas width="516" height="100" id="canvas-110"></canvas></div>
10223
+ </div>
10224
+
10225
+
10136
10226
  </div>
10137
10227
  </div>
10138
10228
  </div>
@@ -10183,7 +10273,23 @@ path.tweenFrom({ fillColor: 'red' }, { duration: 1000 });
10183
10273
 
10184
10274
 
10185
10275
 
10186
-
10276
+ <h4>Example:</h4>
10277
+
10278
+ <div class="paperscript split">
10279
+
10280
+ <div class="buttons">
10281
+ <div class="button run">Run</div>
10282
+ </div>
10283
+
10284
+ <script type="text/paperscript" canvas="canvas-111">
10285
+ var result = new Path.RegularPolygon([50, 50], 3, 40)
10286
+ .exclude(new Path.Circle([50, 50], 25));
10287
+ result.fillColor = 'red';
10288
+ </script>
10289
+ <div class="canvas"><canvas width="516" height="100" id="canvas-111"></canvas></div>
10290
+ </div>
10291
+
10292
+
10187
10293
  </div>
10188
10294
  </div>
10189
10295
  </div>
@@ -10291,9 +10397,9 @@ path.tweenFrom({ fillColor: 'red' }, { duration: 1000 });
10291
10397
 
10292
10398
  <h3>Path Intersections and Locations</h3>
10293
10399
 
10294
- <div id="getintersections-path" class="member">
10400
+ <div id="getintersections" class="member">
10295
10401
  <div class="member-link">
10296
- <a name="getintersections-path" href="#getintersections-path"><tt><b>getIntersections</b>(path[, include])</tt></a>
10402
+ <a name="getintersections" href="#getintersections"><tt><b>getIntersections</b>([path[, include]])</tt></a>
10297
10403
  </div>
10298
10404
  <div class="member-description hidden">
10299
10405
  <div class="member-text">
@@ -10307,7 +10413,7 @@ path.tweenFrom({ fillColor: 'red' }, { duration: 1000 });
10307
10413
  <tt>path:</tt>
10308
10414
  <a href="../classes/PathItem.html"><tt>PathItem</tt></a>
10309
10415
  &mdash;&nbsp;the other item to find the intersections with
10310
-
10416
+ &mdash;&nbsp;optional
10311
10417
  </li>
10312
10418
 
10313
10419
  <li>
@@ -10348,7 +10454,7 @@ path.tweenFrom({ fillColor: 'red' }, { duration: 1000 });
10348
10454
  <div class="button run">Run</div>
10349
10455
  </div>
10350
10456
 
10351
- <script type="text/paperscript" canvas="canvas-108">
10457
+ <script type="text/paperscript" canvas="canvas-112">
10352
10458
  var path = new Path.Rectangle(new Point(30, 25), new Size(50, 50));
10353
10459
  path.strokeColor = 'black';
10354
10460
 
@@ -10371,7 +10477,7 @@ function onFrame(event) {
10371
10477
  }
10372
10478
  }
10373
10479
  </script>
10374
- <div class="canvas"><canvas width="516" height="100" id="canvas-108"></canvas></div>
10480
+ <div class="canvas"><canvas width="516" height="100" id="canvas-112"></canvas></div>
10375
10481
  </div>
10376
10482
 
10377
10483
 
@@ -10512,7 +10618,7 @@ function onFrame(event) {
10512
10618
  <div class="button run">Run</div>
10513
10619
  </div>
10514
10620
 
10515
- <script type="text/paperscript" canvas="canvas-109">
10621
+ <script type="text/paperscript" canvas="canvas-113">
10516
10622
  var star = new Path.Star({
10517
10623
  center: view.center,
10518
10624
  points: 10,
@@ -10536,7 +10642,7 @@ function onMouseMove(event) {
10536
10642
  circle.position = nearestPoint;
10537
10643
  }
10538
10644
  </script>
10539
- <div class="canvas"><canvas width="516" height="200" id="canvas-109"></canvas></div>
10645
+ <div class="canvas"><canvas width="516" height="200" id="canvas-113"></canvas></div>
10540
10646
  </div>
10541
10647
 
10542
10648
 
@@ -10599,7 +10705,7 @@ function onMouseMove(event) {
10599
10705
  <div class="button run">Run</div>
10600
10706
  </div>
10601
10707
 
10602
- <script type="text/paperscript" canvas="canvas-110">
10708
+ <script type="text/paperscript" canvas="canvas-114">
10603
10709
  // Create a circle shaped path at { x: 80, y: 50 }
10604
10710
  // with a radius of 35:
10605
10711
  var path = new Path.Circle({
@@ -10617,7 +10723,7 @@ copy.position.x += 150;
10617
10723
  // Flatten the copied path, with a maximum error of 4 points:
10618
10724
  copy.flatten(4);
10619
10725
  </script>
10620
- <div class="canvas"><canvas width="516" height="100" id="canvas-110"></canvas></div>
10726
+ <div class="canvas"><canvas width="516" height="100" id="canvas-114"></canvas></div>
10621
10727
  </div>
10622
10728
 
10623
10729
 
@@ -10695,7 +10801,7 @@ copy.flatten(4);
10695
10801
  <div class="button run">Run</div>
10696
10802
  </div>
10697
10803
 
10698
- <script type="text/paperscript" canvas="canvas-111">
10804
+ <script type="text/paperscript" canvas="canvas-115">
10699
10805
  // Create a rectangular path with its top-left point at
10700
10806
  // {x: 30, y: 25} and a size of {width: 50, height: 50}:
10701
10807
  var path = new Path.Rectangle({
@@ -10714,7 +10820,7 @@ copy.position.x += 100;
10714
10820
  // Smooth the segments of the copy:
10715
10821
  copy.smooth({ type: 'continuous' });
10716
10822
  </script>
10717
- <div class="canvas"><canvas width="516" height="100" id="canvas-111"></canvas></div>
10823
+ <div class="canvas"><canvas width="516" height="100" id="canvas-115"></canvas></div>
10718
10824
  </div>
10719
10825
 
10720
10826
 
@@ -10726,7 +10832,7 @@ copy.smooth({ type: 'continuous' });
10726
10832
  <div class="button run">Run</div>
10727
10833
  </div>
10728
10834
 
10729
- <script type="text/paperscript" canvas="canvas-112">
10835
+ <script type="text/paperscript" canvas="canvas-116">
10730
10836
  var path = new Path();
10731
10837
  path.strokeColor = 'black';
10732
10838
 
@@ -10751,7 +10857,7 @@ copy.fullySelected = true;
10751
10857
  // Smooth the path using centripetal Catmull-Rom splines:
10752
10858
  copy.smooth({ type: 'catmull-rom', factor: 0.5 });
10753
10859
  </script>
10754
- <div class="canvas"><canvas width="516" height="220" id="canvas-112"></canvas></div>
10860
+ <div class="canvas"><canvas width="516" height="220" id="canvas-116"></canvas></div>
10755
10861
  </div>
10756
10862
 
10757
10863
 
@@ -10763,7 +10869,7 @@ copy.smooth({ type: 'catmull-rom', factor: 0.5 });
10763
10869
  <div class="button run">Run</div>
10764
10870
  </div>
10765
10871
 
10766
- <script type="text/paperscript" canvas="canvas-113">
10872
+ <script type="text/paperscript" canvas="canvas-117">
10767
10873
  // Create 5 rectangles, next to each other:
10768
10874
  var paths = [];
10769
10875
  for (var i = 0; i < 5; i++) {
@@ -10793,7 +10899,7 @@ paths[3].smooth({ type: 'continuous', from: 0, to: 2 });
10793
10899
  // Smooth a range, using negative indices:
10794
10900
  paths[4].smooth({ type: 'continuous', from: -1, to: 1 });
10795
10901
  </script>
10796
- <div class="canvas"><canvas width="516" height="110" id="canvas-113"></canvas></div>
10902
+ <div class="canvas"><canvas width="516" height="110" id="canvas-117"></canvas></div>
10797
10903
  </div>
10798
10904
 
10799
10905
 
@@ -10846,7 +10952,7 @@ paths[4].smooth({ type: 'continuous', from: -1, to: 1 });
10846
10952
  <div class="button run">Run</div>
10847
10953
  </div>
10848
10954
 
10849
- <script type="text/paperscript" canvas="canvas-114">
10955
+ <script type="text/paperscript" canvas="canvas-118">
10850
10956
  var path;
10851
10957
  function onMouseDown(event) {
10852
10958
  // If we already made a path before, deselect it:
@@ -10876,7 +10982,7 @@ function onMouseUp(event) {
10876
10982
  path.selected = true;
10877
10983
  }
10878
10984
  </script>
10879
- <div class="canvas"><canvas width="516" height="300" id="canvas-114"></canvas></div>
10985
+ <div class="canvas"><canvas width="516" height="300" id="canvas-118"></canvas></div>
10880
10986
  </div>
10881
10987
 
10882
10988
 
@@ -11075,7 +11181,7 @@ function onMouseUp(event) {
11075
11181
  <div class="button run">Run</div>
11076
11182
  </div>
11077
11183
 
11078
- <script type="text/paperscript" canvas="canvas-115">
11184
+ <script type="text/paperscript" canvas="canvas-119">
11079
11185
  var path = new Path();
11080
11186
  path.strokeColor = 'black';
11081
11187
 
@@ -11095,7 +11201,7 @@ path.arcTo(throughPoint, toPoint);
11095
11201
  var circle = new Path.Circle(throughPoint, 3);
11096
11202
  circle.fillColor = 'red';
11097
11203
  </script>
11098
- <div class="canvas"><canvas width="516" height="100" id="canvas-115"></canvas></div>
11204
+ <div class="canvas"><canvas width="516" height="100" id="canvas-119"></canvas></div>
11099
11205
  </div>
11100
11206
 
11101
11207
 
@@ -11107,7 +11213,7 @@ circle.fillColor = 'red';
11107
11213
  <div class="button run">Run</div>
11108
11214
  </div>
11109
11215
 
11110
- <script type="text/paperscript" canvas="canvas-116">
11216
+ <script type="text/paperscript" canvas="canvas-120">
11111
11217
  var myPath;
11112
11218
  function onMouseDrag(event) {
11113
11219
  // If we created a path before, remove it:
@@ -11135,7 +11241,7 @@ function onMouseUp(event) {
11135
11241
  myPath.fillColor = 'black';
11136
11242
  }
11137
11243
  </script>
11138
- <div class="canvas"><canvas width="516" height="300" id="canvas-116"></canvas></div>
11244
+ <div class="canvas"><canvas width="516" height="300" id="canvas-120"></canvas></div>
11139
11245
  </div>
11140
11246
 
11141
11247
 
@@ -11184,7 +11290,7 @@ function onMouseUp(event) {
11184
11290
  <div class="button run">Run</div>
11185
11291
  </div>
11186
11292
 
11187
- <script type="text/paperscript" canvas="canvas-117">
11293
+ <script type="text/paperscript" canvas="canvas-121">
11188
11294
  var path = new Path();
11189
11295
  path.strokeColor = 'black';
11190
11296
 
@@ -11199,7 +11305,7 @@ path2.add(new Point(180, 25));
11199
11305
  // we pass `false` as the second argument to arcTo:
11200
11306
  path2.arcTo(new Point(280, 25), false);
11201
11307
  </script>
11202
- <div class="canvas"><canvas width="516" height="100" id="canvas-117"></canvas></div>
11308
+ <div class="canvas"><canvas width="516" height="100" id="canvas-121"></canvas></div>
11203
11309
  </div>
11204
11310
 
11205
11311
 
@@ -11211,7 +11317,7 @@ path2.arcTo(new Point(280, 25), false);
11211
11317
  <div class="button run">Run</div>
11212
11318
  </div>
11213
11319
 
11214
- <script type="text/paperscript" canvas="canvas-118">
11320
+ <script type="text/paperscript" canvas="canvas-122">
11215
11321
  var myPath;
11216
11322
 
11217
11323
  // The mouse has to move at least 20 points before
@@ -11232,7 +11338,7 @@ function onMouseDrag(event) {
11232
11338
  myPath.arcTo(event.point);
11233
11339
  }
11234
11340
  </script>
11235
- <div class="canvas"><canvas width="516" height="300" id="canvas-118"></canvas></div>
11341
+ <div class="canvas"><canvas width="516" height="300" id="canvas-122"></canvas></div>
11236
11342
  </div>
11237
11343
 
11238
11344
 
@@ -11288,7 +11394,7 @@ function onMouseDrag(event) {
11288
11394
  <div class="button run">Run</div>
11289
11395
  </div>
11290
11396
 
11291
- <script type="text/paperscript" canvas="canvas-119">
11397
+ <script type="text/paperscript" canvas="canvas-123">
11292
11398
  var myPath;
11293
11399
  function onMouseMove(event) {
11294
11400
  // If we created a path before, remove it:
@@ -11309,7 +11415,7 @@ function onMouseMove(event) {
11309
11415
  myPath.selected = true;
11310
11416
  }
11311
11417
  </script>
11312
- <div class="canvas"><canvas width="516" height="300" id="canvas-119"></canvas></div>
11418
+ <div class="canvas"><canvas width="516" height="300" id="canvas-123"></canvas></div>
11313
11419
  </div>
11314
11420
 
11315
11421
 
@@ -11494,7 +11600,7 @@ function onMouseMove(event) {
11494
11600
  <div class="button run">Run</div>
11495
11601
  </div>
11496
11602
 
11497
- <script type="text/paperscript" canvas="canvas-120">
11603
+ <script type="text/paperscript" canvas="canvas-124">
11498
11604
  var path = new Path();
11499
11605
  path.strokeColor = 'black';
11500
11606
 
@@ -11508,7 +11614,7 @@ path.lineBy(50, 0);
11508
11614
  // 0 in x direction and 50 in y direction, becomes {x: 75, y: 75}
11509
11615
  path.lineBy(0, 50);
11510
11616
  </script>
11511
- <div class="canvas"><canvas width="516" height="100" id="canvas-120"></canvas></div>
11617
+ <div class="canvas"><canvas width="516" height="100" id="canvas-124"></canvas></div>
11512
11618
  </div>
11513
11619
 
11514
11620
 
@@ -11520,7 +11626,7 @@ path.lineBy(0, 50);
11520
11626
  <div class="button run">Run</div>
11521
11627
  </div>
11522
11628
 
11523
- <script type="text/paperscript" canvas="canvas-121">
11629
+ <script type="text/paperscript" canvas="canvas-125">
11524
11630
  var path = new Path();
11525
11631
  path.strokeColor = 'black';
11526
11632
 
@@ -11546,7 +11652,7 @@ path.smooth();
11546
11652
  // the construction of the path:
11547
11653
  // path.selected = true;
11548
11654
  </script>
11549
- <div class="canvas"><canvas width="516" height="300" id="canvas-121"></canvas></div>
11655
+ <div class="canvas"><canvas width="516" height="300" id="canvas-125"></canvas></div>
11550
11656
  </div>
11551
11657
 
11552
11658
 
@@ -11765,7 +11871,7 @@ path.smooth();
11765
11871
 
11766
11872
  <!-- =========================== copyright notice ========================== -->
11767
11873
  <p class="footer">
11768
- Paper.js v0.12.19<br>
11874
+ Paper.js v0.13.0<br>
11769
11875
  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>
11770
11876
  <div class="content-end"></div>
11771
11877