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
@@ -1350,6 +1350,46 @@ var path = new Path.Star({
1350
1350
  <h2>Properties</h2>
1351
1351
 
1352
1352
 
1353
+ <div id="strokeprofile" class="member">
1354
+ <div class="member-link">
1355
+ <a name="strokeprofile" href="#strokeprofile"><tt><b>strokeProfile</b></tt></a>
1356
+ </div>
1357
+ <div class="member-description hidden">
1358
+
1359
+ <div class="member-text">
1360
+ <p>The stroke profile of the path: the stops along it that set the pen that draws its stroke, an ellipse with a width, as a factor of its <a href="../classes/Style.html#strokewidth"><tt>style.strokeWidth</tt></a>, an aspect and an angle, see <a href="../classes/StrokeProfileStop.html"><tt>StrokeProfileStop</tt></a>. The stops are sorted by their offsets. Between the stops that set a value, it changes along the path, easing into and out of smooth stops and in straight lines from the others, see <a href="../classes/StrokeProfileStop.html#smooth"><tt>strokeProfileStop.smooth</tt></a>, and beyond the ends of open paths, it stays as at the first and last of them. Two stops at the same offset make a step. The stops stay between the same segments when they move. Without a stroke profile, the stroke is drawn with a round pen of the stroke width all along.</p>
1361
+ <p>It is a property of the path, not of its style, as it is tied to its segments. It can be set to stops or plain objects describing them, <code>{ offset, width, aspect, angle, smooth }</code>, and JSON stores them with the indices that tie them to the segments instead of their offsets, <code>{ index, width, aspect, angle, smooth }</code>. Changing the returned array directly isn&rsquo;t tracked, as with <a href="../classes/Path.html#segments"><tt>segments</tt></a>.</p>
1362
+ <p>The path draws its stroke as the area that the pens sweep, filled with the stroke color, as <a href="../classes/PathItem.html#outline"><tt>pathItem.outline</tt></a>() returns it, and <a href="../classes/Item.html#strokebounds"><tt>item.strokeBounds</tt></a> and hit-testing measure that area. The children of compound paths are drawn with the stroke of their parent, without their profiles. With <a href="../classes/Style.html#strokescaling"><tt>style.strokeScaling</tt></a> off, the profile scales with the view. <a href="../classes/PathItem.html#offset"><tt>pathItem.offset</tt></a>(), the boolean operations, <a href="../classes/PathItem.html#interpolate"><tt>pathItem.interpolate</tt></a>() and SVG export return paths without the profile.</p>
1363
+
1364
+
1365
+
1366
+ <ul class="member-list">
1367
+ <h4>Type:</h4>
1368
+ <li>
1369
+ Array of <a href="../classes/StrokeProfileStop.html"><tt>StrokeProfileStop</tt></a> objects⟋<tt>null</tt>
1370
+ </li>
1371
+ </ul>
1372
+
1373
+
1374
+ <h4>Example:</h4>
1375
+
1376
+
1377
+ <pre><code>var path = new Path.Line([20, 50], [180, 50]);
1378
+ path.strokeColor = 'black';
1379
+ path.strokeWidth = 10;
1380
+ // Taper the stroke from half its width to twice its width:
1381
+ path.strokeProfile = [
1382
+ { offset: 0, width: 0.5 },
1383
+ { offset: path.length, width: 2 }
1384
+ ];
1385
+ console.log(path.getStrokeProfileAt(80).width); // 1.25</code></pre>
1386
+
1387
+ </div>
1388
+
1389
+ </div>
1390
+ </div>
1391
+
1392
+
1353
1393
  <div id="segments" class="member">
1354
1394
  <div class="member-link">
1355
1395
  <a name="segments" href="#segments"><tt><b>segments</b></tt></a>
@@ -1715,6 +1755,59 @@ if (path2.fullySelected) {
1715
1755
  <h2>Methods</h2>
1716
1756
 
1717
1757
 
1758
+ <div id="getstrokeprofileat-offset" class="member">
1759
+ <div class="member-link">
1760
+ <a name="getstrokeprofileat-offset" href="#getstrokeprofileat-offset"><tt><b>getStrokeProfileAt</b>(offset)</tt></a>
1761
+ </div>
1762
+ <div class="member-description hidden">
1763
+ <div class="member-text">
1764
+ <p>Returns the pen of the <a href="../classes/Path.html#strokeprofile"><tt>strokeProfile</tt></a> at the given offset along the path, as a stop that isn&rsquo;t on the path, with all its values: its width as a factor of the <a href="../classes/Style.html#strokewidth"><tt>style.strokeWidth</tt></a>, its aspect and its angle, <code>1</code>, <code>1</code> and <code>0</code> where no stop sets them. Where the profile has a step, it returns the values after it. Adding the stop to the profile keeps the values at the offset, and where they change in straight lines, also around it if the stop isn&rsquo;t smooth. As a smooth stop, the values ease into it and out of it.</p>
1765
+
1766
+
1767
+ <ul class="member-list">
1768
+ <h4>Parameters:</h4>
1769
+
1770
+ <li>
1771
+ <tt>offset:</tt>
1772
+ <tt>Number</tt>
1773
+ &mdash;&nbsp;the offset on the path, where <code>0</code> is at the beginning of the path and <a href="../classes/Path.html#length"><tt>path.length</tt></a> at the end
1774
+
1775
+ </li>
1776
+
1777
+ </ul>
1778
+
1779
+
1780
+ <ul class="member-list">
1781
+ <h4>Returns:</h4>
1782
+
1783
+ <li>
1784
+ <tt><a href="../classes/StrokeProfileStop.html"><tt>StrokeProfileStop</tt></a></tt>&nbsp;&mdash;&nbsp;the pen at the offset
1785
+ </li>
1786
+
1787
+
1788
+ </ul>
1789
+
1790
+
1791
+
1792
+
1793
+ <h4>Example:</h4>
1794
+
1795
+
1796
+ <pre><code>var path = new Path.Line([20, 50], [180, 50]);
1797
+ path.strokeProfile = [
1798
+ { offset: 0, width: 0.5 },
1799
+ { offset: path.length, width: 2, angle: 90 }
1800
+ ];
1801
+ // Add a stop halfway, with the values there:
1802
+ var stop = path.getStrokeProfileAt(path.length / 2);
1803
+ console.log(stop.width, stop.aspect, stop.angle); // 1.25 1 90
1804
+ path.strokeProfile = path.strokeProfile.concat(stop);</code></pre>
1805
+
1806
+ </div>
1807
+ </div>
1808
+ </div>
1809
+
1810
+
1718
1811
  <div id="add-segment" class="member">
1719
1812
  <div class="member-link">
1720
1813
  <a name="add-segment" href="#add-segment"><tt><b>add</b>(...segment)</tt></a>
@@ -3367,6 +3460,91 @@ for (var i = 0; i < amount + 1; i++) {
3367
3460
  <div class="reference-members"><h2>Properties inherited from <a href="../classes/Item.html"><tt>Item</tt></a></h2>
3368
3461
 
3369
3462
 
3463
+ <div id="effects" class="member">
3464
+ <div class="member-link">
3465
+ <a name="effects" href="#effects"><tt><b>effects</b></tt></a>
3466
+ </div>
3467
+ <div class="member-description hidden">
3468
+
3469
+ <div class="member-text">
3470
+ <p>The live effects of the item, in the order in which they apply, as the instances of the <tt>Effecteffects</tt> that they use. They derive what is drawn from the item without changing it: drawing draws their output, and <a href="../classes/Item.html#previewbounds"><tt>previewBounds</tt></a> measures it, while hit testing, <a href="../classes/Item.html#bounds"><tt>bounds</tt></a> and <a href="../classes/Item.html#strokebounds"><tt>strokeBounds</tt></a> stay with the item itself. It is set to plain objects describing them, <code>{ type,
3471
+ parameters, visible }</code>, with the <code>type</code> of the effect. Changing the returned array directly isn&rsquo;t tracked, as with <a href="../classes/Path.html#segments"><tt>path.segments</tt></a>.</p>
3472
+ <p>Paper.js has these effects, and <a href="../classes/Effect.html"><tt>Effect</tt></a> creates more:</p>
3473
+ <ul>
3474
+ <li><code>offset</code>: offsets the paths, see <a href="../classes/PathItem.html#offset"><tt>pathItem.offset</tt></a>(), with the parameters <code>distance</code> (<code>0</code>), <code>join</code> (<code>&#39;miter&#39;</code>) and <code>miterLimit</code> (<code>10</code>).</li>
3475
+ <li><code>outline</code>: outlines the strokes of the paths as filled areas next to their fills, see <a href="../classes/PathItem.html#outline"><tt>pathItem.outline</tt></a>(), following their <a href="../classes/Path.html#strokeprofile"><tt>path.strokeProfile</tt></a>.</li>
3476
+ </ul>
3477
+
3478
+
3479
+
3480
+ <ul class="member-list">
3481
+ <h4>Type:</h4>
3482
+ <li>
3483
+ Array of <a href="../classes/EffectInstance.html"><tt>EffectInstance</tt></a> objects
3484
+ </li>
3485
+ </ul>
3486
+
3487
+
3488
+ <h4>Example:</h4>
3489
+
3490
+ <div class="paperscript split">
3491
+
3492
+ <div class="buttons">
3493
+ <div class="button run">Run</div>
3494
+ </div>
3495
+
3496
+ <script type="text/paperscript" canvas="canvas-50">
3497
+ var path = new Path.Star({
3498
+ center: view.center,
3499
+ points: 5,
3500
+ radius1: 20,
3501
+ radius2: 40,
3502
+ strokeColor: 'black',
3503
+ strokeWidth: 8
3504
+ });
3505
+ path.effects = [
3506
+ { type: 'offset', parameters: { distance: 10, join: 'round' } },
3507
+ { type: 'outline' }
3508
+ ];
3509
+ </script>
3510
+ <div class="canvas"><canvas width="516" height="100" id="canvas-50"></canvas></div>
3511
+ </div>
3512
+
3513
+
3514
+ </div>
3515
+
3516
+ </div>
3517
+ </div>
3518
+
3519
+
3520
+ <div id="previewbounds-matrix" class="member">
3521
+ <div class="member-link">
3522
+ <a name="previewbounds-matrix" href="#previewbounds-matrix"><tt><b>previewBounds</b></tt></a>
3523
+ </div>
3524
+ <div class="member-description hidden">
3525
+
3526
+ <div class="member-text">
3527
+ <p>The bounds of what the item looks like with its effects, in the coordinate space of its parent: of their output with its strokes, or of its children&rsquo;s with their effects, and its <a href="../classes/Item.html#strokebounds"><tt>strokeBounds</tt></a> without them, as Illustrator&rsquo;s &ldquo;Use Preview Bounds&rdquo;.</p>
3528
+
3529
+ <p>Read only.</p>
3530
+
3531
+
3532
+
3533
+ <ul class="member-list">
3534
+ <h4>Type:</h4>
3535
+ <li>
3536
+ <a href="../classes/Rectangle.html"><tt>Rectangle</tt></a>
3537
+ </li>
3538
+ </ul>
3539
+
3540
+
3541
+
3542
+ </div>
3543
+
3544
+ </div>
3545
+ </div>
3546
+
3547
+
3370
3548
  <div id="key" class="member">
3371
3549
  <div class="member-link">
3372
3550
  <a name="key" href="#key"><tt><b>key</b></tt></a>
@@ -3479,7 +3657,7 @@ for (var i = 0; i < amount + 1; i++) {
3479
3657
  <div class="button run">Run</div>
3480
3658
  </div>
3481
3659
 
3482
- <script type="text/paperscript" canvas="canvas-50">
3660
+ <script type="text/paperscript" canvas="canvas-51">
3483
3661
  var path = new Path.Circle({
3484
3662
  center: [80, 50],
3485
3663
  radius: 35
@@ -3494,7 +3672,7 @@ group.addChild(path);
3494
3672
  // The path can be accessed by name:
3495
3673
  group.children['example'].fillColor = 'red';
3496
3674
  </script>
3497
- <div class="canvas"><canvas width="516" height="100" id="canvas-50"></canvas></div>
3675
+ <div class="canvas"><canvas width="516" height="100" id="canvas-51"></canvas></div>
3498
3676
  </div>
3499
3677
 
3500
3678
 
@@ -3532,7 +3710,7 @@ group.children['example'].fillColor = 'red';
3532
3710
  <div class="button run">Run</div>
3533
3711
  </div>
3534
3712
 
3535
- <script type="text/paperscript" canvas="canvas-51">
3713
+ <script type="text/paperscript" canvas="canvas-52">
3536
3714
  var circle = new Path.Circle({
3537
3715
  center: [80, 50],
3538
3716
  radius: 30
@@ -3543,7 +3721,7 @@ circle.style = {
3543
3721
  strokeWidth: 5
3544
3722
  };
3545
3723
  </script>
3546
- <div class="canvas"><canvas width="516" height="100" id="canvas-51"></canvas></div>
3724
+ <div class="canvas"><canvas width="516" height="100" id="canvas-52"></canvas></div>
3547
3725
  </div>
3548
3726
 
3549
3727
 
@@ -3555,7 +3733,7 @@ circle.style = {
3555
3733
  <div class="button run">Run</div>
3556
3734
  </div>
3557
3735
 
3558
- <script type="text/paperscript" canvas="canvas-52">
3736
+ <script type="text/paperscript" canvas="canvas-53">
3559
3737
  var path = new Path.Circle({
3560
3738
  center: [50, 50],
3561
3739
  radius: 30,
@@ -3570,7 +3748,7 @@ var path2 = new Path.Circle({
3570
3748
  // Copy the path style of path:
3571
3749
  path2.style = path.style;
3572
3750
  </script>
3573
- <div class="canvas"><canvas width="516" height="100" id="canvas-52"></canvas></div>
3751
+ <div class="canvas"><canvas width="516" height="100" id="canvas-53"></canvas></div>
3574
3752
  </div>
3575
3753
 
3576
3754
 
@@ -3582,7 +3760,7 @@ path2.style = path.style;
3582
3760
  <div class="button run">Run</div>
3583
3761
  </div>
3584
3762
 
3585
- <script type="text/paperscript" canvas="canvas-53">
3763
+ <script type="text/paperscript" canvas="canvas-54">
3586
3764
  var myStyle = {
3587
3765
  fillColor: 'red',
3588
3766
  strokeColor: 'blue',
@@ -3601,7 +3779,7 @@ var path2 = new Path.Circle({
3601
3779
  });
3602
3780
  path2.style = myStyle;
3603
3781
  </script>
3604
- <div class="canvas"><canvas width="516" height="100" id="canvas-53"></canvas></div>
3782
+ <div class="canvas"><canvas width="516" height="100" id="canvas-54"></canvas></div>
3605
3783
  </div>
3606
3784
 
3607
3785
 
@@ -3643,7 +3821,7 @@ path2.style = myStyle;
3643
3821
  <div class="button run">Run</div>
3644
3822
  </div>
3645
3823
 
3646
- <script type="text/paperscript" canvas="canvas-54">
3824
+ <script type="text/paperscript" canvas="canvas-55">
3647
3825
  var unlockedItem = new Path.Circle({
3648
3826
  center: view.center - [35, 0],
3649
3827
  radius: 30,
@@ -3670,7 +3848,7 @@ new PointText({
3670
3848
  justification: 'center'
3671
3849
  });
3672
3850
  </script>
3673
- <div class="canvas"><canvas width="516" height="100" id="canvas-54"></canvas></div>
3851
+ <div class="canvas"><canvas width="516" height="100" id="canvas-55"></canvas></div>
3674
3852
  </div>
3675
3853
 
3676
3854
 
@@ -3712,7 +3890,7 @@ new PointText({
3712
3890
  <div class="button run">Run</div>
3713
3891
  </div>
3714
3892
 
3715
- <script type="text/paperscript" canvas="canvas-55">
3893
+ <script type="text/paperscript" canvas="canvas-56">
3716
3894
  var path = new Path.Circle({
3717
3895
  center: [50, 50],
3718
3896
  radius: 20,
@@ -3722,7 +3900,7 @@ var path = new Path.Circle({
3722
3900
  // Hide the path:
3723
3901
  path.visible = false;
3724
3902
  </script>
3725
- <div class="canvas"><canvas width="516" height="100" id="canvas-55"></canvas></div>
3903
+ <div class="canvas"><canvas width="516" height="100" id="canvas-56"></canvas></div>
3726
3904
  </div>
3727
3905
 
3728
3906
 
@@ -3770,7 +3948,7 @@ path.visible = false;
3770
3948
  <div class="button run">Run</div>
3771
3949
  </div>
3772
3950
 
3773
- <script type="text/paperscript" canvas="canvas-56">
3951
+ <script type="text/paperscript" canvas="canvas-57">
3774
3952
  // Create a white rectangle in the background
3775
3953
  // with the same dimensions as the view:
3776
3954
  var background = new Path.Rectangle(view.bounds);
@@ -3791,7 +3969,7 @@ var circle2 = new Path.Circle({
3791
3969
  // Set the blend mode of circle2:
3792
3970
  circle2.blendMode = 'multiply';
3793
3971
  </script>
3794
- <div class="canvas"><canvas width="516" height="100" id="canvas-56"></canvas></div>
3972
+ <div class="canvas"><canvas width="516" height="100" id="canvas-57"></canvas></div>
3795
3973
  </div>
3796
3974
 
3797
3975
 
@@ -3833,7 +4011,7 @@ circle2.blendMode = 'multiply';
3833
4011
  <div class="button run">Run</div>
3834
4012
  </div>
3835
4013
 
3836
- <script type="text/paperscript" canvas="canvas-57">
4014
+ <script type="text/paperscript" canvas="canvas-58">
3837
4015
  var circle = new Path.Circle({
3838
4016
  center: [80, 50],
3839
4017
  radius: 35,
@@ -3851,7 +4029,7 @@ var circle2 = new Path.Circle({
3851
4029
  // Make circle2 50% transparent:
3852
4030
  circle2.opacity = 0.5;
3853
4031
  </script>
3854
- <div class="canvas"><canvas width="516" height="100" id="canvas-57"></canvas></div>
4032
+ <div class="canvas"><canvas width="516" height="100" id="canvas-58"></canvas></div>
3855
4033
  </div>
3856
4034
 
3857
4035
 
@@ -3974,14 +4152,14 @@ circle.textWrap = { offset: 10 };</code></pre>
3974
4152
  <div class="button run">Run</div>
3975
4153
  </div>
3976
4154
 
3977
- <script type="text/paperscript" canvas="canvas-58">
4155
+ <script type="text/paperscript" canvas="canvas-59">
3978
4156
  var path = new Path.Circle({
3979
4157
  center: [80, 50],
3980
4158
  radius: 35
3981
4159
  });
3982
4160
  path.selected = true; // Select the path
3983
4161
  </script>
3984
- <div class="canvas"><canvas width="516" height="100" id="canvas-58"></canvas></div>
4162
+ <div class="canvas"><canvas width="516" height="100" id="canvas-59"></canvas></div>
3985
4163
  </div>
3986
4164
 
3987
4165
 
@@ -4112,7 +4290,7 @@ console.log(path.data.pets.length); // 1</code></pre>
4112
4290
  <div class="button run">Run</div>
4113
4291
  </div>
4114
4292
 
4115
- <script type="text/paperscript" canvas="canvas-59">
4293
+ <script type="text/paperscript" canvas="canvas-60">
4116
4294
  // Create a circle at position { x: 10, y: 10 }
4117
4295
  var circle = new Path.Circle({
4118
4296
  center: new Point(10, 10),
@@ -4126,7 +4304,7 @@ circle.position = new Point(20, 20);
4126
4304
  // Move the circle 100 points to the right and 50 points down
4127
4305
  circle.position += new Point(100, 50);
4128
4306
  </script>
4129
- <div class="canvas"><canvas width="516" height="100" id="canvas-59"></canvas></div>
4307
+ <div class="canvas"><canvas width="516" height="100" id="canvas-60"></canvas></div>
4130
4308
  </div>
4131
4309
 
4132
4310
 
@@ -4138,7 +4316,7 @@ circle.position += new Point(100, 50);
4138
4316
  <div class="button run">Run</div>
4139
4317
  </div>
4140
4318
 
4141
- <script type="text/paperscript" canvas="canvas-60">
4319
+ <script type="text/paperscript" canvas="canvas-61">
4142
4320
  // Create a circle at position { x: 20, y: 20 }
4143
4321
  var circle = new Path.Circle({
4144
4322
  center: new Point(20, 20),
@@ -4149,7 +4327,7 @@ var circle = new Path.Circle({
4149
4327
  // Move the circle 100 points to the right
4150
4328
  circle.position.x += 100;
4151
4329
  </script>
4152
- <div class="canvas"><canvas width="516" height="100" id="canvas-60"></canvas></div>
4330
+ <div class="canvas"><canvas width="516" height="100" id="canvas-61"></canvas></div>
4153
4331
  </div>
4154
4332
 
4155
4333
 
@@ -4675,7 +4853,7 @@ console.log(group.children[0] == path); // true</code></pre>
4675
4853
  <div class="button run">Run</div>
4676
4854
  </div>
4677
4855
 
4678
- <script type="text/paperscript" canvas="canvas-61">
4856
+ <script type="text/paperscript" canvas="canvas-62">
4679
4857
  var path = new Path.Circle({
4680
4858
  center: [80, 50],
4681
4859
  radius: 35
@@ -4688,7 +4866,7 @@ group.addChild(path);
4688
4866
  // Access the path through the group's children array:
4689
4867
  group.children[0].fillColor = 'red';
4690
4868
  </script>
4691
- <div class="canvas"><canvas width="516" height="100" id="canvas-61"></canvas></div>
4869
+ <div class="canvas"><canvas width="516" height="100" id="canvas-62"></canvas></div>
4692
4870
  </div>
4693
4871
 
4694
4872
 
@@ -4700,7 +4878,7 @@ group.children[0].fillColor = 'red';
4700
4878
  <div class="button run">Run</div>
4701
4879
  </div>
4702
4880
 
4703
- <script type="text/paperscript" canvas="canvas-62">
4881
+ <script type="text/paperscript" canvas="canvas-63">
4704
4882
  var path = new Path.Circle({
4705
4883
  center: [80, 50],
4706
4884
  radius: 35
@@ -4715,7 +4893,7 @@ group.addChild(path);
4715
4893
  // The path can be accessed by name:
4716
4894
  group.children['example'].fillColor = 'orange';
4717
4895
  </script>
4718
- <div class="canvas"><canvas width="516" height="100" id="canvas-62"></canvas></div>
4896
+ <div class="canvas"><canvas width="516" height="100" id="canvas-63"></canvas></div>
4719
4897
  </div>
4720
4898
 
4721
4899
 
@@ -4727,7 +4905,7 @@ group.children['example'].fillColor = 'orange';
4727
4905
  <div class="button run">Run</div>
4728
4906
  </div>
4729
4907
 
4730
- <script type="text/paperscript" canvas="canvas-63">
4908
+ <script type="text/paperscript" canvas="canvas-64">
4731
4909
  var path = new Path.Circle({
4732
4910
  center: [80, 50],
4733
4911
  radius: 35
@@ -4739,7 +4917,7 @@ group.children = [path];
4739
4917
  // The path is the first child of the group:
4740
4918
  group.firstChild.fillColor = 'green';
4741
4919
  </script>
4742
- <div class="canvas"><canvas width="516" height="100" id="canvas-63"></canvas></div>
4920
+ <div class="canvas"><canvas width="516" height="100" id="canvas-64"></canvas></div>
4743
4921
  </div>
4744
4922
 
4745
4923
 
@@ -4916,7 +5094,7 @@ group.firstChild.fillColor = 'green';
4916
5094
  <div class="button run">Run</div>
4917
5095
  </div>
4918
5096
 
4919
- <script type="text/paperscript" canvas="canvas-64">
5097
+ <script type="text/paperscript" canvas="canvas-65">
4920
5098
  // Create a circle shaped path at { x: 80, y: 50 }
4921
5099
  // with a radius of 35:
4922
5100
  var circle = new Path.Circle({
@@ -4927,7 +5105,7 @@ var circle = new Path.Circle({
4927
5105
  // Set its stroke color to RGB red:
4928
5106
  circle.strokeColor = new Color(1, 0, 0);
4929
5107
  </script>
4930
- <div class="canvas"><canvas width="516" height="100" id="canvas-64"></canvas></div>
5108
+ <div class="canvas"><canvas width="516" height="100" id="canvas-65"></canvas></div>
4931
5109
  </div>
4932
5110
 
4933
5111
 
@@ -4964,7 +5142,7 @@ circle.strokeColor = new Color(1, 0, 0);
4964
5142
  <div class="button run">Run</div>
4965
5143
  </div>
4966
5144
 
4967
- <script type="text/paperscript" canvas="canvas-65">
5145
+ <script type="text/paperscript" canvas="canvas-66">
4968
5146
  // Create a circle shaped path at { x: 80, y: 50 }
4969
5147
  // with a radius of 35:
4970
5148
  var circle = new Path.Circle({
@@ -4976,7 +5154,7 @@ var circle = new Path.Circle({
4976
5154
  // Set its stroke width to 10:
4977
5155
  circle.strokeWidth = 10;
4978
5156
  </script>
4979
- <div class="canvas"><canvas width="516" height="100" id="canvas-65"></canvas></div>
5157
+ <div class="canvas"><canvas width="516" height="100" id="canvas-66"></canvas></div>
4980
5158
  </div>
4981
5159
 
4982
5160
 
@@ -5023,7 +5201,7 @@ circle.strokeWidth = 10;
5023
5201
  <div class="button run">Run</div>
5024
5202
  </div>
5025
5203
 
5026
- <script type="text/paperscript" canvas="canvas-66">
5204
+ <script type="text/paperscript" canvas="canvas-67">
5027
5205
  var line = new Path({
5028
5206
  segments: [[80, 50], [420, 50]],
5029
5207
  strokeColor: 'black',
@@ -5044,7 +5222,7 @@ var line2 = line.clone();
5044
5222
  line2.position.y += 100;
5045
5223
  line2.strokeCap = 'butt';
5046
5224
  </script>
5047
- <div class="canvas"><canvas width="516" height="200" id="canvas-66"></canvas></div>
5225
+ <div class="canvas"><canvas width="516" height="200" id="canvas-67"></canvas></div>
5048
5226
  </div>
5049
5227
 
5050
5228
 
@@ -5091,7 +5269,7 @@ line2.strokeCap = 'butt';
5091
5269
  <div class="button run">Run</div>
5092
5270
  </div>
5093
5271
 
5094
- <script type="text/paperscript" canvas="canvas-67">
5272
+ <script type="text/paperscript" canvas="canvas-68">
5095
5273
  var path = new Path({
5096
5274
  segments: [[80, 100], [120, 40], [160, 100]],
5097
5275
  strokeColor: 'black',
@@ -5108,7 +5286,7 @@ var path3 = path2.clone();
5108
5286
  path3.position.x += path3.bounds.width * 1.5;
5109
5287
  path3.strokeJoin = 'bevel';
5110
5288
  </script>
5111
- <div class="canvas"><canvas width="516" height="120" id="canvas-67"></canvas></div>
5289
+ <div class="canvas"><canvas width="516" height="120" id="canvas-68"></canvas></div>
5112
5290
  </div>
5113
5291
 
5114
5292
 
@@ -5212,7 +5390,7 @@ path3.strokeJoin = 'bevel';
5212
5390
  <div class="button run">Run</div>
5213
5391
  </div>
5214
5392
 
5215
- <script type="text/paperscript" canvas="canvas-68">
5393
+ <script type="text/paperscript" canvas="canvas-69">
5216
5394
  var path = new Path.Circle({
5217
5395
  center: [80, 50],
5218
5396
  radius: 40,
@@ -5223,7 +5401,7 @@ var path = new Path.Circle({
5223
5401
  // Set the dashed stroke to [10pt dash, 4pt gap]:
5224
5402
  path.dashArray = [10, 4];
5225
5403
  </script>
5226
- <div class="canvas"><canvas width="516" height="100" id="canvas-68"></canvas></div>
5404
+ <div class="canvas"><canvas width="516" height="100" id="canvas-69"></canvas></div>
5227
5405
  </div>
5228
5406
 
5229
5407
 
@@ -5329,7 +5507,7 @@ path.dashArray = [10, 4];
5329
5507
  <div class="button run">Run</div>
5330
5508
  </div>
5331
5509
 
5332
- <script type="text/paperscript" canvas="canvas-69">
5510
+ <script type="text/paperscript" canvas="canvas-70">
5333
5511
  // Create a circle shaped path at { x: 80, y: 50 }
5334
5512
  // with a radius of 35:
5335
5513
  var circle = new Path.Circle({
@@ -5340,7 +5518,7 @@ var circle = new Path.Circle({
5340
5518
  // Set the fill color of the circle to RGB red:
5341
5519
  circle.fillColor = new Color(1, 0, 0);
5342
5520
  </script>
5343
- <div class="canvas"><canvas width="516" height="100" id="canvas-69"></canvas></div>
5521
+ <div class="canvas"><canvas width="516" height="100" id="canvas-70"></canvas></div>
5344
5522
  </div>
5345
5523
 
5346
5524
 
@@ -5415,7 +5593,7 @@ circle.fillColor = new Color(1, 0, 0);
5415
5593
  <div class="button run">Run</div>
5416
5594
  </div>
5417
5595
 
5418
- <script type="text/paperscript" canvas="canvas-70">
5596
+ <script type="text/paperscript" canvas="canvas-71">
5419
5597
  var circle = new Path.Circle({
5420
5598
  center: [80, 50],
5421
5599
  radius: 35,
@@ -5428,7 +5606,7 @@ var circle = new Path.Circle({
5428
5606
  shadowOffset: new Point(5, 5)
5429
5607
  });
5430
5608
  </script>
5431
- <div class="canvas"><canvas width="516" height="100" id="canvas-70"></canvas></div>
5609
+ <div class="canvas"><canvas width="516" height="100" id="canvas-71"></canvas></div>
5432
5610
  </div>
5433
5611
 
5434
5612
 
@@ -5569,7 +5747,7 @@ var circle = new Path.Circle({
5569
5747
  <div class="button run">Run</div>
5570
5748
  </div>
5571
5749
 
5572
- <script type="text/paperscript" canvas="canvas-71">
5750
+ <script type="text/paperscript" canvas="canvas-72">
5573
5751
  // Create a rectangle shaped path with its top left point at:
5574
5752
  // {x: 50, y: 25} and a size of {width: 50, height: 50}
5575
5753
  var path = new Path.Rectangle(new Point(50, 25), new Size(50, 50));
@@ -5580,7 +5758,7 @@ path.onFrame = function(event) {
5580
5758
  this.rotate(3);
5581
5759
  }
5582
5760
  </script>
5583
- <div class="canvas"><canvas width="516" height="100" id="canvas-71"></canvas></div>
5761
+ <div class="canvas"><canvas width="516" height="100" id="canvas-72"></canvas></div>
5584
5762
  </div>
5585
5763
 
5586
5764
 
@@ -5624,7 +5802,7 @@ path.onFrame = function(event) {
5624
5802
  <div class="button run">Run</div>
5625
5803
  </div>
5626
5804
 
5627
- <script type="text/paperscript" canvas="canvas-72">
5805
+ <script type="text/paperscript" canvas="canvas-73">
5628
5806
  // Create a circle shaped path at the center of the view:
5629
5807
  var path = new Path.Circle({
5630
5808
  center: view.center,
@@ -5638,7 +5816,7 @@ path.onMouseDown = function(event) {
5638
5816
  this.fillColor = 'red';
5639
5817
  }
5640
5818
  </script>
5641
- <div class="canvas"><canvas width="516" height="100" id="canvas-72"></canvas></div>
5819
+ <div class="canvas"><canvas width="516" height="100" id="canvas-73"></canvas></div>
5642
5820
  </div>
5643
5821
 
5644
5822
 
@@ -5650,7 +5828,7 @@ path.onMouseDown = function(event) {
5650
5828
  <div class="button run">Run</div>
5651
5829
  </div>
5652
5830
 
5653
- <script type="text/paperscript" canvas="canvas-73">
5831
+ <script type="text/paperscript" canvas="canvas-74">
5654
5832
  // Loop 30 times:
5655
5833
  for (var i = 0; i < 30; i++) {
5656
5834
  // Create a circle shaped path at a random position
@@ -5668,7 +5846,7 @@ for (var i = 0; i < 30; i++) {
5668
5846
  }
5669
5847
  }
5670
5848
  </script>
5671
- <div class="canvas"><canvas width="516" height="100" id="canvas-73"></canvas></div>
5849
+ <div class="canvas"><canvas width="516" height="100" id="canvas-74"></canvas></div>
5672
5850
  </div>
5673
5851
 
5674
5852
 
@@ -5712,7 +5890,7 @@ for (var i = 0; i < 30; i++) {
5712
5890
  <div class="button run">Run</div>
5713
5891
  </div>
5714
5892
 
5715
- <script type="text/paperscript" canvas="canvas-74">
5893
+ <script type="text/paperscript" canvas="canvas-75">
5716
5894
  // Create a circle shaped path at the center of the view:
5717
5895
  var path = new Path.Circle({
5718
5896
  center: view.center,
@@ -5725,7 +5903,7 @@ path.onMouseDrag = function(event) {
5725
5903
  path.position += event.delta;
5726
5904
  }
5727
5905
  </script>
5728
- <div class="canvas"><canvas width="516" height="240" id="canvas-74"></canvas></div>
5906
+ <div class="canvas"><canvas width="516" height="240" id="canvas-75"></canvas></div>
5729
5907
  </div>
5730
5908
 
5731
5909
 
@@ -5769,7 +5947,7 @@ path.onMouseDrag = function(event) {
5769
5947
  <div class="button run">Run</div>
5770
5948
  </div>
5771
5949
 
5772
- <script type="text/paperscript" canvas="canvas-75">
5950
+ <script type="text/paperscript" canvas="canvas-76">
5773
5951
  // Create a circle shaped path at the center of the view:
5774
5952
  var path = new Path.Circle({
5775
5953
  center: view.center,
@@ -5783,7 +5961,7 @@ path.onMouseUp = function(event) {
5783
5961
  this.fillColor = 'red';
5784
5962
  }
5785
5963
  </script>
5786
- <div class="canvas"><canvas width="516" height="100" id="canvas-75"></canvas></div>
5964
+ <div class="canvas"><canvas width="516" height="100" id="canvas-76"></canvas></div>
5787
5965
  </div>
5788
5966
 
5789
5967
 
@@ -5827,7 +6005,7 @@ path.onMouseUp = function(event) {
5827
6005
  <div class="button run">Run</div>
5828
6006
  </div>
5829
6007
 
5830
- <script type="text/paperscript" canvas="canvas-76">
6008
+ <script type="text/paperscript" canvas="canvas-77">
5831
6009
  // Create a circle shaped path at the center of the view:
5832
6010
  var path = new Path.Circle({
5833
6011
  center: view.center,
@@ -5841,7 +6019,7 @@ path.onClick = function(event) {
5841
6019
  this.fillColor = 'red';
5842
6020
  }
5843
6021
  </script>
5844
- <div class="canvas"><canvas width="516" height="100" id="canvas-76"></canvas></div>
6022
+ <div class="canvas"><canvas width="516" height="100" id="canvas-77"></canvas></div>
5845
6023
  </div>
5846
6024
 
5847
6025
 
@@ -5853,7 +6031,7 @@ path.onClick = function(event) {
5853
6031
  <div class="button run">Run</div>
5854
6032
  </div>
5855
6033
 
5856
- <script type="text/paperscript" canvas="canvas-77">
6034
+ <script type="text/paperscript" canvas="canvas-78">
5857
6035
  // Loop 30 times:
5858
6036
  for (var i = 0; i < 30; i++) {
5859
6037
  // Create a circle shaped path at a random position
@@ -5871,7 +6049,7 @@ for (var i = 0; i < 30; i++) {
5871
6049
  }
5872
6050
  }
5873
6051
  </script>
5874
- <div class="canvas"><canvas width="516" height="100" id="canvas-77"></canvas></div>
6052
+ <div class="canvas"><canvas width="516" height="100" id="canvas-78"></canvas></div>
5875
6053
  </div>
5876
6054
 
5877
6055
 
@@ -5915,7 +6093,7 @@ for (var i = 0; i < 30; i++) {
5915
6093
  <div class="button run">Run</div>
5916
6094
  </div>
5917
6095
 
5918
- <script type="text/paperscript" canvas="canvas-78">
6096
+ <script type="text/paperscript" canvas="canvas-79">
5919
6097
  // Create a circle shaped path at the center of the view:
5920
6098
  var path = new Path.Circle({
5921
6099
  center: view.center,
@@ -5929,7 +6107,7 @@ path.onDoubleClick = function(event) {
5929
6107
  this.fillColor = 'red';
5930
6108
  }
5931
6109
  </script>
5932
- <div class="canvas"><canvas width="516" height="100" id="canvas-78"></canvas></div>
6110
+ <div class="canvas"><canvas width="516" height="100" id="canvas-79"></canvas></div>
5933
6111
  </div>
5934
6112
 
5935
6113
 
@@ -5941,7 +6119,7 @@ path.onDoubleClick = function(event) {
5941
6119
  <div class="button run">Run</div>
5942
6120
  </div>
5943
6121
 
5944
- <script type="text/paperscript" canvas="canvas-79">
6122
+ <script type="text/paperscript" canvas="canvas-80">
5945
6123
  // Loop 30 times:
5946
6124
  for (var i = 0; i < 30; i++) {
5947
6125
  // Create a circle shaped path at a random position
@@ -5959,7 +6137,7 @@ for (var i = 0; i < 30; i++) {
5959
6137
  }
5960
6138
  }
5961
6139
  </script>
5962
- <div class="canvas"><canvas width="516" height="100" id="canvas-79"></canvas></div>
6140
+ <div class="canvas"><canvas width="516" height="100" id="canvas-80"></canvas></div>
5963
6141
  </div>
5964
6142
 
5965
6143
 
@@ -6003,7 +6181,7 @@ for (var i = 0; i < 30; i++) {
6003
6181
  <div class="button run">Run</div>
6004
6182
  </div>
6005
6183
 
6006
- <script type="text/paperscript" canvas="canvas-80">
6184
+ <script type="text/paperscript" canvas="canvas-81">
6007
6185
  // Create a circle shaped path at the center of the view:
6008
6186
  var path = new Path.Circle({
6009
6187
  center: view.center,
@@ -6017,7 +6195,7 @@ path.onMouseMove = function(event) {
6017
6195
  this.opacity = Math.random();
6018
6196
  }
6019
6197
  </script>
6020
- <div class="canvas"><canvas width="516" height="100" id="canvas-80"></canvas></div>
6198
+ <div class="canvas"><canvas width="516" height="100" id="canvas-81"></canvas></div>
6021
6199
  </div>
6022
6200
 
6023
6201
 
@@ -6061,7 +6239,7 @@ path.onMouseMove = function(event) {
6061
6239
  <div class="button run">Run</div>
6062
6240
  </div>
6063
6241
 
6064
- <script type="text/paperscript" canvas="canvas-81">
6242
+ <script type="text/paperscript" canvas="canvas-82">
6065
6243
  // Create a circle shaped path at the center of the view:
6066
6244
  var path = new Path.Circle({
6067
6245
  center: view.center,
@@ -6079,7 +6257,7 @@ path.onMouseLeave = function(event) {
6079
6257
  this.fillColor = 'black';
6080
6258
  }
6081
6259
  </script>
6082
- <div class="canvas"><canvas width="516" height="100" id="canvas-81"></canvas></div>
6260
+ <div class="canvas"><canvas width="516" height="100" id="canvas-82"></canvas></div>
6083
6261
  </div>
6084
6262
 
6085
6263
 
@@ -6091,7 +6269,7 @@ path.onMouseLeave = function(event) {
6091
6269
  <div class="button run">Run</div>
6092
6270
  </div>
6093
6271
 
6094
- <script type="text/paperscript" canvas="canvas-82">
6272
+ <script type="text/paperscript" canvas="canvas-83">
6095
6273
  function enter(event) {
6096
6274
  this.fillColor = 'red';
6097
6275
  }
@@ -6113,7 +6291,7 @@ function onMouseDown(event) {
6113
6291
  path.onMouseLeave = leave;
6114
6292
  }
6115
6293
  </script>
6116
- <div class="canvas"><canvas width="516" height="100" id="canvas-82"></canvas></div>
6294
+ <div class="canvas"><canvas width="516" height="100" id="canvas-83"></canvas></div>
6117
6295
  </div>
6118
6296
 
6119
6297
 
@@ -6157,7 +6335,7 @@ function onMouseDown(event) {
6157
6335
  <div class="button run">Run</div>
6158
6336
  </div>
6159
6337
 
6160
- <script type="text/paperscript" canvas="canvas-83">
6338
+ <script type="text/paperscript" canvas="canvas-84">
6161
6339
  // Create a circle shaped path at the center of the view:
6162
6340
  var path = new Path.Circle({
6163
6341
  center: view.center,
@@ -6170,7 +6348,139 @@ path.onMouseLeave = function(event) {
6170
6348
  this.fillColor = 'red';
6171
6349
  }
6172
6350
  </script>
6173
- <div class="canvas"><canvas width="516" height="100" id="canvas-83"></canvas></div>
6351
+ <div class="canvas"><canvas width="516" height="100" id="canvas-84"></canvas></div>
6352
+ </div>
6353
+
6354
+
6355
+ </div>
6356
+
6357
+ </div>
6358
+ </div>
6359
+
6360
+
6361
+ <div id="ondraw" class="member">
6362
+ <div class="member-link">
6363
+ <a name="ondraw" href="#ondraw"><tt><b>onDraw</b></tt></a>
6364
+ </div>
6365
+ <div class="member-description hidden">
6366
+
6367
+ <div class="member-text">
6368
+ <p>The function to be called whenever the item is drawn: in views, in <a href="../classes/Item.html#rasterize"><tt>rasterize</tt></a>(), and once for each placement of a symbol whose definition contains it. It is called right before the item&rsquo;s default drawing, and draws with the canvas API beneath it, or replaces it by returning <code>false</code> or calling <code>event.preventDefault()</code>. The function receives a <a href="../classes/DrawEvent.html"><tt>DrawEvent</tt></a> object with these fields:</p>
6369
+
6370
+
6371
+
6372
+ <ul class="member-list">
6373
+ <h4>Type:</h4>
6374
+ <li>
6375
+ <tt>Function</tt>⟋<tt>null</tt>
6376
+ </li>
6377
+ </ul>
6378
+ <ul class="member-list">
6379
+ <h4>Options:</h4>
6380
+ <li><tt>event.item: <a href="../classes/Item.html"><tt>Item</tt></a></tt> &mdash; the item that is drawn</li>
6381
+ <li><tt>event.context: <tt>CanvasRenderingContext2D</tt></tt> &mdash; the canvas context, transformed into the item&rsquo;s coordinates</li>
6382
+ <li><tt>event.matrix: <a href="../classes/Matrix.html"><tt>Matrix</tt></a></tt> &mdash; the matrix from the item&rsquo;s coordinates to the pixels of the view, without its pixel ratio, for drawing things at a size in pixels</li>
6383
+ <li><tt>event.pixelRatio: <tt>Number</tt></tt> &mdash; the device pixels per pixel: the view&rsquo;s pixel ratio, or the resolution divided by 72 in <a href="../classes/Item.html#rasterize"><tt>rasterize</tt></a>()</li>
6384
+ <li><tt>event.view: <a href="../classes/View.html"><tt>View</tt></a></tt> &mdash; the view drawn into, or <code>null</code> in <a href="../classes/Item.html#rasterize"><tt>rasterize</tt></a>()
6385
+ What the handler draws isn&rsquo;t part of the item&rsquo;s hit testing, its bounds or its SVG export. In buffered groups, it is only called when the group draws its buffer again, see <a href="../classes/Group.html#buffered"><tt>group.buffered</tt></a>.</li>
6386
+ </ul>
6387
+
6388
+ <h4>Example:<span class="description">Draw a hairline cross through the center of a circle, beneath it:</span></h4>
6389
+
6390
+ <div class="paperscript split">
6391
+
6392
+ <div class="buttons">
6393
+ <div class="button run">Run</div>
6394
+ </div>
6395
+
6396
+ <script type="text/paperscript" canvas="canvas-85">
6397
+ var path = new Path.Circle({
6398
+ center: view.center,
6399
+ radius: 25,
6400
+ fillColor: 'rgba(255, 0, 0, 0.5)'
6401
+ });
6402
+
6403
+ path.onDraw = function(event) {
6404
+ var ctx = event.context,
6405
+ center = this.position,
6406
+ scale = event.matrix.scaling.x;
6407
+ ctx.beginPath();
6408
+ ctx.moveTo(center.x - 40, center.y);
6409
+ ctx.lineTo(center.x + 40, center.y);
6410
+ ctx.moveTo(center.x, center.y - 40);
6411
+ ctx.lineTo(center.x, center.y + 40);
6412
+ ctx.lineWidth = 1 / scale;
6413
+ ctx.stroke();
6414
+ }
6415
+ </script>
6416
+ <div class="canvas"><canvas width="516" height="100" id="canvas-85"></canvas></div>
6417
+ </div>
6418
+
6419
+
6420
+ </div>
6421
+
6422
+ </div>
6423
+ </div>
6424
+
6425
+
6426
+ <div id="ondrawselection" class="member">
6427
+ <div class="member-link">
6428
+ <a name="ondrawselection" href="#ondrawselection"><tt><b>onDrawSelection</b></tt></a>
6429
+ </div>
6430
+ <div class="member-description hidden">
6431
+
6432
+ <div class="member-text">
6433
+ <p>The function to be called when the selection of the selected item is drawn, over all the content. It is called right before the item&rsquo;s default selection drawing, and draws with the canvas API beneath it, or replaces it by returning <code>false</code> or calling <code>event.preventDefault()</code>. The function receives a <a href="../classes/DrawEvent.html"><tt>DrawEvent</tt></a> object with these fields:</p>
6434
+
6435
+
6436
+
6437
+ <ul class="member-list">
6438
+ <h4>Type:</h4>
6439
+ <li>
6440
+ <tt>Function</tt>⟋<tt>null</tt>
6441
+ </li>
6442
+ </ul>
6443
+ <ul class="member-list">
6444
+ <h4>Options:</h4>
6445
+ <li><tt>event.item: <a href="../classes/Item.html"><tt>Item</tt></a></tt> &mdash; the selected item</li>
6446
+ <li><tt>event.context: <tt>CanvasRenderingContext2D</tt></tt> &mdash; the canvas context, in the pixels of the view, with the selection color as its <code>strokeStyle</code> and <code>fillStyle</code>, and a <code>lineWidth</code> of 1</li>
6447
+ <li><tt>event.matrix: <a href="../classes/Matrix.html"><tt>Matrix</tt></a></tt> &mdash; the matrix from the item&rsquo;s coordinates to the pixels of the view</li>
6448
+ <li><tt>event.size: <tt>Number</tt></tt> &mdash; the size of the handles, see <a href="../classes/PaperScope.html#settings"><tt>paperScope.settings</tt></a></li>
6449
+ <li><tt>event.color: <a href="../classes/Color.html"><tt>Color</tt></a></tt> &mdash; the selection color, see <a href="../classes/Item.html#selectedcolor"><tt>selectedColor</tt></a></li>
6450
+ <li><tt>event.view: <a href="../classes/View.html"><tt>View</tt></a></tt> &mdash; the view drawn into
6451
+ What the handler draws isn&rsquo;t part of the item&rsquo;s hit testing, its bounds or its SVG export.</li>
6452
+ </ul>
6453
+
6454
+ <h4>Example:<span class="description">Draw the selection of a path as a dot at each segment:</span></h4>
6455
+
6456
+ <div class="paperscript split">
6457
+
6458
+ <div class="buttons">
6459
+ <div class="button run">Run</div>
6460
+ </div>
6461
+
6462
+ <script type="text/paperscript" canvas="canvas-86">
6463
+ var path = new Path.Star({
6464
+ center: view.center,
6465
+ points: 5,
6466
+ radius1: 20,
6467
+ radius2: 40,
6468
+ strokeColor: 'black',
6469
+ selected: true
6470
+ });
6471
+
6472
+ path.onDrawSelection = function(event) {
6473
+ var ctx = event.context;
6474
+ this.segments.forEach(function(segment) {
6475
+ var point = event.matrix.transform(segment.point);
6476
+ ctx.beginPath();
6477
+ ctx.arc(point.x, point.y, event.size, 0, Math.PI * 2);
6478
+ ctx.fill();
6479
+ });
6480
+ return false;
6481
+ }
6482
+ </script>
6483
+ <div class="canvas"><canvas width="516" height="100" id="canvas-86"></canvas></div>
6174
6484
  </div>
6175
6485
 
6176
6486
 
@@ -6186,6 +6496,261 @@ path.onMouseLeave = function(event) {
6186
6496
  <div class="reference-members"><h2>Methods inherited from <a href="../classes/Item.html"><tt>Item</tt></a></h2>
6187
6497
 
6188
6498
 
6499
+ <div id="addeffect-effect" class="member">
6500
+ <div class="member-link">
6501
+ <a name="addeffect-effect" href="#addeffect-effect"><tt><b>addEffect</b>(effect)</tt></a>
6502
+ </div>
6503
+ <div class="member-description hidden">
6504
+ <div class="member-text">
6505
+ <p>Adds an effect at the end of the item&rsquo;s effects.</p>
6506
+
6507
+
6508
+ <ul class="member-list">
6509
+ <h4>Parameters:</h4>
6510
+
6511
+ <li>
6512
+ <tt>effect:</tt>
6513
+ <tt>Object</tt>
6514
+ &mdash;&nbsp;the plain object describing the effect
6515
+
6516
+ </li>
6517
+
6518
+ </ul>
6519
+
6520
+
6521
+ <ul class="member-list">
6522
+ <h4>Returns:</h4>
6523
+
6524
+ <li>
6525
+ <tt><a href="../classes/EffectInstance.html"><tt>EffectInstance</tt></a></tt>&nbsp;&mdash;&nbsp;the added instance
6526
+ </li>
6527
+
6528
+
6529
+ </ul>
6530
+
6531
+
6532
+
6533
+
6534
+
6535
+ </div>
6536
+ </div>
6537
+ </div>
6538
+
6539
+
6540
+ <div id="inserteffect-index-effect" class="member">
6541
+ <div class="member-link">
6542
+ <a name="inserteffect-index-effect" href="#inserteffect-index-effect"><tt><b>insertEffect</b>(index, effect)</tt></a>
6543
+ </div>
6544
+ <div class="member-description hidden">
6545
+ <div class="member-text">
6546
+ <p>Inserts an effect into the item&rsquo;s effects at the given index.</p>
6547
+
6548
+
6549
+ <ul class="member-list">
6550
+ <h4>Parameters:</h4>
6551
+
6552
+ <li>
6553
+ <tt>index:</tt>
6554
+ <tt>Number</tt>
6555
+ &mdash;&nbsp;the index at which to insert the effect
6556
+
6557
+ </li>
6558
+
6559
+ <li>
6560
+ <tt>effect:</tt>
6561
+ <tt>Object</tt>
6562
+ &mdash;&nbsp;the plain object describing the effect
6563
+
6564
+ </li>
6565
+
6566
+ </ul>
6567
+
6568
+
6569
+ <ul class="member-list">
6570
+ <h4>Returns:</h4>
6571
+
6572
+ <li>
6573
+ <tt><a href="../classes/EffectInstance.html"><tt>EffectInstance</tt></a></tt>&nbsp;&mdash;&nbsp;the inserted instance
6574
+ </li>
6575
+
6576
+
6577
+ </ul>
6578
+
6579
+
6580
+
6581
+
6582
+
6583
+ </div>
6584
+ </div>
6585
+ </div>
6586
+
6587
+
6588
+ <div id="inserteffects-index-effects" class="member">
6589
+ <div class="member-link">
6590
+ <a name="inserteffects-index-effects" href="#inserteffects-index-effects"><tt><b>insertEffects</b>(index, effects)</tt></a>
6591
+ </div>
6592
+ <div class="member-description hidden">
6593
+ <div class="member-text">
6594
+ <p>Inserts effects into the item&rsquo;s effects at the given index.</p>
6595
+
6596
+
6597
+ <ul class="member-list">
6598
+ <h4>Parameters:</h4>
6599
+
6600
+ <li>
6601
+ <tt>index:</tt>
6602
+ <tt>Number</tt>
6603
+ &mdash;&nbsp;the index at which to insert the effects
6604
+
6605
+ </li>
6606
+
6607
+ <li>
6608
+ <tt>effects:</tt>
6609
+ Array of <tt>Object</tt> objects
6610
+ &mdash;&nbsp;the plain objects describing the effects
6611
+
6612
+ </li>
6613
+
6614
+ </ul>
6615
+
6616
+
6617
+ <ul class="member-list">
6618
+ <h4>Returns:</h4>
6619
+
6620
+ <li>
6621
+ <tt>Array of <a href="../classes/EffectInstance.html"><tt>EffectInstance</tt></a> objects</tt>&nbsp;&mdash;&nbsp;the inserted instances
6622
+ </li>
6623
+
6624
+
6625
+ </ul>
6626
+
6627
+
6628
+
6629
+
6630
+
6631
+ </div>
6632
+ </div>
6633
+ </div>
6634
+
6635
+
6636
+ <div id="removeeffect-index" class="member">
6637
+ <div class="member-link">
6638
+ <a name="removeeffect-index" href="#removeeffect-index"><tt><b>removeEffect</b>(index)</tt></a>
6639
+ </div>
6640
+ <div class="member-description hidden">
6641
+ <div class="member-text">
6642
+ <p>Removes the effect at the given index from the item&rsquo;s effects.</p>
6643
+
6644
+
6645
+ <ul class="member-list">
6646
+ <h4>Parameters:</h4>
6647
+
6648
+ <li>
6649
+ <tt>index:</tt>
6650
+ <tt>Number</tt>
6651
+ &mdash;&nbsp;the index of the effect to remove
6652
+
6653
+ </li>
6654
+
6655
+ </ul>
6656
+
6657
+
6658
+ <ul class="member-list">
6659
+ <h4>Returns:</h4>
6660
+
6661
+ <li>
6662
+ <tt><a href="../classes/EffectInstance.html"><tt>EffectInstance</tt></a></tt>&nbsp;&mdash;&nbsp;the removed instance, or <code>null</code>
6663
+ </li>
6664
+
6665
+
6666
+ </ul>
6667
+
6668
+
6669
+
6670
+
6671
+
6672
+ </div>
6673
+ </div>
6674
+ </div>
6675
+
6676
+
6677
+ <div id="removeeffects" class="member">
6678
+ <div class="member-link">
6679
+ <a name="removeeffects" href="#removeeffects"><tt><b>removeEffects</b>([start[, end]])</tt></a>
6680
+ </div>
6681
+ <div class="member-description hidden">
6682
+ <div class="member-text">
6683
+ <p>Removes the effects from the start index to the end index from the item&rsquo;s effects, or all of them.</p>
6684
+
6685
+
6686
+ <ul class="member-list">
6687
+ <h4>Parameters:</h4>
6688
+
6689
+ <li>
6690
+ <tt>start:</tt>
6691
+ <tt>Number</tt>
6692
+ &mdash;&nbsp;the index of the first effect to remove
6693
+ &mdash;&nbsp;optional, default: <tt>0</tt>
6694
+ </li>
6695
+
6696
+ <li>
6697
+ <tt>end:</tt>
6698
+ <tt>Number</tt>
6699
+ &mdash;&nbsp;the index after the last one
6700
+ &mdash;&nbsp;optional, default: <tt>effects.length</tt>
6701
+ </li>
6702
+
6703
+ </ul>
6704
+
6705
+
6706
+ <ul class="member-list">
6707
+ <h4>Returns:</h4>
6708
+
6709
+ <li>
6710
+ <tt>Array of <a href="../classes/EffectInstance.html"><tt>EffectInstance</tt></a> objects</tt>&nbsp;&mdash;&nbsp;the removed instances
6711
+ </li>
6712
+
6713
+
6714
+ </ul>
6715
+
6716
+
6717
+
6718
+
6719
+
6720
+ </div>
6721
+ </div>
6722
+ </div>
6723
+
6724
+
6725
+ <div id="geteffectoutput" class="member">
6726
+ <div class="member-link">
6727
+ <a name="geteffectoutput" href="#geteffectoutput"><tt><b>getEffectOutput</b>()</tt></a>
6728
+ </div>
6729
+ <div class="member-description hidden">
6730
+ <div class="member-text">
6731
+ <p>Returns what the item&rsquo;s visible effects make of it, in the item&rsquo;s own coordinates, outside of the scene graph, or <code>null</code> if it has none. It is kept until the item, its content, its effects or the registered effects change, so changing it isn&rsquo;t tracked.</p>
6732
+
6733
+
6734
+
6735
+ <ul class="member-list">
6736
+ <h4>Returns:</h4>
6737
+
6738
+ <li>
6739
+ <tt><a href="../classes/Item.html"><tt>Item</tt></a>⟋<tt>null</tt></tt>&nbsp;&mdash;&nbsp;the output of the effects
6740
+ </li>
6741
+
6742
+
6743
+ </ul>
6744
+
6745
+
6746
+
6747
+
6748
+
6749
+ </div>
6750
+ </div>
6751
+ </div>
6752
+
6753
+
6189
6754
  <div id="set-props" class="member">
6190
6755
  <div class="member-link">
6191
6756
  <a name="set-props" href="#set-props"><tt><b>set</b>(props)</tt></a>
@@ -6229,7 +6794,7 @@ path.onMouseLeave = function(event) {
6229
6794
  <div class="button run">Run</div>
6230
6795
  </div>
6231
6796
 
6232
- <script type="text/paperscript" canvas="canvas-84">
6797
+ <script type="text/paperscript" canvas="canvas-87">
6233
6798
  var circle = new Path.Circle({
6234
6799
  center: [80, 50],
6235
6800
  radius: 35
@@ -6242,7 +6807,7 @@ circle.set({
6242
6807
  selected: true
6243
6808
  });
6244
6809
  </script>
6245
- <div class="canvas"><canvas width="516" height="100" id="canvas-84"></canvas></div>
6810
+ <div class="canvas"><canvas width="516" height="100" id="canvas-87"></canvas></div>
6246
6811
  </div>
6247
6812
 
6248
6813
 
@@ -6298,7 +6863,7 @@ circle.set({
6298
6863
  <div class="button run">Run</div>
6299
6864
  </div>
6300
6865
 
6301
- <script type="text/paperscript" canvas="canvas-85">
6866
+ <script type="text/paperscript" canvas="canvas-88">
6302
6867
  var circle = new Path.Circle({
6303
6868
  center: [50, 50],
6304
6869
  radius: 10,
@@ -6313,7 +6878,7 @@ for (var i = 0; i < 20; i++) {
6313
6878
  copy.position.x += i * copy.bounds.width;
6314
6879
  }
6315
6880
  </script>
6316
- <div class="canvas"><canvas width="516" height="100" id="canvas-85"></canvas></div>
6881
+ <div class="canvas"><canvas width="516" height="100" id="canvas-88"></canvas></div>
6317
6882
  </div>
6318
6883
 
6319
6884
 
@@ -6439,7 +7004,7 @@ for (var i = 0; i < 20; i++) {
6439
7004
  <div class="button run">Run</div>
6440
7005
  </div>
6441
7006
 
6442
- <script type="text/paperscript" canvas="canvas-86">
7007
+ <script type="text/paperscript" canvas="canvas-89">
6443
7008
  var circle = new Path.Circle({
6444
7009
  center: [50, 50],
6445
7010
  radius: 5,
@@ -6456,7 +7021,7 @@ raster.position.x += 100;
6456
7021
  circle.scale(5);
6457
7022
  raster.scale(5);
6458
7023
  </script>
6459
- <div class="canvas"><canvas width="516" height="100" id="canvas-86"></canvas></div>
7024
+ <div class="canvas"><canvas width="516" height="100" id="canvas-89"></canvas></div>
6460
7025
  </div>
6461
7026
 
6462
7027
 
@@ -6510,7 +7075,7 @@ raster.scale(5);
6510
7075
  <div class="button run">Run</div>
6511
7076
  </div>
6512
7077
 
6513
- <script type="text/paperscript" canvas="canvas-87">
7078
+ <script type="text/paperscript" canvas="canvas-90">
6514
7079
  var path = new Path.Star({
6515
7080
  center: [50, 50],
6516
7081
  points: 12,
@@ -6531,7 +7096,7 @@ function onMouseDown(event) {
6531
7096
  }
6532
7097
  }
6533
7098
  </script>
6534
- <div class="canvas"><canvas width="516" height="100" id="canvas-87"></canvas></div>
7099
+ <div class="canvas"><canvas width="516" height="100" id="canvas-90"></canvas></div>
6535
7100
  </div>
6536
7101
 
6537
7102
 
@@ -7049,11 +7614,17 @@ function onMouseDown(event) {
7049
7614
  </div>
7050
7615
  <div class="member-description hidden">
7051
7616
  <div class="member-text">
7052
- <p>Exports the item with its content and child items as an SVG DOM.</p>
7617
+ <p>Exports the item with its content and child items as an SVG DOM. With <code>options.bounds</code> or <code>options.matrix</code>, the item is wrapped in an <code>&lt;svg&gt;</code> element sized to the bounds, as <a href="../classes/Project.html#exportsvg-options"><tt>project.exportSVG(options)</tt></a> does.</p>
7053
7618
  <ul class="member-list">
7054
7619
  <h4>Options:</h4>
7055
- <li><tt>options.bounds: <tt>String</tt>⟋<a href="../classes/Rectangle.html"><tt>Rectangle</tt></a></tt> &mdash; the bounds of the area to export, either as a string (<tt>&lsquo;view&rsquo;</tt>, <tt>content&rsquo;</tt>), or a <a href="../classes/Rectangle.html"><tt>Rectangle</tt></a> object: <code>&#39;view&#39;</code> uses the view bounds, <code>&#39;content&#39;</code> uses the stroke bounds of all content &mdash;&nbsp;default: <tt>&lsquo;view&rsquo;</tt></li>
7056
- <li><tt>options.matrix: <a href="../classes/Matrix.html"><tt>Matrix</tt></a></tt> &mdash; the matrix with which to transform the exported content: If <code>options.bounds</code> is set to <code>&#39;view&#39;</code>, <code>paper.view.matrix</code> is used, for all other settings of <code>options.bounds</code> the identity matrix is used. &mdash;&nbsp;default: <tt>paper.view.matrix</tt></li>
7620
+ <li>[options.bounds] {String|Rectangle} the bounds of the area to
7621
+ export, either as a string ({@values 'view', content'}), or a
7622
+ {@link Rectangle} object: `'view'` uses the view bounds,
7623
+ `'content'` uses the stroke bounds of the item</li>
7624
+ <li>[options.matrix] {Matrix} the matrix with which to transform the
7625
+ exported content: If `options.bounds` is set to `'view'`,
7626
+ `paper.view.matrix` is used, for all other settings of
7627
+ `options.bounds` the identity matrix is used.</li>
7057
7628
  <li><tt>options.asString: <tt>Boolean</tt></tt> &mdash; whether a SVG node or a <code>String</code> is to be returned &mdash;&nbsp;default: <tt>false</tt></li>
7058
7629
  <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>
7059
7630
  <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>
@@ -8366,7 +8937,7 @@ Array of <a href="../classes/Item.html"><tt>Item</tt></a> objects
8366
8937
  <div class="button run">Run</div>
8367
8938
  </div>
8368
8939
 
8369
- <script type="text/paperscript" canvas="canvas-88">
8940
+ <script type="text/paperscript" canvas="canvas-91">
8370
8941
  // Create a rectangle shaped path with its top left
8371
8942
  // point at {x: 80, y: 25} and a size of {width: 50, height: 50}:
8372
8943
  var path = new Path.Rectangle(new Point(80, 25), new Size(50, 50));
@@ -8375,7 +8946,7 @@ path.fillColor = 'black';
8375
8946
  // Rotate the path by 30 degrees:
8376
8947
  path.rotate(30);
8377
8948
  </script>
8378
- <div class="canvas"><canvas width="516" height="100" id="canvas-88"></canvas></div>
8949
+ <div class="canvas"><canvas width="516" height="100" id="canvas-91"></canvas></div>
8379
8950
  </div>
8380
8951
 
8381
8952
 
@@ -8387,7 +8958,7 @@ path.rotate(30);
8387
8958
  <div class="button run">Run</div>
8388
8959
  </div>
8389
8960
 
8390
- <script type="text/paperscript" canvas="canvas-89">
8961
+ <script type="text/paperscript" canvas="canvas-92">
8391
8962
  // Create a rectangle shaped path with its top left
8392
8963
  // point at {x: 175, y: 50} and a size of {width: 100, height: 100}:
8393
8964
  var topLeft = new Point(175, 50);
@@ -8409,7 +8980,7 @@ function onFrame(event) {
8409
8980
  path.rotate(3, view.center);
8410
8981
  }
8411
8982
  </script>
8412
- <div class="canvas"><canvas width="516" height="200" id="canvas-89"></canvas></div>
8983
+ <div class="canvas"><canvas width="516" height="200" id="canvas-92"></canvas></div>
8413
8984
  </div>
8414
8985
 
8415
8986
 
@@ -8458,7 +9029,7 @@ function onFrame(event) {
8458
9029
  <div class="button run">Run</div>
8459
9030
  </div>
8460
9031
 
8461
- <script type="text/paperscript" canvas="canvas-90">
9032
+ <script type="text/paperscript" canvas="canvas-93">
8462
9033
  // Create a circle shaped path at { x: 80, y: 50 }
8463
9034
  // with a radius of 20:
8464
9035
  var circle = new Path.Circle({
@@ -8470,7 +9041,7 @@ var circle = new Path.Circle({
8470
9041
  // Scale the path by 150% from its center point
8471
9042
  circle.scale(1.5);
8472
9043
  </script>
8473
- <div class="canvas"><canvas width="516" height="100" id="canvas-90"></canvas></div>
9044
+ <div class="canvas"><canvas width="516" height="100" id="canvas-93"></canvas></div>
8474
9045
  </div>
8475
9046
 
8476
9047
 
@@ -8482,7 +9053,7 @@ circle.scale(1.5);
8482
9053
  <div class="button run">Run</div>
8483
9054
  </div>
8484
9055
 
8485
- <script type="text/paperscript" canvas="canvas-91">
9056
+ <script type="text/paperscript" canvas="canvas-94">
8486
9057
  // Create a circle shaped path at { x: 80, y: 50 }
8487
9058
  // with a radius of 20:
8488
9059
  var circle = new Path.Circle({
@@ -8494,7 +9065,7 @@ var circle = new Path.Circle({
8494
9065
  // Scale the path 150% from its bottom left corner
8495
9066
  circle.scale(1.5, circle.bounds.bottomLeft);
8496
9067
  </script>
8497
- <div class="canvas"><canvas width="516" height="100" id="canvas-91"></canvas></div>
9068
+ <div class="canvas"><canvas width="516" height="100" id="canvas-94"></canvas></div>
8498
9069
  </div>
8499
9070
 
8500
9071
 
@@ -8550,7 +9121,7 @@ circle.scale(1.5, circle.bounds.bottomLeft);
8550
9121
  <div class="button run">Run</div>
8551
9122
  </div>
8552
9123
 
8553
- <script type="text/paperscript" canvas="canvas-92">
9124
+ <script type="text/paperscript" canvas="canvas-95">
8554
9125
  // Create a circle shaped path at { x: 100, y: 50 }
8555
9126
  // with a radius of 20:
8556
9127
  var circle = new Path.Circle({
@@ -8562,7 +9133,7 @@ var circle = new Path.Circle({
8562
9133
  // Scale the path horizontally by 300%
8563
9134
  circle.scale(3, 1);
8564
9135
  </script>
8565
- <div class="canvas"><canvas width="516" height="100" id="canvas-92"></canvas></div>
9136
+ <div class="canvas"><canvas width="516" height="100" id="canvas-95"></canvas></div>
8566
9137
  </div>
8567
9138
 
8568
9139
 
@@ -9000,7 +9571,7 @@ circle.scale(3, 1);
9000
9571
  <div class="button run">Run</div>
9001
9572
  </div>
9002
9573
 
9003
- <script type="text/paperscript" canvas="canvas-93">
9574
+ <script type="text/paperscript" canvas="canvas-96">
9004
9575
  // Create a rectangle shaped path with its top left corner
9005
9576
  // at {x: 80, y: 25} and a size of {width: 75, height: 50}:
9006
9577
  var path = new Path.Rectangle({
@@ -9021,7 +9592,7 @@ var circlePath = new Path.Circle({
9021
9592
  // the rectangular path:
9022
9593
  circlePath.fitBounds(path.bounds);
9023
9594
  </script>
9024
- <div class="canvas"><canvas width="516" height="100" id="canvas-93"></canvas></div>
9595
+ <div class="canvas"><canvas width="516" height="100" id="canvas-96"></canvas></div>
9025
9596
  </div>
9026
9597
 
9027
9598
 
@@ -9033,7 +9604,7 @@ circlePath.fitBounds(path.bounds);
9033
9604
  <div class="button run">Run</div>
9034
9605
  </div>
9035
9606
 
9036
- <script type="text/paperscript" canvas="canvas-94">
9607
+ <script type="text/paperscript" canvas="canvas-97">
9037
9608
  // Create a rectangle shaped path with its top left corner
9038
9609
  // at {x: 80, y: 25} and a size of {width: 75, height: 50}:
9039
9610
  var path = new Path.Rectangle({
@@ -9054,7 +9625,7 @@ var circlePath = new Path.Circle({
9054
9625
  // the rectangular path:
9055
9626
  circlePath.fitBounds(path.bounds, 'cover');
9056
9627
  </script>
9057
- <div class="canvas"><canvas width="516" height="100" id="canvas-94"></canvas></div>
9628
+ <div class="canvas"><canvas width="516" height="100" id="canvas-97"></canvas></div>
9058
9629
  </div>
9059
9630
 
9060
9631
 
@@ -9066,7 +9637,7 @@ circlePath.fitBounds(path.bounds, 'cover');
9066
9637
  <div class="button run">Run</div>
9067
9638
  </div>
9068
9639
 
9069
- <script type="text/paperscript" canvas="canvas-95">
9640
+ <script type="text/paperscript" canvas="canvas-98">
9070
9641
  var path = new Path.Circle({
9071
9642
  center: [80, 50],
9072
9643
  radius: 30,
@@ -9076,7 +9647,7 @@ var path = new Path.Circle({
9076
9647
  // Fit the path to the bounding rectangle of the view:
9077
9648
  path.fitBounds(view.bounds);
9078
9649
  </script>
9079
- <div class="canvas"><canvas width="516" height="200" id="canvas-95"></canvas></div>
9650
+ <div class="canvas"><canvas width="516" height="200" id="canvas-98"></canvas></div>
9080
9651
  </div>
9081
9652
 
9082
9653
 
@@ -9102,7 +9673,7 @@ path.fitBounds(view.bounds);
9102
9673
  <li>
9103
9674
  <tt>type:</tt>
9104
9675
  <tt>String</tt>
9105
- &mdash;&nbsp;the type of event: <tt>&lsquo;frame&rsquo;</tt>, <tt>mousedown&rsquo;</tt>, <tt>&lsquo;mouseup&rsquo;</tt>, <tt>&lsquo;mousedrag&rsquo;</tt>, <tt>&lsquo;click&rsquo;</tt>, <tt>&lsquo;doubleclick&rsquo;</tt>, <tt>&lsquo;mousemove&rsquo;</tt>, <tt>&lsquo;mouseenter&rsquo;</tt>, <tt>&lsquo;mouseleave&rsquo;</tt>
9676
+ &mdash;&nbsp;the type of event: <tt>&lsquo;frame&rsquo;</tt>, <tt>mousedown&rsquo;</tt>, <tt>&lsquo;mouseup&rsquo;</tt>, <tt>&lsquo;mousedrag&rsquo;</tt>, <tt>&lsquo;click&rsquo;</tt>, <tt>&lsquo;doubleclick&rsquo;</tt>, <tt>&lsquo;mousemove&rsquo;</tt>, <tt>&lsquo;mouseenter&rsquo;</tt>, <tt>&lsquo;mouseleave&rsquo;</tt>, <tt>&lsquo;draw&rsquo;</tt>, <tt>&lsquo;drawselection&rsquo;</tt>
9106
9677
 
9107
9678
  </li>
9108
9679
 
@@ -9137,7 +9708,7 @@ path.fitBounds(view.bounds);
9137
9708
  <div class="button run">Run</div>
9138
9709
  </div>
9139
9710
 
9140
- <script type="text/paperscript" canvas="canvas-96">
9711
+ <script type="text/paperscript" canvas="canvas-99">
9141
9712
  // Create a circle shaped path at the center of the view:
9142
9713
  var path = new Path.Circle({
9143
9714
  center: view.center,
@@ -9155,7 +9726,7 @@ path.on('mouseleave', function() {
9155
9726
  this.fillColor = 'black';
9156
9727
  });
9157
9728
  </script>
9158
- <div class="canvas"><canvas width="516" height="100" id="canvas-96"></canvas></div>
9729
+ <div class="canvas"><canvas width="516" height="100" id="canvas-99"></canvas></div>
9159
9730
  </div>
9160
9731
 
9161
9732
 
@@ -9179,7 +9750,7 @@ path.on('mouseleave', function() {
9179
9750
  <li>
9180
9751
  <tt>object:</tt>
9181
9752
  <tt>Object</tt>
9182
- &mdash;&nbsp;an object containing one or more of the following properties: <tt>frame</tt>, <tt>mousedown</tt>, <tt>mouseup</tt>, <tt>mousedrag</tt>, <tt>click</tt>, <tt>doubleclick</tt>, <tt>mousemove</tt>, <tt>mouseenter</tt>, <tt>mouseleave</tt>
9753
+ &mdash;&nbsp;an object containing one or more of the following properties: <tt>frame</tt>, <tt>mousedown</tt>, <tt>mouseup</tt>, <tt>mousedrag</tt>, <tt>click</tt>, <tt>doubleclick</tt>, <tt>mousemove</tt>, <tt>mouseenter</tt>, <tt>mouseleave</tt>, <tt>draw</tt>, <tt>drawselection</tt>
9183
9754
 
9184
9755
  </li>
9185
9756
 
@@ -9207,7 +9778,7 @@ path.on('mouseleave', function() {
9207
9778
  <div class="button run">Run</div>
9208
9779
  </div>
9209
9780
 
9210
- <script type="text/paperscript" canvas="canvas-97">
9781
+ <script type="text/paperscript" canvas="canvas-100">
9211
9782
  // Create a circle shaped path at the center of the view:
9212
9783
  var path = new Path.Circle({
9213
9784
  center: view.center,
@@ -9225,7 +9796,7 @@ path.on({
9225
9796
  }
9226
9797
  });
9227
9798
  </script>
9228
- <div class="canvas"><canvas width="516" height="100" id="canvas-97"></canvas></div>
9799
+ <div class="canvas"><canvas width="516" height="100" id="canvas-100"></canvas></div>
9229
9800
  </div>
9230
9801
 
9231
9802
 
@@ -9237,7 +9808,7 @@ path.on({
9237
9808
  <div class="button run">Run</div>
9238
9809
  </div>
9239
9810
 
9240
- <script type="text/paperscript" canvas="canvas-98">
9811
+ <script type="text/paperscript" canvas="canvas-101">
9241
9812
  var pathHandlers = {
9242
9813
  mouseenter: function(event) {
9243
9814
  this.fillColor = 'red';
@@ -9260,7 +9831,7 @@ function onMouseDown(event) {
9260
9831
  path.on(pathHandlers);
9261
9832
  }
9262
9833
  </script>
9263
- <div class="canvas"><canvas width="516" height="100" id="canvas-98"></canvas></div>
9834
+ <div class="canvas"><canvas width="516" height="100" id="canvas-101"></canvas></div>
9264
9835
  </div>
9265
9836
 
9266
9837
 
@@ -9284,7 +9855,7 @@ function onMouseDown(event) {
9284
9855
  <li>
9285
9856
  <tt>type:</tt>
9286
9857
  <tt>String</tt>
9287
- &mdash;&nbsp;the type of event: <tt>&lsquo;frame&rsquo;</tt>, <tt>mousedown&rsquo;</tt>, <tt>&lsquo;mouseup&rsquo;</tt>, <tt>&lsquo;mousedrag&rsquo;</tt>, <tt>&lsquo;click&rsquo;</tt>, <tt>&lsquo;doubleclick&rsquo;</tt>, <tt>&lsquo;mousemove&rsquo;</tt>, <tt>&lsquo;mouseenter&rsquo;</tt>, <tt>&lsquo;mouseleave&rsquo;</tt>
9858
+ &mdash;&nbsp;the type of event: <tt>&lsquo;frame&rsquo;</tt>, <tt>mousedown&rsquo;</tt>, <tt>&lsquo;mouseup&rsquo;</tt>, <tt>&lsquo;mousedrag&rsquo;</tt>, <tt>&lsquo;click&rsquo;</tt>, <tt>&lsquo;doubleclick&rsquo;</tt>, <tt>&lsquo;mousemove&rsquo;</tt>, <tt>&lsquo;mouseenter&rsquo;</tt>, <tt>&lsquo;mouseleave&rsquo;</tt>, <tt>&lsquo;draw&rsquo;</tt>, <tt>&lsquo;drawselection&rsquo;</tt>
9288
9859
 
9289
9860
  </li>
9290
9861
 
@@ -9332,7 +9903,7 @@ function onMouseDown(event) {
9332
9903
  <li>
9333
9904
  <tt>object:</tt>
9334
9905
  <tt>Object</tt>
9335
- &mdash;&nbsp;an object containing one or more of the following properties: <tt>frame</tt>, <tt>mousedown</tt>, <tt>mouseup</tt>, <tt>mousedrag</tt>, <tt>click</tt>, <tt>doubleclick</tt>, <tt>mousemove</tt>, <tt>mouseenter</tt>, <tt>mouseleave</tt>
9906
+ &mdash;&nbsp;an object containing one or more of the following properties: <tt>frame</tt>, <tt>mousedown</tt>, <tt>mouseup</tt>, <tt>mousedrag</tt>, <tt>click</tt>, <tt>doubleclick</tt>, <tt>mousemove</tt>, <tt>mouseenter</tt>, <tt>mouseleave</tt>, <tt>draw</tt>, <tt>drawselection</tt>
9336
9907
 
9337
9908
  </li>
9338
9909
 
@@ -9373,7 +9944,7 @@ function onMouseDown(event) {
9373
9944
  <li>
9374
9945
  <tt>type:</tt>
9375
9946
  <tt>String</tt>
9376
- &mdash;&nbsp;the type of event: <tt>&lsquo;frame&rsquo;</tt>, <tt>mousedown&rsquo;</tt>, <tt>&lsquo;mouseup&rsquo;</tt>, <tt>&lsquo;mousedrag&rsquo;</tt>, <tt>&lsquo;click&rsquo;</tt>, <tt>&lsquo;doubleclick&rsquo;</tt>, <tt>&lsquo;mousemove&rsquo;</tt>, <tt>&lsquo;mouseenter&rsquo;</tt>, <tt>&lsquo;mouseleave&rsquo;</tt>
9947
+ &mdash;&nbsp;the type of event: <tt>&lsquo;frame&rsquo;</tt>, <tt>mousedown&rsquo;</tt>, <tt>&lsquo;mouseup&rsquo;</tt>, <tt>&lsquo;mousedrag&rsquo;</tt>, <tt>&lsquo;click&rsquo;</tt>, <tt>&lsquo;doubleclick&rsquo;</tt>, <tt>&lsquo;mousemove&rsquo;</tt>, <tt>&lsquo;mouseenter&rsquo;</tt>, <tt>&lsquo;mouseleave&rsquo;</tt>, <tt>&lsquo;draw&rsquo;</tt>, <tt>&lsquo;drawselection&rsquo;</tt>
9377
9948
 
9378
9949
  </li>
9379
9950
 
@@ -9421,7 +9992,7 @@ function onMouseDown(event) {
9421
9992
  <li>
9422
9993
  <tt>type:</tt>
9423
9994
  <tt>String</tt>
9424
- &mdash;&nbsp;the type of event: <tt>&lsquo;frame&rsquo;</tt>, <tt>mousedown&rsquo;</tt>, <tt>&lsquo;mouseup&rsquo;</tt>, <tt>&lsquo;mousedrag&rsquo;</tt>, <tt>&lsquo;click&rsquo;</tt>, <tt>&lsquo;doubleclick&rsquo;</tt>, <tt>&lsquo;mousemove&rsquo;</tt>, <tt>&lsquo;mouseenter&rsquo;</tt>, <tt>&lsquo;mouseleave&rsquo;</tt>
9995
+ &mdash;&nbsp;the type of event: <tt>&lsquo;frame&rsquo;</tt>, <tt>mousedown&rsquo;</tt>, <tt>&lsquo;mouseup&rsquo;</tt>, <tt>&lsquo;mousedrag&rsquo;</tt>, <tt>&lsquo;click&rsquo;</tt>, <tt>&lsquo;doubleclick&rsquo;</tt>, <tt>&lsquo;mousemove&rsquo;</tt>, <tt>&lsquo;mouseenter&rsquo;</tt>, <tt>&lsquo;mouseleave&rsquo;</tt>, <tt>&lsquo;draw&rsquo;</tt>, <tt>&lsquo;drawselection&rsquo;</tt>
9425
9996
 
9426
9997
  </li>
9427
9998
 
@@ -9488,7 +10059,7 @@ function onMouseDown(event) {
9488
10059
  <div class="button run">Run</div>
9489
10060
  </div>
9490
10061
 
9491
- <script type="text/paperscript" canvas="canvas-99">
10062
+ <script type="text/paperscript" canvas="canvas-102">
9492
10063
  function onMouseDrag(event) {
9493
10064
  // Create a circle shaped path at the mouse position,
9494
10065
  // with a radius of 10:
@@ -9505,7 +10076,7 @@ function onMouseDrag(event) {
9505
10076
  });
9506
10077
  }
9507
10078
  </script>
9508
- <div class="canvas"><canvas width="516" height="200" id="canvas-99"></canvas></div>
10079
+ <div class="canvas"><canvas width="516" height="200" id="canvas-102"></canvas></div>
9509
10080
  </div>
9510
10081
 
9511
10082
 
@@ -9535,7 +10106,7 @@ function onMouseDrag(event) {
9535
10106
  <div class="button run">Run</div>
9536
10107
  </div>
9537
10108
 
9538
- <script type="text/paperscript" canvas="canvas-100">
10109
+ <script type="text/paperscript" canvas="canvas-103">
9539
10110
  function onMouseMove(event) {
9540
10111
  // Create a circle shaped path at the mouse position,
9541
10112
  // with a radius of 10:
@@ -9549,7 +10120,7 @@ function onMouseMove(event) {
9549
10120
  path.removeOnMove();
9550
10121
  }
9551
10122
  </script>
9552
- <div class="canvas"><canvas width="516" height="200" id="canvas-100"></canvas></div>
10123
+ <div class="canvas"><canvas width="516" height="200" id="canvas-103"></canvas></div>
9553
10124
  </div>
9554
10125
 
9555
10126
 
@@ -9579,7 +10150,7 @@ function onMouseMove(event) {
9579
10150
  <div class="button run">Run</div>
9580
10151
  </div>
9581
10152
 
9582
- <script type="text/paperscript" canvas="canvas-101">
10153
+ <script type="text/paperscript" canvas="canvas-104">
9583
10154
  function onMouseDown(event) {
9584
10155
  // Create a circle shaped path at the mouse position,
9585
10156
  // with a radius of 10:
@@ -9593,7 +10164,7 @@ function onMouseDown(event) {
9593
10164
  path.removeOnDown();
9594
10165
  }
9595
10166
  </script>
9596
- <div class="canvas"><canvas width="516" height="200" id="canvas-101"></canvas></div>
10167
+ <div class="canvas"><canvas width="516" height="200" id="canvas-104"></canvas></div>
9597
10168
  </div>
9598
10169
 
9599
10170
 
@@ -9623,7 +10194,7 @@ function onMouseDown(event) {
9623
10194
  <div class="button run">Run</div>
9624
10195
  </div>
9625
10196
 
9626
- <script type="text/paperscript" canvas="canvas-102">
10197
+ <script type="text/paperscript" canvas="canvas-105">
9627
10198
  function onMouseDrag(event) {
9628
10199
  // Create a circle shaped path at the mouse position,
9629
10200
  // with a radius of 10:
@@ -9637,7 +10208,7 @@ function onMouseDrag(event) {
9637
10208
  path.removeOnDrag();
9638
10209
  }
9639
10210
  </script>
9640
- <div class="canvas"><canvas width="516" height="200" id="canvas-102"></canvas></div>
10211
+ <div class="canvas"><canvas width="516" height="200" id="canvas-105"></canvas></div>
9641
10212
  </div>
9642
10213
 
9643
10214
 
@@ -9667,7 +10238,7 @@ function onMouseDrag(event) {
9667
10238
  <div class="button run">Run</div>
9668
10239
  </div>
9669
10240
 
9670
- <script type="text/paperscript" canvas="canvas-103">
10241
+ <script type="text/paperscript" canvas="canvas-106">
9671
10242
  function onMouseDown(event) {
9672
10243
  // Create a circle shaped path at the mouse position,
9673
10244
  // with a radius of 10:
@@ -9681,7 +10252,7 @@ function onMouseDown(event) {
9681
10252
  path.removeOnUp();
9682
10253
  }
9683
10254
  </script>
9684
- <div class="canvas"><canvas width="516" height="200" id="canvas-103"></canvas></div>
10255
+ <div class="canvas"><canvas width="516" height="200" id="canvas-106"></canvas></div>
9685
10256
  </div>
9686
10257
 
9687
10258
 
@@ -9754,7 +10325,7 @@ function onMouseDown(event) {
9754
10325
  <div class="button run">Run</div>
9755
10326
  </div>
9756
10327
 
9757
- <script type="text/paperscript" canvas="canvas-104">
10328
+ <script type="text/paperscript" canvas="canvas-107">
9758
10329
  var path = new Path.Circle({
9759
10330
  radius: view.bounds.height * 0.4,
9760
10331
  center: view.center
@@ -9765,7 +10336,7 @@ path.tween(
9765
10336
  3000
9766
10337
  );
9767
10338
  </script>
9768
- <div class="canvas"><canvas width="516" height="100" id="canvas-104"></canvas></div>
10339
+ <div class="canvas"><canvas width="516" height="100" id="canvas-107"></canvas></div>
9769
10340
  </div>
9770
10341
 
9771
10342
 
@@ -9777,7 +10348,7 @@ path.tween(
9777
10348
  <div class="button run">Run</div>
9778
10349
  </div>
9779
10350
 
9780
- <script type="text/paperscript" canvas="canvas-105">
10351
+ <script type="text/paperscript" canvas="canvas-108">
9781
10352
  var path = new Shape.Rectangle({
9782
10353
  fillColor: 'red',
9783
10354
  center: [50, view.center.y],
@@ -9792,7 +10363,7 @@ path.tween({
9792
10363
  duration: 2000
9793
10364
  });
9794
10365
  </script>
9795
- <div class="canvas"><canvas width="516" height="100" id="canvas-105"></canvas></div>
10366
+ <div class="canvas"><canvas width="516" height="100" id="canvas-108"></canvas></div>
9796
10367
  </div>
9797
10368
 
9798
10369
 
@@ -9858,7 +10429,7 @@ path.tween({
9858
10429
  <div class="button run">Run</div>
9859
10430
  </div>
9860
10431
 
9861
- <script type="text/paperscript" canvas="canvas-106">
10432
+ <script type="text/paperscript" canvas="canvas-109">
9862
10433
  var path = new Path.Rectangle({
9863
10434
  size: [100, 100],
9864
10435
  position: view.center,
@@ -9872,7 +10443,7 @@ path.tween({
9872
10443
  'segments[2].point.x': '-= 50'
9873
10444
  }, 3000);
9874
10445
  </script>
9875
- <div class="canvas"><canvas width="516" height="200" id="canvas-106"></canvas></div>
10446
+ <div class="canvas"><canvas width="516" height="200" id="canvas-109"></canvas></div>
9876
10447
  </div>
9877
10448
 
9878
10449
 
@@ -9931,7 +10502,7 @@ path.tween({
9931
10502
  <div class="button run">Run</div>
9932
10503
  </div>
9933
10504
 
9934
- <script type="text/paperscript" canvas="canvas-107">
10505
+ <script type="text/paperscript" canvas="canvas-110">
9935
10506
  var path = new Path.Circle({
9936
10507
  fillColor: 'blue',
9937
10508
  radius: view.bounds.height * 0.4,
@@ -9947,7 +10518,7 @@ path.tween(2000).onUpdate = function(event) {
9947
10518
  path.interpolate(pathFrom, pathTo, event.factor)
9948
10519
  };
9949
10520
  </script>
9950
- <div class="canvas"><canvas width="516" height="100" id="canvas-107"></canvas></div>
10521
+ <div class="canvas"><canvas width="516" height="100" id="canvas-110"></canvas></div>
9951
10522
  </div>
9952
10523
 
9953
10524
 
@@ -10068,7 +10639,7 @@ path.tween(2000).onUpdate = function(event) {
10068
10639
  <div class="button run">Run</div>
10069
10640
  </div>
10070
10641
 
10071
- <script type="text/paperscript" canvas="canvas-108">
10642
+ <script type="text/paperscript" canvas="canvas-111">
10072
10643
  var path = new Path.Circle({
10073
10644
  fillColor: 'blue',
10074
10645
  radius: view.bounds.height * 0.4,
@@ -10076,7 +10647,7 @@ var path = new Path.Circle({
10076
10647
  });
10077
10648
  path.tweenFrom({ fillColor: 'red' }, { duration: 1000 });
10078
10649
  </script>
10079
- <div class="canvas"><canvas width="516" height="100" id="canvas-108"></canvas></div>
10650
+ <div class="canvas"><canvas width="516" height="100" id="canvas-111"></canvas></div>
10080
10651
  </div>
10081
10652
 
10082
10653
 
@@ -10242,12 +10813,12 @@ path.tweenFrom({ fillColor: 'red' }, { duration: 1000 });
10242
10813
  <div class="button run">Run</div>
10243
10814
  </div>
10244
10815
 
10245
- <script type="text/paperscript" canvas="canvas-109">
10816
+ <script type="text/paperscript" canvas="canvas-112">
10246
10817
  var result = new Path.RegularPolygon([50, 50], 3, 40)
10247
10818
  .unite(new Path.Circle([50, 50], 25));
10248
10819
  result.fillColor = 'red';
10249
10820
  </script>
10250
- <div class="canvas"><canvas width="516" height="100" id="canvas-109"></canvas></div>
10821
+ <div class="canvas"><canvas width="516" height="100" id="canvas-112"></canvas></div>
10251
10822
  </div>
10252
10823
 
10253
10824
 
@@ -10259,7 +10830,7 @@ result.fillColor = 'red';
10259
10830
  <div class="button run">Run</div>
10260
10831
  </div>
10261
10832
 
10262
- <script type="text/paperscript" canvas="canvas-110">
10833
+ <script type="text/paperscript" canvas="canvas-113">
10263
10834
  var circles = [];
10264
10835
  for (var i = 0; i < 6; i++) {
10265
10836
  circles.push(new Path.Circle([30 + i * 20, 50], 20));
@@ -10267,7 +10838,7 @@ for (var i = 0; i < 6; i++) {
10267
10838
  var result = circles[0].unite(circles.slice(1));
10268
10839
  result.fillColor = 'red';
10269
10840
  </script>
10270
- <div class="canvas"><canvas width="516" height="100" id="canvas-110"></canvas></div>
10841
+ <div class="canvas"><canvas width="516" height="100" id="canvas-113"></canvas></div>
10271
10842
  </div>
10272
10843
 
10273
10844
 
@@ -10330,12 +10901,12 @@ result.fillColor = 'red';
10330
10901
  <div class="button run">Run</div>
10331
10902
  </div>
10332
10903
 
10333
- <script type="text/paperscript" canvas="canvas-111">
10904
+ <script type="text/paperscript" canvas="canvas-114">
10334
10905
  var result = new Path.RegularPolygon([50, 50], 3, 40)
10335
10906
  .intersect(new Path.Circle([50, 50], 25));
10336
10907
  result.fillColor = 'red';
10337
10908
  </script>
10338
- <div class="canvas"><canvas width="516" height="100" id="canvas-111"></canvas></div>
10909
+ <div class="canvas"><canvas width="516" height="100" id="canvas-114"></canvas></div>
10339
10910
  </div>
10340
10911
 
10341
10912
 
@@ -10361,16 +10932,254 @@ result.fillColor = 'red';
10361
10932
  <h4>Parameters:</h4>
10362
10933
 
10363
10934
  <li>
10364
- <tt>path:</tt>
10365
- <a href="../classes/PathItem.html"><tt>PathItem</tt></a>⟋Array of <a href="../classes/PathItem.html"><tt>PathItem</tt></a> objects
10366
- &mdash;&nbsp;the path or paths to subtract
10935
+ <tt>path:</tt>
10936
+ <a href="../classes/PathItem.html"><tt>PathItem</tt></a>⟋Array of <a href="../classes/PathItem.html"><tt>PathItem</tt></a> objects
10937
+ &mdash;&nbsp;the path or paths to subtract
10938
+
10939
+ </li>
10940
+
10941
+ <li>
10942
+ <tt>options:</tt>
10943
+ <tt>Object</tt>
10944
+ &mdash;&nbsp;the boolean operation options
10945
+ &mdash;&nbsp;optional
10946
+ </li>
10947
+
10948
+ </ul>
10949
+
10950
+
10951
+ <ul class="member-list">
10952
+ <h4>Returns:</h4>
10953
+
10954
+ <li>
10955
+ <tt><a href="../classes/PathItem.html"><tt>PathItem</tt></a></tt>&nbsp;&mdash;&nbsp;the resulting path item
10956
+ </li>
10957
+
10958
+
10959
+ </ul>
10960
+
10961
+
10962
+
10963
+
10964
+ <h4>Example:</h4>
10965
+
10966
+ <div class="paperscript split">
10967
+
10968
+ <div class="buttons">
10969
+ <div class="button run">Run</div>
10970
+ </div>
10971
+
10972
+ <script type="text/paperscript" canvas="canvas-115">
10973
+ var result = new Path.RegularPolygon([50, 50], 3, 40)
10974
+ .subtract(new Path.Circle([50, 50], 25));
10975
+ result.fillColor = 'red';
10976
+ </script>
10977
+ <div class="canvas"><canvas width="516" height="100" id="canvas-115"></canvas></div>
10978
+ </div>
10979
+
10980
+
10981
+ </div>
10982
+ </div>
10983
+ </div>
10984
+
10985
+
10986
+ <div id="exclude-path" class="member">
10987
+ <div class="member-link">
10988
+ <a name="exclude-path" href="#exclude-path"><tt><b>exclude</b>(path[, options])</tt></a>
10989
+ </div>
10990
+ <div class="member-description hidden">
10991
+ <div class="member-text">
10992
+ <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>
10993
+ <ul class="member-list">
10994
+ <h4>Options:</h4>
10995
+ <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>
10996
+ </ul>
10997
+
10998
+ <ul class="member-list">
10999
+ <h4>Parameters:</h4>
11000
+
11001
+ <li>
11002
+ <tt>path:</tt>
11003
+ <a href="../classes/PathItem.html"><tt>PathItem</tt></a>⟋Array of <a href="../classes/PathItem.html"><tt>PathItem</tt></a> objects
11004
+ &mdash;&nbsp;the path or paths to exclude the intersection of
11005
+
11006
+ </li>
11007
+
11008
+ <li>
11009
+ <tt>options:</tt>
11010
+ <tt>Object</tt>
11011
+ &mdash;&nbsp;the boolean operation options
11012
+ &mdash;&nbsp;optional
11013
+ </li>
11014
+
11015
+ </ul>
11016
+
11017
+
11018
+ <ul class="member-list">
11019
+ <h4>Returns:</h4>
11020
+
11021
+ <li>
11022
+ <tt><a href="../classes/PathItem.html"><tt>PathItem</tt></a></tt>&nbsp;&mdash;&nbsp;the resulting path item
11023
+ </li>
11024
+
11025
+
11026
+ </ul>
11027
+
11028
+
11029
+
11030
+
11031
+ <h4>Example:</h4>
11032
+
11033
+ <div class="paperscript split">
11034
+
11035
+ <div class="buttons">
11036
+ <div class="button run">Run</div>
11037
+ </div>
11038
+
11039
+ <script type="text/paperscript" canvas="canvas-116">
11040
+ var result = new Path.RegularPolygon([50, 50], 3, 40)
11041
+ .exclude(new Path.Circle([50, 50], 25));
11042
+ result.fillColor = 'red';
11043
+ </script>
11044
+ <div class="canvas"><canvas width="516" height="100" id="canvas-116"></canvas></div>
11045
+ </div>
11046
+
11047
+
11048
+ </div>
11049
+ </div>
11050
+ </div>
11051
+
11052
+
11053
+ <div id="divide-path" class="member">
11054
+ <div class="member-link">
11055
+ <a name="divide-path" href="#divide-path"><tt><b>divide</b>(path[, options])</tt></a>
11056
+ </div>
11057
+ <div class="member-description hidden">
11058
+ <div class="member-text">
11059
+ <p>Splits the geometry of this path along the geometry of the specified path returns the result as a new group item. This is equivalent to calling <a href="../classes/PathItem.html#subtract-path"><tt>subtract(path)</tt></a> and <a href="../classes/PathItem.html#intersect-path"><tt>intersect(path)</tt></a> and putting the results into a new group.</p>
11060
+ <ul class="member-list">
11061
+ <h4>Options:</h4>
11062
+ <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>
11063
+ <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. &mdash;&nbsp;default: <tt>true</tt></li>
11064
+ </ul>
11065
+
11066
+ <ul class="member-list">
11067
+ <h4>Parameters:</h4>
11068
+
11069
+ <li>
11070
+ <tt>path:</tt>
11071
+ <a href="../classes/PathItem.html"><tt>PathItem</tt></a>
11072
+ &mdash;&nbsp;the path to divide by
11073
+
11074
+ </li>
11075
+
11076
+ <li>
11077
+ <tt>options:</tt>
11078
+ <tt>Object</tt>
11079
+ &mdash;&nbsp;the boolean operation options
11080
+ &mdash;&nbsp;optional
11081
+ </li>
11082
+
11083
+ </ul>
11084
+
11085
+
11086
+ <ul class="member-list">
11087
+ <h4>Returns:</h4>
11088
+
11089
+ <li>
11090
+ <tt><a href="../classes/PathItem.html"><tt>PathItem</tt></a></tt>&nbsp;&mdash;&nbsp;the resulting path item
11091
+ </li>
11092
+
11093
+
11094
+ </ul>
11095
+
11096
+
11097
+
11098
+
11099
+
11100
+ </div>
11101
+ </div>
11102
+ </div>
11103
+
11104
+
11105
+ <div id="reorient" class="member">
11106
+ <div class="member-link">
11107
+ <a name="reorient" href="#reorient"><tt><b>reorient</b>([nonZero[, clockwise]])</tt></a>
11108
+ </div>
11109
+ <div class="member-description hidden">
11110
+ <div class="member-text">
11111
+ <p>Fixes the orientation of the sub-paths of a compound-path, assuming that non of its sub-paths intersect, by reorienting them so that they are of different winding direction than their containing paths, except for disjoint sub-paths, i.e. islands, which are oriented so that they have the same winding direction as the the biggest path.</p>
11112
+
11113
+
11114
+ <ul class="member-list">
11115
+ <h4>Parameters:</h4>
11116
+
11117
+ <li>
11118
+ <tt>nonZero:</tt>
11119
+ <tt>Boolean</tt>
11120
+ &mdash;&nbsp;controls if the non-zero fill-rule is to be applied, by counting the winding of each nested path and discarding sub-paths that do not contribute to the final result
11121
+ &mdash;&nbsp;optional, default: <tt>false</tt>
11122
+ </li>
11123
+
11124
+ <li>
11125
+ <tt>clockwise:</tt>
11126
+ <tt>Boolean</tt>
11127
+ &mdash;&nbsp;if provided, the orientation of the root paths will be set to the orientation specified by <code>clockwise</code>, otherwise the orientation of the largest root child is used.
11128
+ &mdash;&nbsp;optional
11129
+ </li>
11130
+
11131
+ </ul>
11132
+
11133
+
11134
+ <ul class="member-list">
11135
+ <h4>Returns:</h4>
11136
+
11137
+ <li>
11138
+ <tt><a href="../classes/PathItem.html"><tt>PathItem</tt></a></tt>&nbsp;&mdash;&nbsp;a reference to the item itself, reoriented
11139
+ </li>
11140
+
11141
+
11142
+ </ul>
11143
+
11144
+
11145
+
11146
+
11147
+
11148
+ </div>
11149
+ </div>
11150
+ </div>
11151
+
11152
+
11153
+ <h3>Offsetting and Outlining</h3>
11154
+
11155
+ <div id="offset-distance" class="member">
11156
+ <div class="member-link">
11157
+ <a name="offset-distance" href="#offset-distance"><tt><b>offset</b>(distance[, options])</tt></a>
11158
+ </div>
11159
+ <div class="member-description hidden">
11160
+ <div class="member-text">
11161
+ <p>Offsets the path item by the given distance and returns the result as a new path item. Closed paths and compound paths grow by positive distances and shrink by negative ones, open paths are offset along their normals for positive distances, and against them for negative ones. As with the boolean operations, the path item&rsquo;s matrix is applied first.</p>
11162
+ <ul class="member-list">
11163
+ <h4>Options:</h4>
11164
+ <li><tt>options.join: <tt>String</tt></tt> &mdash; the shape of the corners that the offset adds where the path turns away from it: <tt>&lsquo;miter&rsquo;</tt>, <tt>&lsquo;round&rsquo;</tt>, <tt>&lsquo;bevel&rsquo;</tt> &mdash;&nbsp;default: <tt>&lsquo;miter&rsquo;</tt></li>
11165
+ <li><tt>options.miterLimit: <tt>Number</tt></tt> &mdash; the limit of miter corners, see <a href="../classes/Style.html#miterlimit"><tt>style.miterLimit</tt></a> &mdash;&nbsp;default: <tt>10</tt></li>
11166
+ <li><tt>options.insert: <tt>Boolean</tt></tt> &mdash; whether the resulting item should be inserted back into the scene graph, above this path &mdash;&nbsp;default: <tt>true</tt></li>
11167
+ </ul>
11168
+
11169
+ <ul class="member-list">
11170
+ <h4>Parameters:</h4>
11171
+
11172
+ <li>
11173
+ <tt>distance:</tt>
11174
+ <tt>Number</tt>
11175
+ &mdash;&nbsp;the distance to offset the path item by
10367
11176
 
10368
11177
  </li>
10369
11178
 
10370
11179
  <li>
10371
11180
  <tt>options:</tt>
10372
11181
  <tt>Object</tt>
10373
- &mdash;&nbsp;the boolean operation options
11182
+ &mdash;&nbsp;the offset options
10374
11183
  &mdash;&nbsp;optional
10375
11184
  </li>
10376
11185
 
@@ -10398,12 +11207,13 @@ result.fillColor = 'red';
10398
11207
  <div class="button run">Run</div>
10399
11208
  </div>
10400
11209
 
10401
- <script type="text/paperscript" canvas="canvas-112">
10402
- var result = new Path.RegularPolygon([50, 50], 3, 40)
10403
- .subtract(new Path.Circle([50, 50], 25));
10404
- result.fillColor = 'red';
11210
+ <script type="text/paperscript" canvas="canvas-117">
11211
+ var path = new Path.Star([50, 50], 5, 20, 40);
11212
+ path.strokeColor = 'black';
11213
+ var result = path.offset(10, { join: 'round' });
11214
+ result.strokeColor = 'red';
10405
11215
  </script>
10406
- <div class="canvas"><canvas width="516" height="100" id="canvas-112"></canvas></div>
11216
+ <div class="canvas"><canvas width="516" height="100" id="canvas-117"></canvas></div>
10407
11217
  </div>
10408
11218
 
10409
11219
 
@@ -10412,32 +11222,30 @@ result.fillColor = 'red';
10412
11222
  </div>
10413
11223
 
10414
11224
 
10415
- <div id="exclude-path" class="member">
11225
+ <div id="outline" class="member">
10416
11226
  <div class="member-link">
10417
- <a name="exclude-path" href="#exclude-path"><tt><b>exclude</b>(path[, options])</tt></a>
11227
+ <a name="outline" href="#outline"><tt><b>outline</b>([options])</tt></a>
10418
11228
  </div>
10419
11229
  <div class="member-description hidden">
10420
11230
  <div class="member-text">
10421
- <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>
11231
+ <p>Outlines the stroke of the path item, and returns the area that it covers as a new path item, filled with the stroke&rsquo;s color. As with the boolean operations, the path item&rsquo;s matrix is applied first. Dashed strokes are outlined as their dashes, each with the stroke&rsquo;s caps, as the canvas draws them, see <a href="../classes/PathItem.html#dash-options"><tt>dash(options)</tt></a>.</p>
11232
+ <p>Paths with a <a href="../classes/Path.html#strokeprofile"><tt>path.strokeProfile</tt></a> are outlined as the area that its pens sweep. Their round joins and caps are the pens themselves, and their other joins and caps connect the points where the pens touch the sides of the stroke. Steps in the profile end the parts of the stroke straight across, as butt caps do.</p>
10422
11233
  <ul class="member-list">
10423
11234
  <h4>Options:</h4>
10424
- <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>
11235
+ <li><tt>options.width: <tt>Number</tt></tt> &mdash; the width of the stroke &mdash;&nbsp;default: <tt>this.strokeWidth</tt></li>
11236
+ <li><tt>options.join: <tt>String</tt></tt> &mdash; the shape of the stroke&rsquo;s corners: <tt>&lsquo;miter&rsquo;</tt>, <tt>&lsquo;round&rsquo;</tt>, <tt>&lsquo;bevel&rsquo;</tt> &mdash;&nbsp;default: <tt>this.strokeJoin</tt></li>
11237
+ <li><tt>options.cap: <tt>String</tt></tt> &mdash; the shape of the stroke&rsquo;s ends: <tt>&lsquo;round&rsquo;</tt>, <tt>&lsquo;square&rsquo;</tt>, <tt>&lsquo;butt&rsquo;</tt> &mdash;&nbsp;default: <tt>this.strokeCap</tt></li>
11238
+ <li><tt>options.miterLimit: <tt>Number</tt></tt> &mdash; the limit of miter corners, see <a href="../classes/Style.html#miterlimit"><tt>style.miterLimit</tt></a> &mdash;&nbsp;default: <tt>this.miterLimit</tt></li>
11239
+ <li><tt>options.insert: <tt>Boolean</tt></tt> &mdash; whether the resulting item should be inserted back into the scene graph, above this path &mdash;&nbsp;default: <tt>true</tt></li>
10425
11240
  </ul>
10426
11241
 
10427
11242
  <ul class="member-list">
10428
11243
  <h4>Parameters:</h4>
10429
11244
 
10430
- <li>
10431
- <tt>path:</tt>
10432
- <a href="../classes/PathItem.html"><tt>PathItem</tt></a>⟋Array of <a href="../classes/PathItem.html"><tt>PathItem</tt></a> objects
10433
- &mdash;&nbsp;the path or paths to exclude the intersection of
10434
-
10435
- </li>
10436
-
10437
11245
  <li>
10438
11246
  <tt>options:</tt>
10439
11247
  <tt>Object</tt>
10440
- &mdash;&nbsp;the boolean operation options
11248
+ &mdash;&nbsp;the outline options
10441
11249
  &mdash;&nbsp;optional
10442
11250
  </li>
10443
11251
 
@@ -10465,12 +11273,17 @@ result.fillColor = 'red';
10465
11273
  <div class="button run">Run</div>
10466
11274
  </div>
10467
11275
 
10468
- <script type="text/paperscript" canvas="canvas-113">
10469
- var result = new Path.RegularPolygon([50, 50], 3, 40)
10470
- .exclude(new Path.Circle([50, 50], 25));
10471
- result.fillColor = 'red';
11276
+ <script type="text/paperscript" canvas="canvas-118">
11277
+ var path = new Path.Arc([20, 70], [50, 20], [80, 70]);
11278
+ path.strokeColor = 'black';
11279
+ path.strokeWidth = 20;
11280
+ path.strokeCap = 'round';
11281
+ var result = path.outline();
11282
+ result.strokeColor = 'red';
11283
+ result.strokeWidth = 1;
11284
+ path.remove();
10472
11285
  </script>
10473
- <div class="canvas"><canvas width="516" height="100" id="canvas-113"></canvas></div>
11286
+ <div class="canvas"><canvas width="516" height="100" id="canvas-118"></canvas></div>
10474
11287
  </div>
10475
11288
 
10476
11289
 
@@ -10479,33 +11292,27 @@ result.fillColor = 'red';
10479
11292
  </div>
10480
11293
 
10481
11294
 
10482
- <div id="divide-path" class="member">
11295
+ <div id="dash" class="member">
10483
11296
  <div class="member-link">
10484
- <a name="divide-path" href="#divide-path"><tt><b>divide</b>(path[, options])</tt></a>
11297
+ <a name="dash" href="#dash"><tt><b>dash</b>([options])</tt></a>
10485
11298
  </div>
10486
11299
  <div class="member-description hidden">
10487
11300
  <div class="member-text">
10488
- <p>Splits the geometry of this path along the geometry of the specified path returns the result as a new group item. This is equivalent to calling <a href="../classes/PathItem.html#subtract-path"><tt>subtract(path)</tt></a> and <a href="../classes/PathItem.html#intersect-path"><tt>intersect(path)</tt></a> and putting the results into a new group.</p>
11301
+ <p>Cuts the stroke of the path item into its dashes, as the canvas draws them with the <a href="../classes/Style.html#dasharray"><tt>style.dashArray</tt></a> and <a href="../classes/Style.html#dashoffset"><tt>style.dashOffset</tt></a> of the path item or those of the options, and returns them as a new group of open paths with the path item&rsquo;s style, without its dash pattern. The pattern starts over on each path of a compound path, and the dashes keep the parts of the paths&rsquo; stroke profiles. As with the boolean operations, the path item&rsquo;s matrix is applied first.</p>
10489
11302
  <ul class="member-list">
10490
11303
  <h4>Options:</h4>
10491
- <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>
10492
- <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. &mdash;&nbsp;default: <tt>true</tt></li>
11304
+ <li><tt>options.dashArray: Array of <tt>Numbers</tt></tt> &mdash; the lengths of the dashes and the gaps between them &mdash;&nbsp;default: <tt>this.dashArray</tt></li>
11305
+ <li><tt>options.dashOffset: <tt>Number</tt></tt> &mdash; the offset into the pattern at which the dashes start &mdash;&nbsp;default: <tt>this.dashOffset</tt></li>
11306
+ <li><tt>options.insert: <tt>Boolean</tt></tt> &mdash; whether the resulting group should be inserted back into the scene graph, above this path item &mdash;&nbsp;default: <tt>true</tt></li>
10493
11307
  </ul>
10494
11308
 
10495
11309
  <ul class="member-list">
10496
11310
  <h4>Parameters:</h4>
10497
11311
 
10498
- <li>
10499
- <tt>path:</tt>
10500
- <a href="../classes/PathItem.html"><tt>PathItem</tt></a>
10501
- &mdash;&nbsp;the path to divide by
10502
-
10503
- </li>
10504
-
10505
11312
  <li>
10506
11313
  <tt>options:</tt>
10507
11314
  <tt>Object</tt>
10508
- &mdash;&nbsp;the boolean operation options
11315
+ &mdash;&nbsp;the dash options
10509
11316
  &mdash;&nbsp;optional
10510
11317
  </li>
10511
11318
 
@@ -10516,7 +11323,7 @@ result.fillColor = 'red';
10516
11323
  <h4>Returns:</h4>
10517
11324
 
10518
11325
  <li>
10519
- <tt><a href="../classes/PathItem.html"><tt>PathItem</tt></a></tt>&nbsp;&mdash;&nbsp;the resulting path item
11326
+ <tt><a href="../classes/Group.html"><tt>Group</tt></a></tt>&nbsp;&mdash;&nbsp;the dashes, as a new group of paths
10520
11327
  </li>
10521
11328
 
10522
11329
 
@@ -10525,55 +11332,34 @@ result.fillColor = 'red';
10525
11332
 
10526
11333
 
10527
11334
 
10528
-
10529
- </div>
10530
- </div>
10531
- </div>
10532
-
10533
-
10534
- <div id="reorient" class="member">
10535
- <div class="member-link">
10536
- <a name="reorient" href="#reorient"><tt><b>reorient</b>([nonZero[, clockwise]])</tt></a>
10537
- </div>
10538
- <div class="member-description hidden">
10539
- <div class="member-text">
10540
- <p>Fixes the orientation of the sub-paths of a compound-path, assuming that non of its sub-paths intersect, by reorienting them so that they are of different winding direction than their containing paths, except for disjoint sub-paths, i.e. islands, which are oriented so that they have the same winding direction as the the biggest path.</p>
10541
-
10542
-
10543
- <ul class="member-list">
10544
- <h4>Parameters:</h4>
10545
-
10546
- <li>
10547
- <tt>nonZero:</tt>
10548
- <tt>Boolean</tt>
10549
- &mdash;&nbsp;controls if the non-zero fill-rule is to be applied, by counting the winding of each nested path and discarding sub-paths that do not contribute to the final result
10550
- &mdash;&nbsp;optional, default: <tt>false</tt>
10551
- </li>
10552
-
10553
- <li>
10554
- <tt>clockwise:</tt>
10555
- <tt>Boolean</tt>
10556
- &mdash;&nbsp;if provided, the orientation of the root paths will be set to the orientation specified by <code>clockwise</code>, otherwise the orientation of the largest root child is used.
10557
- &mdash;&nbsp;optional
10558
- </li>
10559
-
10560
- </ul>
11335
+ <h4>Example:</h4>
10561
11336
 
10562
-
10563
- <ul class="member-list">
10564
- <h4>Returns:</h4>
10565
-
10566
- <li>
10567
- <tt><a href="../classes/PathItem.html"><tt>PathItem</tt></a></tt>&nbsp;&mdash;&nbsp;a reference to the item itself, reoriented
10568
- </li>
11337
+ <div class="paperscript split">
10569
11338
 
10570
-
10571
- </ul>
11339
+ <div class="buttons">
11340
+ <div class="button run">Run</div>
11341
+ </div>
10572
11342
 
11343
+ <script type="text/paperscript" canvas="canvas-119">
11344
+ var path = new Path.Circle({
11345
+ center: [80, 50],
11346
+ radius: 35,
11347
+ strokeColor: 'black',
11348
+ strokeWidth: 4,
11349
+ dashArray: [12, 6]
11350
+ });
11351
+ // Turn every other dash red:
11352
+ var dashes = path.dash();
11353
+ dashes.children.forEach(function(dash, i) {
11354
+ if (i % 2)
11355
+ dash.strokeColor = 'red';
11356
+ });
11357
+ path.remove();
11358
+ </script>
11359
+ <div class="canvas"><canvas width="516" height="100" id="canvas-119"></canvas></div>
11360
+ </div>
10573
11361
 
10574
11362
 
10575
-
10576
-
10577
11363
  </div>
10578
11364
  </div>
10579
11365
  </div>
@@ -10638,7 +11424,7 @@ result.fillColor = 'red';
10638
11424
  <div class="button run">Run</div>
10639
11425
  </div>
10640
11426
 
10641
- <script type="text/paperscript" canvas="canvas-114">
11427
+ <script type="text/paperscript" canvas="canvas-120">
10642
11428
  var path = new Path.Rectangle(new Point(30, 25), new Size(50, 50));
10643
11429
  path.strokeColor = 'black';
10644
11430
 
@@ -10661,7 +11447,7 @@ function onFrame(event) {
10661
11447
  }
10662
11448
  }
10663
11449
  </script>
10664
- <div class="canvas"><canvas width="516" height="100" id="canvas-114"></canvas></div>
11450
+ <div class="canvas"><canvas width="516" height="100" id="canvas-120"></canvas></div>
10665
11451
  </div>
10666
11452
 
10667
11453
 
@@ -10802,7 +11588,7 @@ function onFrame(event) {
10802
11588
  <div class="button run">Run</div>
10803
11589
  </div>
10804
11590
 
10805
- <script type="text/paperscript" canvas="canvas-115">
11591
+ <script type="text/paperscript" canvas="canvas-121">
10806
11592
  var star = new Path.Star({
10807
11593
  center: view.center,
10808
11594
  points: 10,
@@ -10826,7 +11612,7 @@ function onMouseMove(event) {
10826
11612
  circle.position = nearestPoint;
10827
11613
  }
10828
11614
  </script>
10829
- <div class="canvas"><canvas width="516" height="200" id="canvas-115"></canvas></div>
11615
+ <div class="canvas"><canvas width="516" height="200" id="canvas-121"></canvas></div>
10830
11616
  </div>
10831
11617
 
10832
11618
 
@@ -10889,7 +11675,7 @@ function onMouseMove(event) {
10889
11675
  <div class="button run">Run</div>
10890
11676
  </div>
10891
11677
 
10892
- <script type="text/paperscript" canvas="canvas-116">
11678
+ <script type="text/paperscript" canvas="canvas-122">
10893
11679
  // Create a circle shaped path at { x: 80, y: 50 }
10894
11680
  // with a radius of 35:
10895
11681
  var path = new Path.Circle({
@@ -10907,7 +11693,7 @@ copy.position.x += 150;
10907
11693
  // Flatten the copied path, with a maximum error of 4 points:
10908
11694
  copy.flatten(4);
10909
11695
  </script>
10910
- <div class="canvas"><canvas width="516" height="100" id="canvas-116"></canvas></div>
11696
+ <div class="canvas"><canvas width="516" height="100" id="canvas-122"></canvas></div>
10911
11697
  </div>
10912
11698
 
10913
11699
 
@@ -10985,7 +11771,7 @@ copy.flatten(4);
10985
11771
  <div class="button run">Run</div>
10986
11772
  </div>
10987
11773
 
10988
- <script type="text/paperscript" canvas="canvas-117">
11774
+ <script type="text/paperscript" canvas="canvas-123">
10989
11775
  // Create a rectangular path with its top-left point at
10990
11776
  // {x: 30, y: 25} and a size of {width: 50, height: 50}:
10991
11777
  var path = new Path.Rectangle({
@@ -11004,7 +11790,7 @@ copy.position.x += 100;
11004
11790
  // Smooth the segments of the copy:
11005
11791
  copy.smooth({ type: 'continuous' });
11006
11792
  </script>
11007
- <div class="canvas"><canvas width="516" height="100" id="canvas-117"></canvas></div>
11793
+ <div class="canvas"><canvas width="516" height="100" id="canvas-123"></canvas></div>
11008
11794
  </div>
11009
11795
 
11010
11796
 
@@ -11016,7 +11802,7 @@ copy.smooth({ type: 'continuous' });
11016
11802
  <div class="button run">Run</div>
11017
11803
  </div>
11018
11804
 
11019
- <script type="text/paperscript" canvas="canvas-118">
11805
+ <script type="text/paperscript" canvas="canvas-124">
11020
11806
  var path = new Path();
11021
11807
  path.strokeColor = 'black';
11022
11808
 
@@ -11041,7 +11827,7 @@ copy.fullySelected = true;
11041
11827
  // Smooth the path using centripetal Catmull-Rom splines:
11042
11828
  copy.smooth({ type: 'catmull-rom', factor: 0.5 });
11043
11829
  </script>
11044
- <div class="canvas"><canvas width="516" height="220" id="canvas-118"></canvas></div>
11830
+ <div class="canvas"><canvas width="516" height="220" id="canvas-124"></canvas></div>
11045
11831
  </div>
11046
11832
 
11047
11833
 
@@ -11053,7 +11839,7 @@ copy.smooth({ type: 'catmull-rom', factor: 0.5 });
11053
11839
  <div class="button run">Run</div>
11054
11840
  </div>
11055
11841
 
11056
- <script type="text/paperscript" canvas="canvas-119">
11842
+ <script type="text/paperscript" canvas="canvas-125">
11057
11843
  // Create 5 rectangles, next to each other:
11058
11844
  var paths = [];
11059
11845
  for (var i = 0; i < 5; i++) {
@@ -11083,7 +11869,7 @@ paths[3].smooth({ type: 'continuous', from: 0, to: 2 });
11083
11869
  // Smooth a range, using negative indices:
11084
11870
  paths[4].smooth({ type: 'continuous', from: -1, to: 1 });
11085
11871
  </script>
11086
- <div class="canvas"><canvas width="516" height="110" id="canvas-119"></canvas></div>
11872
+ <div class="canvas"><canvas width="516" height="110" id="canvas-125"></canvas></div>
11087
11873
  </div>
11088
11874
 
11089
11875
 
@@ -11094,22 +11880,28 @@ paths[4].smooth({ type: 'continuous', from: -1, to: 1 });
11094
11880
 
11095
11881
  <div id="simplify" class="member">
11096
11882
  <div class="member-link">
11097
- <a name="simplify" href="#simplify"><tt><b>simplify</b>([tolerance])</tt></a>
11883
+ <a name="simplify" href="#simplify"><tt><b>simplify</b>([options])</tt></a>
11098
11884
  </div>
11099
11885
  <div class="member-description hidden">
11100
11886
  <div class="member-text">
11101
11887
  <p>Fits a sequence of as few curves as possible through the path&rsquo;s anchor points, ignoring the path items&rsquo;s curve-handles, with an allowed maximum error. When called on <a href="../classes/CompoundPath.html"><tt>CompoundPath</tt></a> items, each of the nested paths is simplified. On <a href="../classes/Path.html"><tt>Path</tt></a> items, the <a href="../classes/Path.html#segments"><tt>path.segments</tt></a> array is processed and replaced by the resulting sequence of fitted curves.</p>
11102
11888
  <p>This method can be used to process and simplify the point data received from a mouse or touch device.</p>
11103
-
11889
+ <p>With <code>options.from</code> and <code>options.to</code>, only the segments in that range are replaced. The fitted curves join the curves outside of the range tangentially where these have handles.</p>
11890
+ <ul class="member-list">
11891
+ <h4>Options:</h4>
11892
+ <li><tt>options.tolerance: <tt>Number</tt></tt> &mdash; the allowed maximum error when fitting the curves through the segment points &mdash;&nbsp;default: <tt>2.5</tt></li>
11893
+ <li><tt>options.from: <tt>Number</tt>⟋<a href="../classes/Segment.html"><tt>Segment</tt></a>⟋<a href="../classes/Curve.html"><tt>Curve</tt></a></tt> &mdash; the segment or curve at which to start simplifying, if not the full path shall be simplified (inclusive). This can either be a segment index, or a segment or curve object that is part of the path. If the passed number is negative, the index is wrapped around the end of the path.</li>
11894
+ <li><tt>options.to: <tt>Number</tt>⟋<a href="../classes/Segment.html"><tt>Segment</tt></a>⟋<a href="../classes/Curve.html"><tt>Curve</tt></a></tt> &mdash; the segment or curve up to which to simplify (inclusive). This can either be a segment index, or a segment or curve object that is part of the path. If the passed number is negative, the index is wrapped around the end of the path.</li>
11895
+ </ul>
11104
11896
 
11105
11897
  <ul class="member-list">
11106
11898
  <h4>Parameters:</h4>
11107
11899
 
11108
11900
  <li>
11109
- <tt>tolerance:</tt>
11110
- <tt>Number</tt>
11111
- &mdash;&nbsp;the allowed maximum error when fitting the curves through the segment points
11112
- &mdash;&nbsp;optional, default: <tt>2.5</tt>
11901
+ <tt>options:</tt>
11902
+ <tt>Object</tt>⟋<tt>Number</tt>
11903
+ &mdash;&nbsp;the simplification options, or the tolerance as a number
11904
+ &mdash;&nbsp;optional
11113
11905
  </li>
11114
11906
 
11115
11907
  </ul>
@@ -11136,7 +11928,7 @@ paths[4].smooth({ type: 'continuous', from: -1, to: 1 });
11136
11928
  <div class="button run">Run</div>
11137
11929
  </div>
11138
11930
 
11139
- <script type="text/paperscript" canvas="canvas-120">
11931
+ <script type="text/paperscript" canvas="canvas-126">
11140
11932
  var path;
11141
11933
  function onMouseDown(event) {
11142
11934
  // If we already made a path before, deselect it:
@@ -11166,7 +11958,7 @@ function onMouseUp(event) {
11166
11958
  path.selected = true;
11167
11959
  }
11168
11960
  </script>
11169
- <div class="canvas"><canvas width="516" height="300" id="canvas-120"></canvas></div>
11961
+ <div class="canvas"><canvas width="516" height="300" id="canvas-126"></canvas></div>
11170
11962
  </div>
11171
11963
 
11172
11964
 
@@ -11365,7 +12157,7 @@ function onMouseUp(event) {
11365
12157
  <div class="button run">Run</div>
11366
12158
  </div>
11367
12159
 
11368
- <script type="text/paperscript" canvas="canvas-121">
12160
+ <script type="text/paperscript" canvas="canvas-127">
11369
12161
  var path = new Path();
11370
12162
  path.strokeColor = 'black';
11371
12163
 
@@ -11385,7 +12177,7 @@ path.arcTo(throughPoint, toPoint);
11385
12177
  var circle = new Path.Circle(throughPoint, 3);
11386
12178
  circle.fillColor = 'red';
11387
12179
  </script>
11388
- <div class="canvas"><canvas width="516" height="100" id="canvas-121"></canvas></div>
12180
+ <div class="canvas"><canvas width="516" height="100" id="canvas-127"></canvas></div>
11389
12181
  </div>
11390
12182
 
11391
12183
 
@@ -11397,7 +12189,7 @@ circle.fillColor = 'red';
11397
12189
  <div class="button run">Run</div>
11398
12190
  </div>
11399
12191
 
11400
- <script type="text/paperscript" canvas="canvas-122">
12192
+ <script type="text/paperscript" canvas="canvas-128">
11401
12193
  var myPath;
11402
12194
  function onMouseDrag(event) {
11403
12195
  // If we created a path before, remove it:
@@ -11425,7 +12217,7 @@ function onMouseUp(event) {
11425
12217
  myPath.fillColor = 'black';
11426
12218
  }
11427
12219
  </script>
11428
- <div class="canvas"><canvas width="516" height="300" id="canvas-122"></canvas></div>
12220
+ <div class="canvas"><canvas width="516" height="300" id="canvas-128"></canvas></div>
11429
12221
  </div>
11430
12222
 
11431
12223
 
@@ -11474,7 +12266,7 @@ function onMouseUp(event) {
11474
12266
  <div class="button run">Run</div>
11475
12267
  </div>
11476
12268
 
11477
- <script type="text/paperscript" canvas="canvas-123">
12269
+ <script type="text/paperscript" canvas="canvas-129">
11478
12270
  var path = new Path();
11479
12271
  path.strokeColor = 'black';
11480
12272
 
@@ -11489,7 +12281,7 @@ path2.add(new Point(180, 25));
11489
12281
  // we pass `false` as the second argument to arcTo:
11490
12282
  path2.arcTo(new Point(280, 25), false);
11491
12283
  </script>
11492
- <div class="canvas"><canvas width="516" height="100" id="canvas-123"></canvas></div>
12284
+ <div class="canvas"><canvas width="516" height="100" id="canvas-129"></canvas></div>
11493
12285
  </div>
11494
12286
 
11495
12287
 
@@ -11501,7 +12293,7 @@ path2.arcTo(new Point(280, 25), false);
11501
12293
  <div class="button run">Run</div>
11502
12294
  </div>
11503
12295
 
11504
- <script type="text/paperscript" canvas="canvas-124">
12296
+ <script type="text/paperscript" canvas="canvas-130">
11505
12297
  var myPath;
11506
12298
 
11507
12299
  // The mouse has to move at least 20 points before
@@ -11522,7 +12314,158 @@ function onMouseDrag(event) {
11522
12314
  myPath.arcTo(event.point);
11523
12315
  }
11524
12316
  </script>
11525
- <div class="canvas"><canvas width="516" height="300" id="canvas-124"></canvas></div>
12317
+ <div class="canvas"><canvas width="516" height="300" id="canvas-130"></canvas></div>
12318
+ </div>
12319
+
12320
+
12321
+ </div>
12322
+ </div>
12323
+ </div>
12324
+
12325
+
12326
+ <div id="arcaround-center-angle" class="member">
12327
+ <div class="member-link">
12328
+ <a name="arcaround-center-angle" href="#arcaround-center-angle"><tt><b>arcAround</b>(center, angle)</tt></a>
12329
+ </div>
12330
+ <div class="member-description hidden">
12331
+ <div class="member-text">
12332
+ <p>Adds an arc that sweeps the specified angle around the specified <code>center</code> point, from the position of the last segment in the path, by adding one or more segments to the path. Positive angles draw the arc in clockwise direction, negative ones in anticlockwise direction.</p>
12333
+
12334
+
12335
+ <ul class="member-list">
12336
+ <h4>Parameters:</h4>
12337
+
12338
+ <li>
12339
+ <tt>center:</tt>
12340
+ <a href="../classes/Point.html"><tt>Point</tt></a>
12341
+ &mdash;&nbsp;the center of the arc
12342
+
12343
+ </li>
12344
+
12345
+ <li>
12346
+ <tt>angle:</tt>
12347
+ <tt>Number</tt>
12348
+ &mdash;&nbsp;the angle in degrees that the arc sweeps over
12349
+
12350
+ </li>
12351
+
12352
+ </ul>
12353
+
12354
+
12355
+
12356
+
12357
+
12358
+ <h4>Example:</h4>
12359
+
12360
+ <div class="paperscript split">
12361
+
12362
+ <div class="buttons">
12363
+ <div class="button run">Run</div>
12364
+ </div>
12365
+
12366
+ <script type="text/paperscript" canvas="canvas-131">
12367
+ var path = new Path();
12368
+ path.strokeColor = 'black';
12369
+ path.add(new Point(30, 75));
12370
+ path.lineTo(new Point(80, 75));
12371
+
12372
+ // Draw a half circle around (105, 75) and continue on the other side:
12373
+ path.arcAround(new Point(105, 75), 180);
12374
+ path.lineTo(new Point(180, 75));
12375
+
12376
+ // Draw a full circle around (230, 75):
12377
+ var circle = new Path();
12378
+ circle.strokeColor = 'red';
12379
+ circle.add(new Point(250, 75));
12380
+ circle.arcAround(new Point(230, 75), 360);
12381
+ </script>
12382
+ <div class="canvas"><canvas width="516" height="100" id="canvas-131"></canvas></div>
12383
+ </div>
12384
+
12385
+
12386
+ </div>
12387
+ </div>
12388
+ </div>
12389
+
12390
+
12391
+ <div id="arctowards-to" class="member">
12392
+ <div class="member-link">
12393
+ <a name="arctowards-to" href="#arctowards-to"><tt><b>arcTowards</b>(to)</tt></a>
12394
+ </div>
12395
+ <div class="member-description hidden">
12396
+ <div class="member-text">
12397
+ <p>Adds an arc from the position of the last segment in the path to the specified point, by adding one or more segments to the path. The arc continues in the direction in which the path ends, without a corner.</p>
12398
+
12399
+
12400
+ <ul class="member-list">
12401
+ <h4>Parameters:</h4>
12402
+
12403
+ <li>
12404
+ <tt>to:</tt>
12405
+ <a href="../classes/Point.html"><tt>Point</tt></a>
12406
+ &mdash;&nbsp;the point where the arc should end
12407
+
12408
+ </li>
12409
+
12410
+ </ul>
12411
+
12412
+
12413
+
12414
+
12415
+
12416
+ <h4>Example:</h4>
12417
+
12418
+ <div class="paperscript split">
12419
+
12420
+ <div class="buttons">
12421
+ <div class="button run">Run</div>
12422
+ </div>
12423
+
12424
+ <script type="text/paperscript" canvas="canvas-132">
12425
+ var path = new Path();
12426
+ path.strokeColor = 'black';
12427
+ path.add(new Point(30, 125));
12428
+ path.lineTo(new Point(80, 125));
12429
+
12430
+ // Each arc continues smoothly from where the path ends:
12431
+ path.arcTowards(new Point(130, 75));
12432
+ path.arcTowards(new Point(230, 75));
12433
+ path.lineTo(new Point(230, 125));
12434
+ </script>
12435
+ <div class="canvas"><canvas width="516" height="100" id="canvas-132"></canvas></div>
12436
+ </div>
12437
+
12438
+
12439
+ <h4>Example:<span class="description">Interactive example. Click and drag in the view below:</span></h4>
12440
+
12441
+ <div class="paperscript split">
12442
+
12443
+ <div class="buttons">
12444
+ <div class="button run">Run</div>
12445
+ </div>
12446
+
12447
+ <script type="text/paperscript" canvas="canvas-133">
12448
+ var myPath;
12449
+
12450
+ // The mouse has to move at least 20 points before
12451
+ // the next mouse drag event is fired:
12452
+ tool.minDistance = 20;
12453
+
12454
+ // When the user clicks, create a new path that starts
12455
+ // with a horizontal line ending at the mouse position:
12456
+ function onMouseDown(event) {
12457
+ myPath = new Path();
12458
+ myPath.strokeColor = 'black';
12459
+ myPath.add(event.point - [20, 0], event.point);
12460
+ }
12461
+
12462
+ // On each mouse drag event, continue the path smoothly
12463
+ // with an arc to the current position of the mouse:
12464
+ function onMouseDrag(event) {
12465
+ myPath.arcTowards(event.point);
12466
+ }
12467
+ </script>
12468
+ <div class="canvas"><canvas width="516" height="300" id="canvas-133"></canvas></div>
11526
12469
  </div>
11527
12470
 
11528
12471
 
@@ -11578,7 +12521,7 @@ function onMouseDrag(event) {
11578
12521
  <div class="button run">Run</div>
11579
12522
  </div>
11580
12523
 
11581
- <script type="text/paperscript" canvas="canvas-125">
12524
+ <script type="text/paperscript" canvas="canvas-134">
11582
12525
  var myPath;
11583
12526
  function onMouseMove(event) {
11584
12527
  // If we created a path before, remove it:
@@ -11599,7 +12542,7 @@ function onMouseMove(event) {
11599
12542
  myPath.selected = true;
11600
12543
  }
11601
12544
  </script>
11602
- <div class="canvas"><canvas width="516" height="300" id="canvas-125"></canvas></div>
12545
+ <div class="canvas"><canvas width="516" height="300" id="canvas-134"></canvas></div>
11603
12546
  </div>
11604
12547
 
11605
12548
 
@@ -11784,7 +12727,7 @@ function onMouseMove(event) {
11784
12727
  <div class="button run">Run</div>
11785
12728
  </div>
11786
12729
 
11787
- <script type="text/paperscript" canvas="canvas-126">
12730
+ <script type="text/paperscript" canvas="canvas-135">
11788
12731
  var path = new Path();
11789
12732
  path.strokeColor = 'black';
11790
12733
 
@@ -11798,7 +12741,7 @@ path.lineBy(50, 0);
11798
12741
  // 0 in x direction and 50 in y direction, becomes {x: 75, y: 75}
11799
12742
  path.lineBy(0, 50);
11800
12743
  </script>
11801
- <div class="canvas"><canvas width="516" height="100" id="canvas-126"></canvas></div>
12744
+ <div class="canvas"><canvas width="516" height="100" id="canvas-135"></canvas></div>
11802
12745
  </div>
11803
12746
 
11804
12747
 
@@ -11810,7 +12753,7 @@ path.lineBy(0, 50);
11810
12753
  <div class="button run">Run</div>
11811
12754
  </div>
11812
12755
 
11813
- <script type="text/paperscript" canvas="canvas-127">
12756
+ <script type="text/paperscript" canvas="canvas-136">
11814
12757
  var path = new Path();
11815
12758
  path.strokeColor = 'black';
11816
12759
 
@@ -11836,7 +12779,7 @@ path.smooth();
11836
12779
  // the construction of the path:
11837
12780
  // path.selected = true;
11838
12781
  </script>
11839
- <div class="canvas"><canvas width="516" height="300" id="canvas-127"></canvas></div>
12782
+ <div class="canvas"><canvas width="516" height="300" id="canvas-136"></canvas></div>
11840
12783
  </div>
11841
12784
 
11842
12785
 
@@ -12055,7 +12998,7 @@ path.smooth();
12055
12998
 
12056
12999
  <!-- =========================== copyright notice ========================== -->
12057
13000
  <p class="footer">
12058
- Paper.js v0.16.0<br>
13001
+ Paper.js v0.17.0<br>
12059
13002
  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>
12060
13003
  <div class="content-end"></div>
12061
13004