paper 0.15.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 (64) hide show
  1. package/CHANGELOG.md +158 -0
  2. package/README.md +24 -16
  3. package/dist/docs/assets/js/paper.js +4811 -808
  4. package/dist/docs/classes/AreaText.html +771 -243
  5. package/dist/docs/classes/ChangeFlag.html +1 -1
  6. package/dist/docs/classes/Color.html +218 -21
  7. package/dist/docs/classes/CompoundPath.html +1174 -274
  8. package/dist/docs/classes/Curve.html +2 -2
  9. package/dist/docs/classes/CurveLocation.html +1 -1
  10. package/dist/docs/classes/DrawEvent.html +69 -0
  11. package/dist/docs/classes/Effect.html +434 -0
  12. package/dist/docs/classes/EffectInstance.html +304 -0
  13. package/dist/docs/classes/Event.html +1 -1
  14. package/dist/docs/classes/Gradient.html +1 -1
  15. package/dist/docs/classes/GradientStop.html +1 -1
  16. package/dist/docs/classes/Group.html +842 -243
  17. package/dist/docs/classes/HitResult.html +1 -1
  18. package/dist/docs/classes/HostItem.html +770 -242
  19. package/dist/docs/classes/Item.html +827 -242
  20. package/dist/docs/classes/Key.html +1 -1
  21. package/dist/docs/classes/KeyEvent.html +1 -1
  22. package/dist/docs/classes/Layer.html +784 -185
  23. package/dist/docs/classes/Matrix.html +1 -1
  24. package/dist/docs/classes/MouseEvent.html +1 -1
  25. package/dist/docs/classes/PaperScope.html +1 -1
  26. package/dist/docs/classes/PaperScript.html +4 -2
  27. package/dist/docs/classes/Path.html +1366 -352
  28. package/dist/docs/classes/PathItem.html +1198 -298
  29. package/dist/docs/classes/PathText.html +772 -244
  30. package/dist/docs/classes/PatternDefinition.html +367 -0
  31. package/dist/docs/classes/Point.html +33 -5
  32. package/dist/docs/classes/PointText.html +771 -243
  33. package/dist/docs/classes/Project.html +251 -9
  34. package/dist/docs/classes/Raster.html +770 -242
  35. package/dist/docs/classes/Rectangle.html +50 -8
  36. package/dist/docs/classes/Segment.html +79 -2
  37. package/dist/docs/classes/Shape.html +770 -242
  38. package/dist/docs/classes/Size.html +31 -3
  39. package/dist/docs/classes/StrokeProfileStop.html +346 -0
  40. package/dist/docs/classes/Style.html +67 -6
  41. package/dist/docs/classes/SymbolDefinition.html +28 -2
  42. package/dist/docs/classes/SymbolItem.html +807 -242
  43. package/dist/docs/classes/TextItem.html +771 -243
  44. package/dist/docs/classes/TextRange.html +1 -1
  45. package/dist/docs/classes/TextStory.html +1 -1
  46. package/dist/docs/classes/Tool.html +2 -2
  47. package/dist/docs/classes/ToolEvent.html +1 -1
  48. package/dist/docs/classes/Tween.html +1 -1
  49. package/dist/docs/classes/View.html +2 -2
  50. package/dist/docs/classes/global.html +1 -1
  51. package/dist/docs/classes/index.html +2 -2
  52. package/dist/docs/index.html +1 -1
  53. package/dist/node/browser.js +15 -0
  54. package/dist/paper-core.js +4701 -728
  55. package/dist/paper-core.min.js +3 -3
  56. package/dist/paper-full.js +4811 -808
  57. package/dist/paper-full.min.js +3 -3
  58. package/dist/paper-hosted.js +5389 -892
  59. package/dist/paper.d.ts +1058 -69
  60. package/examples/Paperjs.org/LiveEffects.html +366 -0
  61. package/examples/Paperjs.org/Offsetting.html +379 -0
  62. package/examples/Paperjs.org/StrokeProfiles.html +706 -0
  63. package/examples/Scripts/Patterns.html +57 -0
  64. package/package.json +21 -11
@@ -376,7 +376,7 @@
376
376
 
377
377
  <!-- =========================== copyright notice ========================== -->
378
378
  <p class="footer">
379
- Paper.js v0.15.0<br>
379
+ Paper.js v0.17.0<br>
380
380
  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>
381
381
  <div class="content-end"></div>
382
382
 
@@ -220,7 +220,7 @@ circle.fillColor = new Color(0.5);
220
220
  </div>
221
221
  <div class="member-description hidden">
222
222
  <div class="member-text">
223
- <p>Creates a HSB, HSL or gradient Color object from the properties of the provided object:</p>
223
+ <p>Creates a HSB, HSL, gradient or pattern Color object from the properties of the provided object:</p>
224
224
  <ul class="member-list">
225
225
  <h4>Options:</h4>
226
226
  <li><tt>hsb.hue: <tt>Number</tt></tt> &mdash; the hue of the color as a value in degrees between <code>0</code> and <code>360</code></li>
@@ -236,6 +236,8 @@ circle.fillColor = new Color(0.5);
236
236
  <li><tt>gradient.destination: <a href="../classes/Point.html"><tt>Point</tt></a></tt> &mdash; the destination point of the gradient</li>
237
237
  <li><tt>gradient.stops: Array of <a href="../classes/GradientStop.html"><tt>GradientStop</tt></a> objects</tt> &mdash; the gradient stops describing the gradient, as an alternative to providing a gradient object</li>
238
238
  <li><tt>gradient.radial: <tt>Boolean</tt></tt> &mdash; controls whether the gradient is radial, as an alternative to providing a gradient object</li>
239
+ <li><tt>pattern.pattern: <a href="../classes/PatternDefinition.html"><tt>PatternDefinition</tt></a></tt> &mdash; the pattern whose tiles the color repeats</li>
240
+ <li><tt>pattern.matrix: <a href="../classes/Matrix.html"><tt>Matrix</tt></a></tt> &mdash; the matrix that places the tiles in the item&rsquo;s coordinates</li>
239
241
  </ul>
240
242
 
241
243
  <ul class="member-list">
@@ -402,7 +404,7 @@ var circle = new Path.Circle({
402
404
 
403
405
  <div id="color-gradient-origin-destination" class="member">
404
406
  <div class="member-link">
405
- <a name="color-gradient-origin-destination" href="#color-gradient-origin-destination"><tt><b>Color</b>(gradient, origin, destination[, highlight])</tt></a>
407
+ <a name="color-gradient-origin-destination" href="#color-gradient-origin-destination"><tt><b>Color</b>(gradient, origin, destination[, highlight[, aspect]])</tt></a>
406
408
  </div>
407
409
  <div class="member-description hidden">
408
410
  <div class="member-text">
@@ -438,6 +440,13 @@ var circle = new Path.Circle({
438
440
  <a href="../classes/Point.html"><tt>Point</tt></a>
439
441
 
440
442
  &mdash;&nbsp;optional
443
+ </li>
444
+
445
+ <li>
446
+ <tt>aspect:</tt>
447
+ <tt>Number</tt>
448
+
449
+ &mdash;&nbsp;optional, default: <tt>1</tt>
441
450
  </li>
442
451
 
443
452
  </ul>
@@ -535,6 +544,83 @@ path.fillColor = gradientColor;
535
544
  </div>
536
545
 
537
546
 
547
+ </div>
548
+ </div>
549
+ </div>
550
+
551
+
552
+ <div id="color-pattern" class="member">
553
+ <div class="member-link">
554
+ <a name="color-pattern" href="#color-pattern"><tt><b>Color</b>(pattern[, matrix])</tt></a>
555
+ </div>
556
+ <div class="member-description hidden">
557
+ <div class="member-text">
558
+ <p>Creates a pattern Color object, which repeats the tiles of the pattern, placed by the matrix in the item&rsquo;s coordinates. As with gradient colors, the matrix is transformed along with the item.</p>
559
+
560
+
561
+ <ul class="member-list">
562
+ <h4>Parameters:</h4>
563
+
564
+ <li>
565
+ <tt>pattern:</tt>
566
+ <a href="../classes/PatternDefinition.html"><tt>PatternDefinition</tt></a>
567
+
568
+
569
+ </li>
570
+
571
+ <li>
572
+ <tt>matrix:</tt>
573
+ <a href="../classes/Matrix.html"><tt>Matrix</tt></a>
574
+
575
+ &mdash;&nbsp;optional
576
+ </li>
577
+
578
+ </ul>
579
+
580
+
581
+ <ul class="member-list">
582
+ <h4>Returns:</h4>
583
+
584
+ <li>
585
+ <tt><a href="../classes/Color.html"><tt>Color</tt></a></tt>
586
+ </li>
587
+
588
+
589
+ </ul>
590
+
591
+
592
+
593
+
594
+ <h4>Example:<span class="description">Filling a rectangle with a dotted pattern, and stroking it with the same pattern, turned by 45 degrees:</span></h4>
595
+
596
+ <div class="paperscript split">
597
+
598
+ <div class="buttons">
599
+ <div class="button run">Run</div>
600
+ </div>
601
+
602
+ <script type="text/paperscript" canvas="canvas-10">
603
+ var dot = new Path.Circle({
604
+ center: [4, 4],
605
+ radius: 2,
606
+ fillColor: 'black'
607
+ });
608
+ var pattern = new PatternDefinition(dot, {
609
+ tile: new Rectangle(0, 0, 8, 8)
610
+ });
611
+
612
+ var path = new Path.Rectangle({
613
+ point: [40, 40],
614
+ size: [160, 120],
615
+ strokeWidth: 16
616
+ });
617
+ path.fillColor = new Color(pattern);
618
+ path.strokeColor = new Color(pattern, new Matrix().rotate(45));
619
+ </script>
620
+ <div class="canvas"><canvas width="516" height="200" id="canvas-10"></canvas></div>
621
+ </div>
622
+
623
+
538
624
  </div>
539
625
  </div>
540
626
  </div>
@@ -1019,7 +1105,7 @@ console.log(color.type); // 'rgb'</code></pre>
1019
1105
  <div class="button run">Run</div>
1020
1106
  </div>
1021
1107
 
1022
- <script type="text/paperscript" canvas="canvas-10">
1108
+ <script type="text/paperscript" canvas="canvas-11">
1023
1109
  var circle = new Path.Circle(new Point(80, 50), 30);
1024
1110
 
1025
1111
  // Fill the circle with red and give it a 20pt green stroke:
@@ -1032,7 +1118,7 @@ circle.style = {
1032
1118
  // Make the stroke half transparent:
1033
1119
  circle.strokeColor.alpha = 0.5;
1034
1120
  </script>
1035
- <div class="canvas"><canvas width="516" height="100" id="canvas-10"></canvas></div>
1121
+ <div class="canvas"><canvas width="516" height="100" id="canvas-11"></canvas></div>
1036
1122
  </div>
1037
1123
 
1038
1124
 
@@ -1071,14 +1157,14 @@ circle.strokeColor.alpha = 0.5;
1071
1157
  <div class="button run">Run</div>
1072
1158
  </div>
1073
1159
 
1074
- <script type="text/paperscript" canvas="canvas-11">
1160
+ <script type="text/paperscript" canvas="canvas-12">
1075
1161
  var circle = new Path.Circle(new Point(80, 50), 30);
1076
1162
  circle.fillColor = 'blue';
1077
1163
 
1078
1164
  // Blue + red = purple:
1079
1165
  circle.fillColor.red = 1;
1080
1166
  </script>
1081
- <div class="canvas"><canvas width="516" height="100" id="canvas-11"></canvas></div>
1167
+ <div class="canvas"><canvas width="516" height="100" id="canvas-12"></canvas></div>
1082
1168
  </div>
1083
1169
 
1084
1170
 
@@ -1115,7 +1201,7 @@ circle.fillColor.red = 1;
1115
1201
  <div class="button run">Run</div>
1116
1202
  </div>
1117
1203
 
1118
- <script type="text/paperscript" canvas="canvas-12">
1204
+ <script type="text/paperscript" canvas="canvas-13">
1119
1205
  var circle = new Path.Circle(new Point(80, 50), 30);
1120
1206
 
1121
1207
  // First we set the fill color to red:
@@ -1124,7 +1210,7 @@ circle.fillColor = 'red';
1124
1210
  // Red + green = yellow:
1125
1211
  circle.fillColor.green = 1;
1126
1212
  </script>
1127
- <div class="canvas"><canvas width="516" height="100" id="canvas-12"></canvas></div>
1213
+ <div class="canvas"><canvas width="516" height="100" id="canvas-13"></canvas></div>
1128
1214
  </div>
1129
1215
 
1130
1216
 
@@ -1161,7 +1247,7 @@ circle.fillColor.green = 1;
1161
1247
  <div class="button run">Run</div>
1162
1248
  </div>
1163
1249
 
1164
- <script type="text/paperscript" canvas="canvas-13">
1250
+ <script type="text/paperscript" canvas="canvas-14">
1165
1251
  var circle = new Path.Circle(new Point(80, 50), 30);
1166
1252
 
1167
1253
  // First we set the fill color to red:
@@ -1170,7 +1256,7 @@ circle.fillColor = 'red';
1170
1256
  // Red + blue = purple:
1171
1257
  circle.fillColor.blue = 1;
1172
1258
  </script>
1173
- <div class="canvas"><canvas width="516" height="100" id="canvas-13"></canvas></div>
1259
+ <div class="canvas"><canvas width="516" height="100" id="canvas-14"></canvas></div>
1174
1260
  </div>
1175
1261
 
1176
1262
 
@@ -1237,12 +1323,12 @@ circle.fillColor.blue = 1;
1237
1323
  <div class="button run">Run</div>
1238
1324
  </div>
1239
1325
 
1240
- <script type="text/paperscript" canvas="canvas-14">
1326
+ <script type="text/paperscript" canvas="canvas-15">
1241
1327
  var circle = new Path.Circle(new Point(80, 50), 30);
1242
1328
  circle.fillColor = 'red';
1243
1329
  circle.fillColor.hue += 30;
1244
1330
  </script>
1245
- <div class="canvas"><canvas width="516" height="100" id="canvas-14"></canvas></div>
1331
+ <div class="canvas"><canvas width="516" height="100" id="canvas-15"></canvas></div>
1246
1332
  </div>
1247
1333
 
1248
1334
 
@@ -1254,7 +1340,7 @@ circle.fillColor.hue += 30;
1254
1340
  <div class="button run">Run</div>
1255
1341
  </div>
1256
1342
 
1257
- <script type="text/paperscript" canvas="canvas-15">
1343
+ <script type="text/paperscript" canvas="canvas-16">
1258
1344
  // Create a rectangle shaped path, using the dimensions
1259
1345
  // of the view:
1260
1346
  var path = new Path.Rectangle(view.bounds);
@@ -1264,7 +1350,7 @@ function onFrame(event) {
1264
1350
  path.fillColor.hue += 0.5;
1265
1351
  }
1266
1352
  </script>
1267
- <div class="canvas"><canvas width="516" height="100" id="canvas-15"></canvas></div>
1353
+ <div class="canvas"><canvas width="516" height="100" id="canvas-16"></canvas></div>
1268
1354
  </div>
1269
1355
 
1270
1356
 
@@ -1410,7 +1496,7 @@ function onFrame(event) {
1410
1496
  <div class="button run">Run</div>
1411
1497
  </div>
1412
1498
 
1413
- <script type="text/paperscript" canvas="canvas-16">
1499
+ <script type="text/paperscript" canvas="canvas-17">
1414
1500
  var path = new Path.Circle({
1415
1501
  center: view.center,
1416
1502
  radius: view.bounds.height * 0.4
@@ -1431,10 +1517,121 @@ function onMouseMove(event) {
1431
1517
  path.fillColor.highlight = event.point;
1432
1518
  }
1433
1519
  </script>
1434
- <div class="canvas"><canvas width="516" height="300" id="canvas-16"></canvas></div>
1520
+ <div class="canvas"><canvas width="516" height="300" id="canvas-17"></canvas></div>
1435
1521
  </div>
1436
1522
 
1437
1523
 
1524
+ </div>
1525
+
1526
+ </div>
1527
+ </div>
1528
+
1529
+
1530
+ <div id="aspect" class="member">
1531
+ <div class="member-link">
1532
+ <a name="aspect" href="#aspect"><tt><b>aspect</b></tt></a>
1533
+ </div>
1534
+ <div class="member-description hidden">
1535
+
1536
+ <div class="member-text">
1537
+ <p>The aspect of a radial gradient: its radius across the line from the origin to the destination, as a factor of its radius along it, which makes it an ellipse. Transforming a gradient color sets it, so that the gradient stretches, shears and rotates with its item.</p>
1538
+
1539
+
1540
+
1541
+ <ul class="member-list">
1542
+ <h4>Default:</h4>
1543
+ <li><tt>1</tt></li>
1544
+ </ul>
1545
+
1546
+ <ul class="member-list">
1547
+ <h4>Type:</h4>
1548
+ <li>
1549
+ <tt>Number</tt>
1550
+ </li>
1551
+ </ul>
1552
+
1553
+
1554
+ <h4>Example:<span class="description">An elliptical radial gradient, twice as wide as tall:</span></h4>
1555
+
1556
+ <div class="paperscript split">
1557
+
1558
+ <div class="buttons">
1559
+ <div class="button run">Run</div>
1560
+ </div>
1561
+
1562
+ <script type="text/paperscript" canvas="canvas-18">
1563
+ var path = new Path.Ellipse({
1564
+ center: view.center,
1565
+ radius: [80, 40],
1566
+ fillColor: {
1567
+ gradient: {
1568
+ stops: ['yellow', 'red', 'black'],
1569
+ radial: true
1570
+ },
1571
+ origin: view.center,
1572
+ destination: view.center + [80, 0],
1573
+ aspect: 0.5
1574
+ }
1575
+ });
1576
+ </script>
1577
+ <div class="canvas"><canvas width="516" height="200" id="canvas-18"></canvas></div>
1578
+ </div>
1579
+
1580
+
1581
+ </div>
1582
+
1583
+ </div>
1584
+ </div>
1585
+
1586
+
1587
+ <h3>Pattern Components</h3>
1588
+
1589
+ <div id="pattern" class="member">
1590
+ <div class="member-link">
1591
+ <a name="pattern" href="#pattern"><tt><b>pattern</b></tt></a>
1592
+ </div>
1593
+ <div class="member-description hidden">
1594
+
1595
+ <div class="member-text">
1596
+ <p>The pattern whose tiles the color repeats.</p>
1597
+
1598
+
1599
+
1600
+ <ul class="member-list">
1601
+ <h4>Type:</h4>
1602
+ <li>
1603
+ <a href="../classes/PatternDefinition.html"><tt>PatternDefinition</tt></a>
1604
+ </li>
1605
+ </ul>
1606
+
1607
+
1608
+
1609
+ </div>
1610
+
1611
+ </div>
1612
+ </div>
1613
+
1614
+
1615
+ <div id="matrix" class="member">
1616
+ <div class="member-link">
1617
+ <a name="matrix" href="#matrix"><tt><b>matrix</b></tt></a>
1618
+ </div>
1619
+ <div class="member-description hidden">
1620
+
1621
+ <div class="member-text">
1622
+ <p>The matrix that places the tiles of the pattern in the item&rsquo;s coordinates.</p>
1623
+
1624
+
1625
+
1626
+ <ul class="member-list">
1627
+ <h4>Type:</h4>
1628
+ <li>
1629
+ <a href="../classes/Matrix.html"><tt>Matrix</tt></a>
1630
+ </li>
1631
+ </ul>
1632
+
1633
+
1634
+
1438
1635
  </div>
1439
1636
 
1440
1637
  </div>
@@ -1710,7 +1907,7 @@ function onMouseMove(event) {
1710
1907
  </div>
1711
1908
  <div class="member-description hidden">
1712
1909
  <div class="member-text">
1713
- <p>Transform the gradient color by the specified matrix.</p>
1910
+ <p>Transform the gradient or pattern color by the specified matrix. Radial gradients become ellipses, see <a href="../classes/Color.html#aspect"><tt>aspect</tt></a>, and the stripes of linear gradients keep running across them, also when the matrix scales unevenly or shears. Pattern colors transform their <a href="../classes/Color.html#matrix"><tt>matrix</tt></a>.</p>
1714
1911
 
1715
1912
 
1716
1913
  <ul class="member-list">
@@ -1719,7 +1916,7 @@ function onMouseMove(event) {
1719
1916
  <li>
1720
1917
  <tt>matrix:</tt>
1721
1918
  <a href="../classes/Matrix.html"><tt>Matrix</tt></a>
1722
- &mdash;&nbsp;the matrix to transform the gradient color by
1919
+ &mdash;&nbsp;the matrix to transform the color by
1723
1920
 
1724
1921
  </li>
1725
1922
 
@@ -2177,12 +2374,12 @@ console.log(result); // { red: 0, green: 1, blue: 0.5 }</code></pre>
2177
2374
  <div class="button run">Run</div>
2178
2375
  </div>
2179
2376
 
2180
- <script type="text/paperscript" canvas="canvas-17">
2377
+ <script type="text/paperscript" canvas="canvas-19">
2181
2378
  var circle = new Path.Circle(view.center, 50);
2182
2379
  // Set a random color as circle fill color.
2183
2380
  circle.fillColor = Color.random();
2184
2381
  </script>
2185
- <div class="canvas"><canvas width="516" height="100" id="canvas-17"></canvas></div>
2382
+ <div class="canvas"><canvas width="516" height="100" id="canvas-19"></canvas></div>
2186
2383
  </div>
2187
2384
 
2188
2385
 
@@ -2196,7 +2393,7 @@ circle.fillColor = Color.random();
2196
2393
 
2197
2394
  <!-- =========================== copyright notice ========================== -->
2198
2395
  <p class="footer">
2199
- Paper.js v0.15.0<br>
2396
+ Paper.js v0.17.0<br>
2200
2397
  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>
2201
2398
  <div class="content-end"></div>
2202
2399