paper 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +252 -0
  2. package/README.md +3 -1
  3. package/dist/docs/assets/js/paper.js +6997 -1658
  4. package/dist/docs/classes/AreaText.html +8658 -0
  5. package/dist/docs/classes/ChangeFlag.html +2 -1
  6. package/dist/docs/classes/Color.html +2 -1
  7. package/dist/docs/classes/CompoundPath.html +152 -67
  8. package/dist/docs/classes/Curve.html +2 -1
  9. package/dist/docs/classes/CurveLocation.html +2 -1
  10. package/dist/docs/classes/Event.html +5 -4
  11. package/dist/docs/classes/Gradient.html +2 -1
  12. package/dist/docs/classes/GradientStop.html +2 -1
  13. package/dist/docs/classes/Group.html +117 -15
  14. package/dist/docs/classes/HitResult.html +2 -1
  15. package/dist/docs/classes/HostItem.html +80 -15
  16. package/dist/docs/classes/Item.html +137 -15
  17. package/dist/docs/classes/Key.html +2 -1
  18. package/dist/docs/classes/KeyEvent.html +5 -4
  19. package/dist/docs/classes/Layer.html +114 -15
  20. package/dist/docs/classes/Matrix.html +2 -1
  21. package/dist/docs/classes/MouseEvent.html +5 -4
  22. package/dist/docs/classes/PaperScope.html +4 -2
  23. package/dist/docs/classes/PaperScript.html +5 -2
  24. package/dist/docs/classes/Path.html +126 -67
  25. package/dist/docs/classes/PathItem.html +270 -185
  26. package/dist/docs/classes/PathText.html +8528 -0
  27. package/dist/docs/classes/Point.html +13 -2
  28. package/dist/docs/classes/PointText.html +1346 -59
  29. package/dist/docs/classes/Project.html +40 -7
  30. package/dist/docs/classes/Raster.html +80 -15
  31. package/dist/docs/classes/Rectangle.html +3 -2
  32. package/dist/docs/classes/Segment.html +2 -1
  33. package/dist/docs/classes/Shape.html +80 -15
  34. package/dist/docs/classes/Size.html +4 -2
  35. package/dist/docs/classes/Style.html +767 -14
  36. package/dist/docs/classes/SymbolDefinition.html +2 -1
  37. package/dist/docs/classes/SymbolItem.html +80 -15
  38. package/dist/docs/classes/TextItem.html +1469 -179
  39. package/dist/docs/classes/TextRange.html +186 -0
  40. package/dist/docs/classes/TextStory.html +355 -0
  41. package/dist/docs/classes/Tool.html +2 -1
  42. package/dist/docs/classes/ToolEvent.html +57 -4
  43. package/dist/docs/classes/Tween.html +17 -1
  44. package/dist/docs/classes/View.html +9 -8
  45. package/dist/docs/classes/global.html +2 -1
  46. package/dist/docs/classes/index.html +2 -2
  47. package/dist/docs/index.html +1 -1
  48. package/dist/paper-core.js +6832 -1637
  49. package/dist/paper-core.min.js +3 -3
  50. package/dist/paper-full.js +6997 -1658
  51. package/dist/paper-full.min.js +3 -3
  52. package/dist/{paper-sourced.js → paper-hosted.js} +7109 -1682
  53. package/dist/paper.d.ts +1727 -163
  54. package/examples/Scripts/AreaText.html +65 -0
  55. package/examples/Scripts/PathText.html +48 -0
  56. package/examples/Scripts/TextRanges.html +51 -0
  57. package/package.json +3 -2
package/dist/paper.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Paper.js v0.14.0 - The Swiss Army Knife of Vector Graphics Scripting.
2
+ * Paper.js v0.15.0 - The Swiss Army Knife of Vector Graphics Scripting.
3
3
  * http://paperjs.org/
4
4
  *
5
5
  * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * All rights reserved.
11
11
  *
12
- * Date: Tue Oct 20 01:20:31 2026 +0200
12
+ * Date: Wed Oct 21 15:44:40 2026 +0200
13
13
  *
14
14
  * This is an auto-generated type definition.
15
15
  */
@@ -22,6 +22,7 @@ declare namespace paper {
22
22
  | { x: number, y: number }
23
23
  | { width: number, height: number }
24
24
  | { angle: number, length: number }
25
+ | { angleInRadians: number, length: number }
25
26
  )
26
27
 
27
28
  type SizeLike = (
@@ -38,6 +39,103 @@ declare namespace paper {
38
39
  | { from: PointLike, to: PointLike }
39
40
  )
40
41
 
42
+ type ColorLike = (
43
+ Color
44
+ | string
45
+ | number[]
46
+ | { red: number, green: number, blue: number, alpha?: number }
47
+ | { gray: number, alpha?: number }
48
+ | { hue: number, saturation: number, brightness: number, alpha?: number }
49
+ | { hue: number, saturation: number, lightness: number, alpha?: number }
50
+ | {
51
+ gradient: Gradient | { stops: GradientStopLike[], radial?: boolean },
52
+ origin: PointLike,
53
+ destination: PointLike,
54
+ highlight?: PointLike
55
+ }
56
+ | {
57
+ stops: GradientStopLike[],
58
+ radial?: boolean,
59
+ origin: PointLike,
60
+ destination: PointLike,
61
+ highlight?: PointLike
62
+ }
63
+ )
64
+
65
+ type GradientStopLike = GradientStop | ColorLike | [ ColorLike, number ]
66
+
67
+ /**
68
+ * An AreaText item represents text that flows inside an area, its
69
+ * {@link #textPath}: any path, with holes too, divided into
70
+ * {@link #columns} and {@link #rows}. Its lines break between words to fit
71
+ * the area's width where they sit. What doesn't fit flows on into the next
72
+ * linked text item.
73
+ */
74
+ class AreaText extends TextItem {
75
+ /**
76
+ * The number of columns that the area is divided into, from left to
77
+ * right, which the text fills one after the other.
78
+ */
79
+ columns: number
80
+
81
+ /**
82
+ * The number of rows that the area is divided into, from top to bottom,
83
+ * each with its columns.
84
+ */
85
+ rows: number
86
+
87
+ /**
88
+ * The space between the columns and between the rows.
89
+ */
90
+ gutter: number
91
+
92
+ /**
93
+ * The space between the area's edges and the text.
94
+ */
95
+ inset: number
96
+
97
+ /**
98
+ * Where the lines sit in each column, from top to bottom.
99
+ */
100
+ verticalAlign: string
101
+
102
+
103
+ /**
104
+ * Creates a text item that flows inside an area.
105
+ *
106
+ * @param area - the path that the text flows inside
107
+ * @param orientation - the orientation of the text
108
+ */
109
+ constructor(area: PathItem, orientation?: string)
110
+
111
+ /**
112
+ * Creates a text item that flows inside a rectangle.
113
+ *
114
+ * @param rectangle - the rectangle that the text flows inside
115
+ * @param orientation - the orientation of the text
116
+ */
117
+ constructor(rectangle: RectangleLike, orientation?: string)
118
+
119
+ /**
120
+ * Creates a text item that flows inside an area, from the properties
121
+ * described by an object literal.
122
+ *
123
+ * @param object - an object containing properties describing the
124
+ * text's attributes
125
+ */
126
+ constructor(object: object)
127
+
128
+ /**
129
+ * Sets the area's height to the smallest that holds all of its text,
130
+ * scaling its {@link #textPath} vertically from its top. An area without
131
+ * a height, which holds nothing, becomes a rectangle as wide as it.
132
+ *
133
+ * @return this area text
134
+ */
135
+ fitHeight(): AreaText
136
+
137
+ }
138
+
41
139
 
42
140
  class ChangeFlag {
43
141
  /**
@@ -185,7 +283,8 @@ declare namespace paper {
185
283
  /**
186
284
  * The highlight point of the gradient.
187
285
  */
188
- highlight: Point
286
+ get highlight(): Point
287
+ set highlight(value: PointLike)
189
288
 
190
289
 
191
290
  /**
@@ -529,22 +628,26 @@ declare namespace paper {
529
628
  /**
530
629
  * The first anchor point of the curve.
531
630
  */
532
- point1: Point
631
+ get point1(): Point
632
+ set point1(value: PointLike)
533
633
 
534
634
  /**
535
635
  * The second anchor point of the curve.
536
636
  */
537
- point2: Point
637
+ get point2(): Point
638
+ set point2(value: PointLike)
538
639
 
539
640
  /**
540
641
  * The handle point that describes the tangent in the first anchor point.
541
642
  */
542
- handle1: Point
643
+ get handle1(): Point
644
+ set handle1(value: PointLike)
543
645
 
544
646
  /**
545
647
  * The handle point that describes the tangent in the second anchor point.
546
648
  */
547
- handle2: Point
649
+ get handle2(): Point
650
+ set handle2(value: PointLike)
548
651
 
549
652
  /**
550
653
  * The first segment of the curve.
@@ -614,12 +717,14 @@ declare namespace paper {
614
717
  /**
615
718
  * The bounding rectangle of the curve excluding stroke width.
616
719
  */
617
- bounds: Rectangle
720
+ get bounds(): Rectangle
721
+ set bounds(value: RectangleLike)
618
722
 
619
723
  /**
620
724
  * The bounding rectangle of the curve including stroke width.
621
725
  */
622
- strokeBounds: Rectangle
726
+ get strokeBounds(): Rectangle
727
+ set strokeBounds(value: RectangleLike)
623
728
 
624
729
  /**
625
730
  * The bounding rectangle of the curve including handles.
@@ -754,6 +859,18 @@ declare namespace paper {
754
859
  */
755
860
  splitAtTime(time: number): Path
756
861
 
862
+ /**
863
+ * @deprecated use use {@link #divideAt} or
864
+ * {@link #divideAtTime} instead.
865
+ */
866
+ divide(offset?: number, isTime?: boolean): Curve
867
+
868
+ /**
869
+ * @deprecated use use {@link #splitAt} or
870
+ * {@link #splitAtTime} instead.
871
+ */
872
+ split(offset?: number, isTime?: boolean): Path
873
+
757
874
  /**
758
875
  * Returns a reversed version of the curve, without modifying the curve
759
876
  * itself.
@@ -870,6 +987,11 @@ declare namespace paper {
870
987
  */
871
988
  getTimeAt(offset: number, start?: number): number
872
989
 
990
+ /**
991
+ * @deprecated use use {@link #getTimeAt} instead.
992
+ */
993
+ getParameterAt(offset: number, start?: number): number
994
+
873
995
  /**
874
996
  * Calculates the curve-time parameters where the curve is tangential to
875
997
  * provided tangent. Note that tangents at the start or end are included.
@@ -881,6 +1003,17 @@ declare namespace paper {
881
1003
  */
882
1004
  getTimesWithTangent(tangent: PointLike): number[]
883
1005
 
1006
+ /**
1007
+ * Calculates the curve-time parameters where the curve is tangential to
1008
+ * provided tangent. Note that tangents at the start or end are included.
1009
+ *
1010
+ * @param tangent - the tangent to which the curve must be tangential
1011
+ *
1012
+ * @return at most two curve-time parameters, where the curve is
1013
+ * tangential to the given tangent
1014
+ */
1015
+ getTimesWithTangent(x: number, y: number): number[]
1016
+
884
1017
  /**
885
1018
  * Calculates the curve offset at the specified curve-time parameter on
886
1019
  * the curve.
@@ -901,6 +1034,16 @@ declare namespace paper {
901
1034
  */
902
1035
  getLocationOf(point: PointLike): CurveLocation | null
903
1036
 
1037
+ /**
1038
+ * Returns the curve location of the specified point if it lies on the
1039
+ * curve, `null` otherwise.
1040
+ *
1041
+ * @param point - the point on the curve
1042
+ *
1043
+ * @return the curve location of the specified point
1044
+ */
1045
+ getLocationOf(x: number, y: number): CurveLocation | null
1046
+
904
1047
  /**
905
1048
  * Returns the length of the path from its beginning up to up to the
906
1049
  * specified point if it lies on the path, `null` otherwise.
@@ -911,6 +1054,16 @@ declare namespace paper {
911
1054
  */
912
1055
  getOffsetOf(point: PointLike): number | null
913
1056
 
1057
+ /**
1058
+ * Returns the length of the path from its beginning up to up to the
1059
+ * specified point if it lies on the path, `null` otherwise.
1060
+ *
1061
+ * @param point - the point on the path
1062
+ *
1063
+ * @return the length of the path up to the specified point
1064
+ */
1065
+ getOffsetOf(x: number, y: number): number | null
1066
+
914
1067
  /**
915
1068
  * Returns the curve-time parameter of the specified point if it lies on the
916
1069
  * curve, `null` otherwise.
@@ -923,6 +1076,28 @@ declare namespace paper {
923
1076
  */
924
1077
  getTimeOf(point: PointLike): number | null
925
1078
 
1079
+ /**
1080
+ * Returns the curve-time parameter of the specified point if it lies on the
1081
+ * curve, `null` otherwise.
1082
+ * Note that if there is more than one possible solution in a
1083
+ * self-intersecting curve, the first found result is returned.
1084
+ *
1085
+ * @param point - the point on the curve
1086
+ *
1087
+ * @return the curve-time parameter of the specified point
1088
+ */
1089
+ getTimeOf(x: number, y: number): number | null
1090
+
1091
+ /**
1092
+ * @deprecated use use {@link #getTimeOf} instead.
1093
+ */
1094
+ getParameterOf(point: PointLike): number
1095
+
1096
+ /**
1097
+ * @deprecated use use {@link #getTimeOf} instead.
1098
+ */
1099
+ getParameterOf(x: number, y: number): number
1100
+
926
1101
  /**
927
1102
  * Returns the nearest location on the curve to the specified point.
928
1103
  *
@@ -933,6 +1108,16 @@ declare namespace paper {
933
1108
  */
934
1109
  getNearestLocation(point: PointLike): CurveLocation
935
1110
 
1111
+ /**
1112
+ * Returns the nearest location on the curve to the specified point.
1113
+ *
1114
+ * @param point - the point for which we search the nearest location
1115
+ *
1116
+ * @return the location on the curve that's the closest to
1117
+ * the specified point
1118
+ */
1119
+ getNearestLocation(x: number, y: number): CurveLocation
1120
+
936
1121
  /**
937
1122
  * Returns the nearest point on the curve to the specified point.
938
1123
  *
@@ -943,6 +1128,16 @@ declare namespace paper {
943
1128
  */
944
1129
  getNearestPoint(point: PointLike): Point
945
1130
 
1131
+ /**
1132
+ * Returns the nearest point on the curve to the specified point.
1133
+ *
1134
+ * @param point - the point for which we search the nearest point
1135
+ *
1136
+ * @return the point on the curve that's the closest to the
1137
+ * specified point
1138
+ */
1139
+ getNearestPoint(x: number, y: number): Point
1140
+
946
1141
  /**
947
1142
  * Calculates the point on the curve at the given location.
948
1143
  *
@@ -1127,6 +1322,11 @@ declare namespace paper {
1127
1322
  */
1128
1323
  readonly time: number
1129
1324
 
1325
+ /**
1326
+ * @deprecated use {@link #time} instead.
1327
+ */
1328
+ readonly parameter: number
1329
+
1130
1330
  /**
1131
1331
  * The point which is defined by the {@link #curve} and
1132
1332
  * {@link #time}.
@@ -1238,7 +1438,18 @@ declare namespace paper {
1238
1438
  */
1239
1439
  class Event {
1240
1440
  /**
1241
- * The time at which the event was created, in milliseconds since the epoch.
1441
+ * The time at which the event was created, in seconds, as the times of
1442
+ * frame events are. Browsers count from the page's time origin, as
1443
+ * `performance.now()` does, while
1444
+ * {@link View#dispatchMouseEvent} and
1445
+ * {@link View#dispatchKeyEvent} use `Date.now()`
1446
+ * unless the host passes a time, so only compare the times of events from
1447
+ * the same source.
1448
+ */
1449
+ readonly time: number
1450
+
1451
+ /**
1452
+ * @deprecated use {@link #time} instead, which is in seconds.
1242
1453
  */
1243
1454
  readonly timeStamp: number
1244
1455
 
@@ -1311,10 +1522,16 @@ declare namespace paper {
1311
1522
  */
1312
1523
  offset: number
1313
1524
 
1525
+ /**
1526
+ * @deprecated use {@link #offset} instead.
1527
+ */
1528
+ rampPoint: number
1529
+
1314
1530
  /**
1315
1531
  * The color of the gradient stop.
1316
1532
  */
1317
- color: Color
1533
+ get color(): Color
1534
+ set color(value: ColorLike)
1318
1535
 
1319
1536
 
1320
1537
  /**
@@ -1374,6 +1591,14 @@ declare namespace paper {
1374
1591
  */
1375
1592
  constructor(object: object)
1376
1593
 
1594
+ /**
1595
+ * Replaces the group with its children, which keep their appearance: the
1596
+ * group's matrix is applied to them, and its clipping mask is released.
1597
+ *
1598
+ * @return the children, or `null` if the group has no parent
1599
+ */
1600
+ ungroup(): Item[]
1601
+
1377
1602
  }
1378
1603
 
1379
1604
  /**
@@ -1417,7 +1642,8 @@ declare namespace paper {
1417
1642
  * If the HitResult has a type of 'pixel', this property refers to the color
1418
1643
  * of the pixel on the {@link Raster} that was hit.
1419
1644
  */
1420
- color: Color | null
1645
+ get color(): Color | null
1646
+ set color(value: ColorLike | null)
1421
1647
 
1422
1648
  /**
1423
1649
  * If the HitResult has a type of 'stroke', 'segment', 'handle-in' or
@@ -1430,7 +1656,8 @@ declare namespace paper {
1430
1656
  * Describes the actual coordinates of the segment, handle or bounding box
1431
1657
  * corner that was hit.
1432
1658
  */
1433
- point: Point
1659
+ get point(): Point
1660
+ set point(value: PointLike)
1434
1661
 
1435
1662
 
1436
1663
  }
@@ -1457,7 +1684,7 @@ declare namespace paper {
1457
1684
  class Item {
1458
1685
  /**
1459
1686
  * The key of the host's node that the item represents, in a project
1460
- * backed by a host document, see {@link Project#source}. It can only be
1687
+ * backed by a host document, see {@link Project#host}. It can only be
1461
1688
  * set once, on an item created by a script, to register the key that
1462
1689
  * the host gave its new node.
1463
1690
  */
@@ -1503,8 +1730,10 @@ declare namespace paper {
1503
1730
  /**
1504
1731
  * The blend mode with which the item is composited onto the canvas. Both
1505
1732
  * the standard canvas compositing modes, as well as the new CSS blend modes
1506
- * are supported. If blend-modes cannot be rendered natively, they are
1507
- * emulated. Be aware that emulation can have an impact on performance.
1733
+ * are supported. Where the canvas doesn't support a CSS blend mode
1734
+ * natively, it draws as `'normal'`. Paper.js's own modes `'add'`,
1735
+ * `'subtract'`, `'average'`, `'pin-light'` and `'negation'` are emulated,
1736
+ * which can have an impact on performance.
1508
1737
  */
1509
1738
  blendMode: string
1510
1739
 
@@ -1521,6 +1750,14 @@ declare namespace paper {
1521
1750
  */
1522
1751
  guide: boolean
1523
1752
 
1753
+ /**
1754
+ * Specifies whether, and how, the item pushes aside the text of the
1755
+ * {@link AreaText} items below it in its layer: `null`, or an object with
1756
+ * `offset`, the space kept between them, and `invert`, to let the text
1757
+ * flow inside it instead. `true` sets the defaults.
1758
+ */
1759
+ textWrap: any
1760
+
1524
1761
  /**
1525
1762
  * Specifies whether the item is selected. This will also return `true` for
1526
1763
  * {@link Group} items if they are partially selected, e.g. groups
@@ -1538,6 +1775,12 @@ declare namespace paper {
1538
1775
  */
1539
1776
  selected: boolean
1540
1777
 
1778
+ /**
1779
+ * Specifies whether the item and all its descendants are selected. Setting
1780
+ * it selects or deselects them all.
1781
+ */
1782
+ fullySelected: boolean
1783
+
1541
1784
  /**
1542
1785
  * Specifies whether the item defines a clip mask. This can only be set on
1543
1786
  * paths and compound paths, and only if the item is already contained
@@ -1556,7 +1799,8 @@ declare namespace paper {
1556
1799
  * default, this is the {@link Rectangle#center} of the item's
1557
1800
  * {@link #bounds} rectangle.
1558
1801
  */
1559
- position: Point
1802
+ get position(): Point
1803
+ set position(value: PointLike)
1560
1804
 
1561
1805
  /**
1562
1806
  * The item's pivot point specified in the item coordinate system, defining
@@ -1565,22 +1809,31 @@ declare namespace paper {
1565
1809
  * meaning the {@link Rectangle#center} of the item's {@link #bounds}
1566
1810
  * rectangle is used as pivot.
1567
1811
  */
1568
- pivot: Point
1812
+ get pivot(): Point
1813
+ set pivot(value: PointLike)
1569
1814
 
1570
1815
  /**
1571
1816
  * The bounding rectangle of the item excluding stroke width.
1572
1817
  */
1573
- bounds: Rectangle
1818
+ get bounds(): Rectangle
1819
+ set bounds(value: RectangleLike)
1574
1820
 
1575
1821
  /**
1576
1822
  * The bounding rectangle of the item including stroke width.
1823
+ *
1824
+ * Setting it fits the item's {@link #bounds} into the given rectangle minus
1825
+ * the extent of the stroke on each side, also where this extent changes
1826
+ * with the item's proportions, as with miters. A rectangle smaller than the
1827
+ * stroke itself shrinks the bounds to its center.
1577
1828
  */
1578
- strokeBounds: Rectangle
1829
+ get strokeBounds(): Rectangle
1830
+ set strokeBounds(value: RectangleLike)
1579
1831
 
1580
1832
  /**
1581
1833
  * The bounding rectangle of the item including handles.
1582
1834
  */
1583
- handleBounds: Rectangle
1835
+ get handleBounds(): Rectangle
1836
+ set handleBounds(value: RectangleLike)
1584
1837
 
1585
1838
  /**
1586
1839
  * The bounding rectangle of the item without any matrix transformations.
@@ -1589,7 +1842,8 @@ declare namespace paper {
1589
1842
  * want to draw something of the same size, position, rotation, and scaling,
1590
1843
  * like a selection frame.
1591
1844
  */
1592
- internalBounds: Rectangle
1845
+ get internalBounds(): Rectangle
1846
+ set internalBounds(value: RectangleLike)
1593
1847
 
1594
1848
  /**
1595
1849
  * The current rotation angle of the item, as described by its
@@ -1607,7 +1861,8 @@ declare namespace paper {
1607
1861
  * {@link #applyMatrix} set to `false`, meaning they do not directly bake
1608
1862
  * transformations into their content.
1609
1863
  */
1610
- scaling: Point
1864
+ get scaling(): Point
1865
+ set scaling(value: PointLike)
1611
1866
 
1612
1867
  /**
1613
1868
  * The item's transformation matrix, defining position and dimensions in
@@ -1639,6 +1894,11 @@ declare namespace paper {
1639
1894
  */
1640
1895
  applyMatrix: boolean
1641
1896
 
1897
+ /**
1898
+ * @deprecated use {@link #applyMatrix} instead.
1899
+ */
1900
+ transformContent: boolean
1901
+
1642
1902
  /**
1643
1903
  * The project that this item belongs to.
1644
1904
  */
@@ -1711,7 +1971,8 @@ declare namespace paper {
1711
1971
  /**
1712
1972
  * The color of the stroke.
1713
1973
  */
1714
- strokeColor: Color | null
1974
+ get strokeColor(): Color | null
1975
+ set strokeColor(value: ColorLike | null)
1715
1976
 
1716
1977
  /**
1717
1978
  * The width of the stroke.
@@ -1762,7 +2023,8 @@ declare namespace paper {
1762
2023
  /**
1763
2024
  * The fill color of the item.
1764
2025
  */
1765
- fillColor: Color | null
2026
+ get fillColor(): Color | null
2027
+ set fillColor(value: ColorLike | null)
1766
2028
 
1767
2029
  /**
1768
2030
  * The fill-rule with which the shape gets filled. Please note that only
@@ -1773,7 +2035,8 @@ declare namespace paper {
1773
2035
  /**
1774
2036
  * The shadow color.
1775
2037
  */
1776
- shadowColor: Color | null
2038
+ get shadowColor(): Color | null
2039
+ set shadowColor(value: ColorLike | null)
1777
2040
 
1778
2041
  /**
1779
2042
  * The shadow's blur radius.
@@ -1783,13 +2046,15 @@ declare namespace paper {
1783
2046
  /**
1784
2047
  * The shadow's offset.
1785
2048
  */
1786
- shadowOffset: Point
2049
+ get shadowOffset(): Point
2050
+ set shadowOffset(value: PointLike)
1787
2051
 
1788
2052
  /**
1789
2053
  * The color the item is highlighted with when selected. If the item does
1790
2054
  * not specify its own color, the color defined by its layer is used instead.
1791
2055
  */
1792
- selectedColor: Color | null
2056
+ get selectedColor(): Color | null
2057
+ set selectedColor(value: ColorLike | null)
1793
2058
 
1794
2059
  /**
1795
2060
  * Item level handler function to be called on each frame of an animation.
@@ -1914,6 +2179,24 @@ declare namespace paper {
1914
2179
  */
1915
2180
  set(props: object): this
1916
2181
 
2182
+ /**
2183
+ * Returns the bounds of the given items in project coordinates, as if
2184
+ * they were grouped, without moving them, e.g. the bounds of the
2185
+ * selection: `Item.getBounds(project.selectedItems)`. As in groups,
2186
+ * items that aren't visible or are empty are left out.
2187
+ *
2188
+ * @option [options.stroke=false] {Boolean} include the stroke widths,
2189
+ * as {@link Item#strokeBounds} does
2190
+ * @option [options.handle=false] {Boolean} include the handles, as
2191
+ * {@link Item#handleBounds} does
2192
+ *
2193
+ * @param items - the items to get the bounds of
2194
+ * @param options - the kind of bounds
2195
+ *
2196
+ * @return the bounds of the items, empty if there are none
2197
+ */
2198
+ static getBounds(items: Item[], options?: { stroke?: boolean, handle?: boolean }): Rectangle
2199
+
1917
2200
  /**
1918
2201
  * Clones the item within the same project and places the copy above the
1919
2202
  * item.
@@ -1946,27 +2229,32 @@ declare namespace paper {
1946
2229
  */
1947
2230
  copyAttributes(source: Item, excludeMatrix: boolean): void
1948
2231
 
2232
+ /**
2233
+ * @deprecated use {@link #rasterize} instead.
2234
+ */
2235
+ rasterize(resolution?: number, insert?: boolean): Raster
2236
+
1949
2237
  /**
1950
2238
  * Rasterizes the item into a newly created Raster object. The item itself
1951
2239
  * is not removed after rasterization.
1952
2240
  *
1953
- * @option [resolution=view.resolution] {Number} the desired resolution to
1954
- * be used when rasterizing, in pixels per inch (DPI). If not specified,
1955
- * the value of `view.resolution` is used by default.
1956
- * @option [raster=null] {Raster} specifies a raster to be reused when
1957
- * rasterizing. If the raster has the desired size already, then the
2241
+ * @option [options.resolution=view.resolution] {Number} the desired
2242
+ * resolution to be used when rasterizing, in pixels per inch (DPI). If
2243
+ * not specified, the value of `view.resolution` is used by default.
2244
+ * @option [options.raster=null] {Raster} specifies a raster to be reused
2245
+ * when rasterizing. If the raster has the desired size already, then the
1958
2246
  * underlying canvas is reused and no new memory needs to be allocated.
1959
2247
  * If no raster is provided, a new raster item is created and returned
1960
2248
  * instead.
1961
- * @option [insert=true] {Boolean} specifies whether the raster should be
1962
- * inserted into the scene graph. When set to `true`, it is inserted
1963
- * above the rasterized item.
2249
+ * @option [options.insert=true] {Boolean} specifies whether the raster
2250
+ * should be inserted into the scene graph. When set to `true`, it is
2251
+ * inserted above the rasterized item.
1964
2252
  *
1965
2253
  * @param options - the rasterization options
1966
2254
  *
1967
2255
  * @return the reused raster or the newly created raster item
1968
2256
  */
1969
- rasterize(options?: object): Raster
2257
+ rasterize(options?: { resolution?: number, raster?: Raster, insert?: boolean }): Raster
1970
2258
 
1971
2259
  /**
1972
2260
  * Checks whether the item's geometry contains the given point.
@@ -1975,13 +2263,28 @@ declare namespace paper {
1975
2263
  */
1976
2264
  contains(point: PointLike): boolean
1977
2265
 
2266
+ /**
2267
+ * Checks whether the item's geometry contains the given point.
2268
+ *
2269
+ * @param point - the point to check for
2270
+ */
2271
+ contains(x: number, y: number): boolean
2272
+
1978
2273
  /**
1979
2274
  * @param rect - the rectangle to check against
1980
2275
  */
1981
2276
  isInside(rect: RectangleLike): boolean
1982
2277
 
1983
2278
  /**
2279
+ * Checks whether the item overlaps with the given item: whether their
2280
+ * outlines cross, or one contains the other, as
2281
+ * {@link Rectangle#intersects} does for rectangles. Items other than
2282
+ * paths and shapes are checked through their bounds. To only check whether
2283
+ * outlines cross, use {@link PathItem#getIntersections}.
2284
+ *
1984
2285
  * @param item - the item to check against
2286
+ *
2287
+ * @return true if the items overlap
1985
2288
  */
1986
2289
  intersects(item: Item): boolean
1987
2290
 
@@ -2032,7 +2335,7 @@ declare namespace paper {
2032
2335
  * @return a hit result object describing what exactly was hit
2033
2336
  * or `null` if nothing was hit
2034
2337
  */
2035
- hitTest(point: PointLike, options?: object): HitResult
2338
+ hitTest(point: PointLike, options?: { tolerance?: number, class?: Function, match?: Function, fill?: boolean, stroke?: boolean, segments?: boolean, curves?: boolean, handles?: boolean, ends?: boolean, position?: boolean, center?: boolean, bounds?: boolean, guides?: boolean, selected?: boolean }): HitResult
2036
2339
 
2037
2340
  /**
2038
2341
  * Performs a hit-test on the item and its children (if it is a {@link
@@ -2050,7 +2353,7 @@ declare namespace paper {
2050
2353
  * @return hit result objects for all hits, describing what
2051
2354
  * exactly was hit or `null` if nothing was hit
2052
2355
  */
2053
- hitTestAll(point: PointLike, options?: object): HitResult[]
2356
+ hitTestAll(point: PointLike, options?: { tolerance?: number, class?: Function, match?: Function, fill?: boolean, stroke?: boolean, segments?: boolean, curves?: boolean, handles?: boolean, ends?: boolean, position?: boolean, center?: boolean, bounds?: boolean, guides?: boolean, selected?: boolean }): HitResult[]
2054
2357
 
2055
2358
  /**
2056
2359
  * Checks whether the item matches the criteria described by the given
@@ -2160,7 +2463,7 @@ declare namespace paper {
2160
2463
  *
2161
2464
  * @return the exported JSON data
2162
2465
  */
2163
- exportJSON(options?: object): string
2466
+ exportJSON(options?: { asString?: boolean, precision?: number }): string
2164
2467
 
2165
2468
  /**
2166
2469
  * Imports (deserializes) the stored JSON data into this item. If the data
@@ -2209,7 +2512,7 @@ declare namespace paper {
2209
2512
  * @return the item converted to an SVG node or a
2210
2513
  * `String` depending on `option.asString` value
2211
2514
  */
2212
- exportSVG(options?: object): SVGElement | string
2515
+ exportSVG(options?: { bounds?: string | RectangleLike, matrix?: Matrix, asString?: boolean, precision?: number, matchShapes?: boolean, embedImages?: boolean, reuseImages?: boolean, idPrefix?: string, reduceAttributes?: boolean }): SVGElement | string
2213
2516
 
2214
2517
  /**
2215
2518
  * Converts the provided SVG content into Paper.js items and adds them to
@@ -2220,6 +2523,10 @@ declare namespace paper {
2220
2523
  * the `<use>` elements that place them as {@link SymbolItem} items. The
2221
2524
  * styles that `<use>` elements inherit don't reach the symbols' content.
2222
2525
  *
2526
+ * URLs are fetched as they are, so validate URLs that come from untrusted
2527
+ * sources first, especially on servers, where they could reach internal
2528
+ * addresses.
2529
+ *
2223
2530
  * @option [options.expandShapes=false] {Boolean} whether imported shape
2224
2531
  * items should be expanded to path items
2225
2532
  * @option [options.crossOrigin] {String} the {@link Raster#crossOrigin}
@@ -2246,7 +2553,7 @@ declare namespace paper {
2246
2553
  * @return the newly created Paper.js item containing the converted
2247
2554
  * SVG content
2248
2555
  */
2249
- importSVG(svg: SVGElement | string, options?: object): Item
2556
+ importSVG(svg: SVGElement | string, options?: { expandShapes?: boolean, crossOrigin?: string, onLoad?: Function, onError?: Function, insert?: boolean, applyMatrix?: boolean }): Item
2250
2557
 
2251
2558
  /**
2252
2559
  * Imports the provided external SVG file, converts it into Paper.js items
@@ -2338,6 +2645,50 @@ declare namespace paper {
2338
2645
  */
2339
2646
  bringToFront(): void
2340
2647
 
2648
+ /**
2649
+ * Inserts the specified item as a child of this item by appending it to
2650
+ * the list of children and moving it above all other children. You can
2651
+ * use this function for groups, compound paths and layers.
2652
+ *
2653
+ * @param item - the item to be appended as a child
2654
+ *
2655
+ * @deprecated use {@link #addChild} instead.
2656
+ */
2657
+ appendTop(item: Item): Item
2658
+
2659
+ /**
2660
+ * Inserts the specified item as a child of this item by appending it to
2661
+ * the list of children and moving it below all other children. You can
2662
+ * use this function for groups, compound paths and layers.
2663
+ *
2664
+ * @param item - the item to be appended as a child
2665
+ *
2666
+ * @deprecated use {@link #insertChild} instead.
2667
+ */
2668
+ appendBottom(item: Item): Item
2669
+
2670
+ /**
2671
+ * Moves this item above the specified item.
2672
+ *
2673
+ * @param item - the item above which it should be moved
2674
+ *
2675
+ * @deprecated use {@link #insertAbove} instead.
2676
+ *
2677
+ * @return true if it was moved
2678
+ */
2679
+ moveAbove(item: Item): boolean
2680
+
2681
+ /**
2682
+ * Moves the item below the specified item.
2683
+ *
2684
+ * @param item - the item below which it should be moved
2685
+ *
2686
+ * @deprecated use {@link #insertBelow} instead.
2687
+ *
2688
+ * @return true if it was moved
2689
+ */
2690
+ moveBelow(item: Item): boolean
2691
+
2341
2692
  /**
2342
2693
  * Adds it to the specified owner, which can be either a {@link Item} or a
2343
2694
  * {@link Project}.
@@ -2381,14 +2732,16 @@ declare namespace paper {
2381
2732
  remove(): boolean
2382
2733
 
2383
2734
  /**
2384
- * Replaces this item with the provided new item which will takes its place
2385
- * in the project hierarchy instead.
2735
+ * Replaces this item with the provided new items which will take its place
2736
+ * in the project hierarchy instead, in the given order. This also ungroups
2737
+ * a group, e.g. `group.replaceWith(...group.children)`, but note that the
2738
+ * items keep their own matrices, see {@link Group#ungroup}.
2386
2739
  *
2387
- * @param item - the item that will replace this item
2740
+ * @param item - the items that will replace this item
2388
2741
  *
2389
2742
  * @return true if the item was replaced
2390
2743
  */
2391
- replaceWith(item: Item): boolean
2744
+ replaceWith(...item: Item[]): boolean
2392
2745
 
2393
2746
  /**
2394
2747
  * Removes all of the item's {@link #children} (if any).
@@ -2543,6 +2896,13 @@ declare namespace paper {
2543
2896
  */
2544
2897
  translate(delta: PointLike): void
2545
2898
 
2899
+ /**
2900
+ * Translates (moves) the item by the given offset views.
2901
+ *
2902
+ * @param delta - the offset to translate the item by
2903
+ */
2904
+ translate(x: number, y: number): void
2905
+
2546
2906
  /**
2547
2907
  * Rotates the item by a given angle around the given center point.
2548
2908
  *
@@ -2630,6 +2990,16 @@ declare namespace paper {
2630
2990
  */
2631
2991
  globalToLocal(point: PointLike): Point
2632
2992
 
2993
+ /**
2994
+ * Converts the specified point from global project coordinate space to the
2995
+ * item's own local coordinate space.
2996
+ *
2997
+ * @param point - the point to be transformed
2998
+ *
2999
+ * @return the transformed point as a new instance
3000
+ */
3001
+ globalToLocal(x: number, y: number): Point
3002
+
2633
3003
  /**
2634
3004
  * Converts the specified point from the item's own local coordinate space
2635
3005
  * to the global project coordinate space.
@@ -2640,6 +3010,16 @@ declare namespace paper {
2640
3010
  */
2641
3011
  localToGlobal(point: PointLike): Point
2642
3012
 
3013
+ /**
3014
+ * Converts the specified point from the item's own local coordinate space
3015
+ * to the global project coordinate space.
3016
+ *
3017
+ * @param point - the point to be transformed
3018
+ *
3019
+ * @return the transformed point as a new instance
3020
+ */
3021
+ localToGlobal(x: number, y: number): Point
3022
+
2643
3023
  /**
2644
3024
  * Converts the specified point from the parent's coordinate space to
2645
3025
  * item's own local coordinate space.
@@ -2650,6 +3030,16 @@ declare namespace paper {
2650
3030
  */
2651
3031
  parentToLocal(point: PointLike): Point
2652
3032
 
3033
+ /**
3034
+ * Converts the specified point from the parent's coordinate space to
3035
+ * item's own local coordinate space.
3036
+ *
3037
+ * @param point - the point to be transformed
3038
+ *
3039
+ * @return the transformed point as a new instance
3040
+ */
3041
+ parentToLocal(x: number, y: number): Point
3042
+
2653
3043
  /**
2654
3044
  * Converts the specified point from the item's own local coordinate space
2655
3045
  * to the parent's coordinate space.
@@ -2660,6 +3050,16 @@ declare namespace paper {
2660
3050
  */
2661
3051
  localToParent(point: PointLike): Point
2662
3052
 
3053
+ /**
3054
+ * Converts the specified point from the item's own local coordinate space
3055
+ * to the parent's coordinate space.
3056
+ *
3057
+ * @param point - the point to be transformed
3058
+ *
3059
+ * @return the transformed point as a new instance
3060
+ */
3061
+ localToParent(x: number, y: number): Point
3062
+
2663
3063
  /**
2664
3064
  * Transform the item so that its {@link #bounds} are centered in the
2665
3065
  * specified rectangle and fitted to it as described by `fit`.
@@ -2749,16 +3149,16 @@ declare namespace paper {
2749
3149
  * Removes the item when the events specified in the passed options object
2750
3150
  * occur.
2751
3151
  *
2752
- * @option options.move {Boolean) remove the item when the next {@link
3152
+ * @option options.move {Boolean} remove the item when the next {@link
2753
3153
  * Tool#onMouseMove} event is fired.
2754
- * @option options.drag {Boolena) remove the item when the next {@link
3154
+ * @option options.drag {Boolean} remove the item when the next {@link
2755
3155
  * Tool#onMouseDrag} event is fired.
2756
- * @option options.down {Boolean) remove the item when the next {@link
3156
+ * @option options.down {Boolean} remove the item when the next {@link
2757
3157
  * Tool#onMouseDown} event is fired.
2758
- * @option options.up {Boolean) remove the item when the next {@link
3158
+ * @option options.up {Boolean} remove the item when the next {@link
2759
3159
  * Tool#onMouseUp} event is fired.
2760
3160
  */
2761
- removeOn(options: object): void
3161
+ removeOn(options: { move?: boolean, drag?: boolean, down?: boolean, up?: boolean }): void
2762
3162
 
2763
3163
  /**
2764
3164
  * Removes the item when the next {@link Tool#onMouseMove} event is fired.
@@ -3273,6 +3673,21 @@ declare namespace paper {
3273
3673
  */
3274
3674
  inverted(): Matrix
3275
3675
 
3676
+ /**
3677
+ * @deprecated use {@link #append} instead.
3678
+ */
3679
+ concatenate(matrix: Matrix): Matrix
3680
+
3681
+ /**
3682
+ * @deprecated use {@link #prepend} instead.
3683
+ */
3684
+ preConcatenate(matrix: Matrix): Matrix
3685
+
3686
+ /**
3687
+ * @deprecated use {@link #appended} instead.
3688
+ */
3689
+ chain(matrix: Matrix): Matrix
3690
+
3276
3691
  /**
3277
3692
  * @return whether this matrix is the identity matrix
3278
3693
  */
@@ -3303,6 +3718,15 @@ declare namespace paper {
3303
3718
  */
3304
3719
  transform(point: PointLike): Point
3305
3720
 
3721
+ /**
3722
+ * Transforms a point and returns the result.
3723
+ *
3724
+ * @param point - the point to be transformed
3725
+ *
3726
+ * @return the transformed point
3727
+ */
3728
+ transform(x: number, y: number): Point
3729
+
3306
3730
  /**
3307
3731
  * Transforms an array of coordinates by this matrix and stores the results
3308
3732
  * into the destination array, which is also returned.
@@ -3324,6 +3748,13 @@ declare namespace paper {
3324
3748
  */
3325
3749
  inverseTransform(point: PointLike): Point
3326
3750
 
3751
+ /**
3752
+ * Inverse transforms a point and returns the result.
3753
+ *
3754
+ * @param point - the point to be transformed
3755
+ */
3756
+ inverseTransform(x: number, y: number): Point
3757
+
3327
3758
  /**
3328
3759
  * Decomposes the affine transformation described by this matrix into
3329
3760
  * `scaling`, `rotation` and `skewing`, and returns an object with
@@ -3358,7 +3789,8 @@ declare namespace paper {
3358
3789
  * The position of the mouse in project coordinates when the event was
3359
3790
  * fired.
3360
3791
  */
3361
- point: Point
3792
+ get point(): Point
3793
+ set point(value: PointLike)
3362
3794
 
3363
3795
  /**
3364
3796
  * The item that dispatched the event. It is different from
@@ -3376,7 +3808,8 @@ declare namespace paper {
3376
3808
  currentTarget: Item
3377
3809
 
3378
3810
 
3379
- delta: Point
3811
+ get delta(): Point
3812
+ set delta(value: PointLike)
3380
3813
 
3381
3814
 
3382
3815
  /**
@@ -3423,8 +3856,11 @@ declare namespace paper {
3423
3856
  * (Note that not all items can set this to `false`)
3424
3857
  * @option [settings.handleSize=4] {Number} the size of the curve handles
3425
3858
  * when drawing selections
3859
+ * @option [settings.segmentSize=null] {Number} the size of the segments
3860
+ * when drawing selections, or `null` to use `settings.handleSize`, e.g.
3861
+ * with `handleSize: 0` to only draw the segments and not their handles
3426
3862
  * @option [settings.hitTolerance=0] {Number} the default tolerance for hit-
3427
- * tests, when no value is specified
3863
+ * tests, when no value is specified, and for the mouse events of items
3428
3864
  * @option [settings.scaleStrokes=false] {Boolean} controls whether applying
3429
3865
  * a matrix to the content of paths and compound paths also scales their
3430
3866
  * {@link Style#strokeWidth}, by the geometric mean of the scale factors
@@ -3459,6 +3895,7 @@ declare namespace paper {
3459
3895
  */
3460
3896
  tools: Tool[]
3461
3897
 
3898
+ AreaText: typeof AreaText
3462
3899
  ChangeFlag: typeof ChangeFlag
3463
3900
  Color: typeof Color
3464
3901
  CompoundPath: typeof CompoundPath
@@ -3480,6 +3917,7 @@ declare namespace paper {
3480
3917
  PaperScript: typeof PaperScript
3481
3918
  Path: typeof Path
3482
3919
  PathItem: typeof PathItem
3920
+ PathText: typeof PathText
3483
3921
  Point: typeof Point
3484
3922
  PointText: typeof PointText
3485
3923
  Project: typeof Project
@@ -3492,6 +3930,8 @@ declare namespace paper {
3492
3930
  SymbolDefinition: typeof SymbolDefinition
3493
3931
  SymbolItem: typeof SymbolItem
3494
3932
  TextItem: typeof TextItem
3933
+ TextRange: typeof TextRange
3934
+ TextStory: typeof TextStory
3495
3935
  Tool: typeof Tool
3496
3936
  ToolEvent: typeof ToolEvent
3497
3937
  Tween: typeof Tween
@@ -3517,7 +3957,7 @@ declare namespace paper {
3517
3957
  * @param code - the PaperScript code
3518
3958
  * @param options - the compilation options
3519
3959
  */
3520
- execute(code: string, options?: object): void
3960
+ execute(code: string, options?: { url?: string, source?: string }): void
3521
3961
 
3522
3962
  /**
3523
3963
  * Injects the paper scope into any other given scope. Can be used for
@@ -3595,7 +4035,7 @@ declare namespace paper {
3595
4035
  * @return an object holding the compiled PaperScript translated
3596
4036
  * into JavaScript code along with source-maps and other information.
3597
4037
  */
3598
- static compile(code: string, options?: object): object
4038
+ static compile(code: string, options?: { url?: string, source?: string }): object
3599
4039
 
3600
4040
  /**
3601
4041
  * Compiles the PaperScript code into a compiled function and executes it.
@@ -3611,14 +4051,31 @@ declare namespace paper {
3611
4051
  * @option options.handlers {String[]} the names of further global
3612
4052
  * handlers to export next to `onFrame`, `onResize` and the tool's
3613
4053
  * handlers, for hosts that call them themselves
4054
+ * @option options.load {Function} the loader for static `import`
4055
+ * statements, called with the specifier as written and the
4056
+ * `options.url` of the importing script, and returning the module's
4057
+ * exports, e.g. the result of executing it. Modules with ES `export`
4058
+ * statements have their default export as `default` and are marked
4059
+ * with `__esModule`, so `import x` receives the default export, and
4060
+ * for CommonJS-style exports the whole exports. `import * as x`
4061
+ * receives all exports, and for CommonJS-style exports, these as
4062
+ * `default` too. Dynamic `import(specifier)` resolves to that
4063
+ * namespace as a Promise, and its loader may return a Promise as well.
4064
+ * The loader runs each module once and handles cycles. Parsing
4065
+ * `import` requires a current Acorn as `self.acorn`
4066
+ *
4067
+ * Code with top-level `await` runs as an async function. `execute()` then
4068
+ * returns a Promise of the exports, and installs the global handlers once
4069
+ * it resolves. Parsing it requires a current Acorn as `self.acorn`.
3614
4070
  *
3615
4071
  * @param code - the PaperScript code
3616
4072
  * @param scope - the scope for which the code is executed
3617
4073
  * @param options - the compilation options
3618
4074
  *
3619
- * @return the exports defined in the executed code
4075
+ * @return the exports defined in the executed code, or
4076
+ * with top-level `await`, a Promise of them
3620
4077
  */
3621
- static execute(code: string, scope: PaperScope, options?: object): object
4078
+ static execute(code: string, scope: PaperScope, options?: { url?: string, source?: string, handlers?: string[], load?: Function }): object | Promise<any>
3622
4079
 
3623
4080
  /**
3624
4081
  * Loads, compiles and executes PaperScript code in the HTML document. Note
@@ -3848,6 +4305,11 @@ declare namespace paper {
3848
4305
  */
3849
4306
  splitAt(location: number | CurveLocation): Path | null
3850
4307
 
4308
+ /**
4309
+ * @deprecated use use {@link #splitAt} instead.
4310
+ */
4311
+ split(index: number, time?: number): Path
4312
+
3851
4313
  /**
3852
4314
  * Joins the path with the other specified path, which will be removed in
3853
4315
  * the process. They can be joined if the first or last segments of either
@@ -3877,7 +4339,7 @@ declare namespace paper {
3877
4339
  *
3878
4340
  * @return the reduced path
3879
4341
  */
3880
- reduce(options?: object): Path
4342
+ reduce(options?: { simplify?: boolean }): Path
3881
4343
 
3882
4344
  /**
3883
4345
  * Attempts to create a new shape item with same geometry as this path item,
@@ -3905,14 +4367,34 @@ declare namespace paper {
3905
4367
  getLocationOf(point: PointLike): CurveLocation | null
3906
4368
 
3907
4369
  /**
3908
- * Returns the length of the path from its beginning up to up to the
3909
- * specified point if it lies on the path, `null` otherwise.
4370
+ * Returns the curve location of the specified point if it lies on the
4371
+ * path, `null` otherwise.
3910
4372
  *
3911
4373
  * @param point - the point on the path
3912
4374
  *
3913
- * @return the length of the path up to the specified point
4375
+ * @return the curve location of the specified point
3914
4376
  */
3915
- getOffsetOf(point: PointLike): number | null
4377
+ getLocationOf(x: number, y: number): CurveLocation | null
4378
+
4379
+ /**
4380
+ * Returns the length of the path from its beginning up to up to the
4381
+ * specified point if it lies on the path, `null` otherwise.
4382
+ *
4383
+ * @param point - the point on the path
4384
+ *
4385
+ * @return the length of the path up to the specified point
4386
+ */
4387
+ getOffsetOf(point: PointLike): number | null
4388
+
4389
+ /**
4390
+ * Returns the length of the path from its beginning up to up to the
4391
+ * specified point if it lies on the path, `null` otherwise.
4392
+ *
4393
+ * @param point - the point on the path
4394
+ *
4395
+ * @return the length of the path up to the specified point
4396
+ */
4397
+ getOffsetOf(x: number, y: number): number | null
3916
4398
 
3917
4399
  /**
3918
4400
  * Returns the curve location of the specified offset on the path, or
@@ -4001,6 +4483,19 @@ declare namespace paper {
4001
4483
  */
4002
4484
  getOffsetsWithTangent(tangent: PointLike): number[]
4003
4485
 
4486
+ /**
4487
+ * Calculates path offsets where the path is tangential to the provided
4488
+ * tangent. Note that tangents at the start or end are included. Tangents at
4489
+ * segment points are returned even if only one of their handles is
4490
+ * collinear with the provided tangent.
4491
+ *
4492
+ * @param tangent - the tangent to which the path must be tangential
4493
+ *
4494
+ * @return path offsets where the path is tangential to the
4495
+ * provided tangent
4496
+ */
4497
+ getOffsetsWithTangent(x: number, y: number): number[]
4498
+
4004
4499
  }
4005
4500
  namespace Path {
4006
4501
 
@@ -4083,6 +4578,14 @@ declare namespace paper {
4083
4578
 
4084
4579
  }
4085
4580
 
4581
+ class RoundRectangle extends Path {
4582
+ /**
4583
+ * @deprecated use {@link #Path.Rectangle} instead.
4584
+ */
4585
+ constructor(rectangle: RectangleLike, radius: SizeLike)
4586
+
4587
+ }
4588
+
4086
4589
  class Ellipse extends Path {
4087
4590
  /**
4088
4591
  * Creates an elliptical path item.
@@ -4102,6 +4605,14 @@ declare namespace paper {
4102
4605
 
4103
4606
  }
4104
4607
 
4608
+ class Oval extends Path {
4609
+ /**
4610
+ * @deprecated use {@link #Path.Ellipse} instead.
4611
+ */
4612
+ constructor(rectangle: RectangleLike)
4613
+
4614
+ }
4615
+
4105
4616
  class Arc extends Path {
4106
4617
  /**
4107
4618
  * Creates a circular arc path item.
@@ -4202,73 +4713,83 @@ declare namespace paper {
4202
4713
 
4203
4714
  /**
4204
4715
  * Unites the geometry of the specified path with this path's geometry
4205
- * and returns the result as a new path item.
4716
+ * and returns the result as a new path item. With an array of paths,
4717
+ * the result covers the areas inside any of them or this path. Each
4718
+ * path keeps its own fill rule.
4206
4719
  *
4207
4720
  * @option [options.insert=true] {Boolean} whether the resulting item
4208
- * should be inserted back into the scene graph, above both paths
4721
+ * should be inserted back into the scene graph, above all paths
4209
4722
  * involved in the operation
4210
4723
  *
4211
- * @param path - the path to unite with
4724
+ * @param path - the path or paths to unite with
4212
4725
  * @param options - the boolean operation options
4213
4726
  *
4214
4727
  * @return the resulting path item
4215
4728
  */
4216
- unite(path: PathItem, options?: object): PathItem
4729
+ unite(path: PathItem | PathItem[], options?: { insert?: boolean }): PathItem
4217
4730
 
4218
4731
  /**
4219
4732
  * Intersects the geometry of the specified path with this path's
4220
- * geometry and returns the result as a new path item.
4733
+ * geometry and returns the result as a new path item. With an array of
4734
+ * paths, the result covers the areas inside all of them and this path.
4735
+ * Each path keeps its own fill rule.
4221
4736
  *
4222
4737
  * @option [options.insert=true] {Boolean} whether the resulting item
4223
- * should be inserted back into the scene graph, above both paths
4738
+ * should be inserted back into the scene graph, above all paths
4224
4739
  * involved in the operation
4225
4740
  * @option [options.trace=true] {Boolean} whether the tracing method is
4226
- * used, treating both paths as areas when determining which parts
4741
+ * used, treating all paths as areas when determining which parts
4227
4742
  * of the paths are to be kept in the result, or whether the first
4228
4743
  * path is only to be split at intersections, keeping the parts of
4229
- * the curves that intersect with the area of the second path.
4744
+ * the curves that intersect with the areas of all other paths.
4230
4745
  *
4231
- * @param path - the path to intersect with
4746
+ * @param path - the path or paths to intersect
4747
+ * with
4232
4748
  * @param options - the boolean operation options
4233
4749
  *
4234
4750
  * @return the resulting path item
4235
4751
  */
4236
- intersect(path: PathItem, options?: object): PathItem
4752
+ intersect(path: PathItem | PathItem[], options?: { insert?: boolean, trace?: boolean }): PathItem
4237
4753
 
4238
4754
  /**
4239
4755
  * Subtracts the geometry of the specified path from this path's
4240
- * geometry and returns the result as a new path item.
4756
+ * geometry and returns the result as a new path item. With an array of
4757
+ * paths, the result covers the areas inside this path and outside all
4758
+ * of them. Each path keeps its own fill rule.
4241
4759
  *
4242
4760
  * @option [options.insert=true] {Boolean} whether the resulting item
4243
- * should be inserted back into the scene graph, above both paths
4761
+ * should be inserted back into the scene graph, above all paths
4244
4762
  * involved in the operation
4245
4763
  * @option [options.trace=true] {Boolean} whether the tracing method is
4246
- * used, treating both paths as areas when determining which parts
4764
+ * used, treating all paths as areas when determining which parts
4247
4765
  * of the paths are to be kept in the result, or whether the first
4248
4766
  * path is only to be split at intersections, removing the parts of
4249
- * the curves that intersect with the area of the second path.
4767
+ * the curves that intersect with the area of any other path.
4250
4768
  *
4251
- * @param path - the path to subtract
4769
+ * @param path - the path or paths to subtract
4252
4770
  * @param options - the boolean operation options
4253
4771
  *
4254
4772
  * @return the resulting path item
4255
4773
  */
4256
- subtract(path: PathItem, options?: object): PathItem
4774
+ subtract(path: PathItem | PathItem[], options?: { insert?: boolean, trace?: boolean }): PathItem
4257
4775
 
4258
4776
  /**
4259
4777
  * Excludes the intersection of the geometry of the specified path with
4260
- * this path's geometry and returns the result as a new path item.
4778
+ * this path's geometry and returns the result as a new path item. With
4779
+ * an array of paths, the result covers the areas inside an odd number
4780
+ * of the paths, this one included. Each path keeps its own fill rule.
4261
4781
  *
4262
4782
  * @option [options.insert=true] {Boolean} whether the resulting item
4263
- * should be inserted back into the scene graph, above both paths
4783
+ * should be inserted back into the scene graph, above all paths
4264
4784
  * involved in the operation
4265
4785
  *
4266
- * @param path - the path to exclude the intersection of
4786
+ * @param path - the path or paths to exclude the
4787
+ * intersection of
4267
4788
  * @param options - the boolean operation options
4268
4789
  *
4269
4790
  * @return the resulting path item
4270
4791
  */
4271
- exclude(path: PathItem, options?: object): PathItem
4792
+ exclude(path: PathItem | PathItem[], options?: { insert?: boolean }): PathItem
4272
4793
 
4273
4794
  /**
4274
4795
  * Splits the geometry of this path along the geometry of the specified
@@ -4289,7 +4810,7 @@ declare namespace paper {
4289
4810
  *
4290
4811
  * @return the resulting path item
4291
4812
  */
4292
- divide(path: PathItem, options?: object): PathItem
4813
+ divide(path: PathItem, options?: { insert?: boolean, trace?: boolean }): PathItem
4293
4814
 
4294
4815
  /**
4295
4816
  * Fixes the orientation of the sub-paths of a compound-path, assuming
@@ -4385,6 +4906,16 @@ declare namespace paper {
4385
4906
  */
4386
4907
  getNearestLocation(point: PointLike): CurveLocation
4387
4908
 
4909
+ /**
4910
+ * Returns the nearest location on the path item to the specified point.
4911
+ *
4912
+ * @param point - the point for which we search the nearest location
4913
+ *
4914
+ * @return the location on the path that's the closest to
4915
+ * the specified point
4916
+ */
4917
+ getNearestLocation(x: number, y: number): CurveLocation
4918
+
4388
4919
  /**
4389
4920
  * Returns the nearest point on the path item to the specified point.
4390
4921
  *
@@ -4395,6 +4926,16 @@ declare namespace paper {
4395
4926
  */
4396
4927
  getNearestPoint(point: PointLike): Point
4397
4928
 
4929
+ /**
4930
+ * Returns the nearest point on the path item to the specified point.
4931
+ *
4932
+ * @param point - the point for which we search the nearest point
4933
+ *
4934
+ * @return the point on the path that's the closest to the specified
4935
+ * point
4936
+ */
4937
+ getNearestPoint(x: number, y: number): Point
4938
+
4398
4939
  /**
4399
4940
  * Reverses the orientation of the path item. When called on
4400
4941
  * {@link CompoundPath} items, each of the nested paths is reversed. On
@@ -4479,7 +5020,7 @@ declare namespace paper {
4479
5020
  *
4480
5021
  * @param options - the smoothing options
4481
5022
  */
4482
- smooth(options?: object): void
5023
+ smooth(options?: { type?: string, factor?: number, from?: number | Segment | Curve, to?: number | Segment | Curve }): void
4483
5024
 
4484
5025
  /**
4485
5026
  * Fits a sequence of as few curves as possible through the path's anchor
@@ -4536,6 +5077,15 @@ declare namespace paper {
4536
5077
  */
4537
5078
  moveTo(point: PointLike): void
4538
5079
 
5080
+ /**
5081
+ * On a normal empty {@link Path}, the point is simply added as the path's
5082
+ * first segment. If called on a {@link CompoundPath}, a new {@link Path} is
5083
+ * created as a child and the point is added as its first segment.
5084
+ *
5085
+ * @param point - the point in which to start the path
5086
+ */
5087
+ moveTo(x: number, y: number): void
5088
+
4539
5089
  /**
4540
5090
  * Adds a straight curve to the path, from the the last segment in the path
4541
5091
  * to the specified point.
@@ -4545,6 +5095,15 @@ declare namespace paper {
4545
5095
  */
4546
5096
  lineTo(point: PointLike): void
4547
5097
 
5098
+ /**
5099
+ * Adds a straight curve to the path, from the the last segment in the path
5100
+ * to the specified point.
5101
+ *
5102
+ * @param point - the destination point of the newly added straight
5103
+ * curve
5104
+ */
5105
+ lineTo(x: number, y: number): void
5106
+
4548
5107
  /**
4549
5108
  * Adds an arc from the position of the last segment in the path, passing
4550
5109
  * through the specified `through` point, to the specified `to` point, by
@@ -4626,6 +5185,13 @@ declare namespace paper {
4626
5185
  */
4627
5186
  moveBy(to: PointLike): void
4628
5187
 
5188
+ /**
5189
+ * If called on a {@link CompoundPath}, a new {@link Path} is created as a
5190
+ * child and a point is added as its first segment relative to the position
5191
+ * of the last segment of the current path.
5192
+ */
5193
+ moveBy(x: number, y: number): void
5194
+
4629
5195
  /**
4630
5196
  * Adds a straight curve to the path, from the the last segment in the path
4631
5197
  * to the `to` vector specified relatively to it.
@@ -4635,6 +5201,15 @@ declare namespace paper {
4635
5201
  */
4636
5202
  lineBy(point: PointLike): void
4637
5203
 
5204
+ /**
5205
+ * Adds a straight curve to the path, from the the last segment in the path
5206
+ * to the `to` vector specified relatively to it.
5207
+ *
5208
+ * @param point - the vector describing the destination of the newly
5209
+ * added straight curve
5210
+ */
5211
+ lineBy(x: number, y: number): void
5212
+
4638
5213
  /**
4639
5214
  * Adds an arc from the position of the last segment in the path, passing
4640
5215
  * through the specified `through` vector, to the specified `to` vector, all
@@ -4700,10 +5275,61 @@ declare namespace paper {
4700
5275
 
4701
5276
  }
4702
5277
 
5278
+ /**
5279
+ * A PathText item represents text that runs along a path, its
5280
+ * {@link #textPath}, each letter turned to the path's direction where it
5281
+ * sits. On a compound path, the text runs along one of its paths after the
5282
+ * other. What doesn't fit between {@link #startOffset} and
5283
+ * {@link #endOffset} flows on into the next linked text item.
5284
+ */
5285
+ class PathText extends TextItem {
5286
+ /**
5287
+ * The length along the path where the text starts.
5288
+ */
5289
+ startOffset: number
5290
+
5291
+ /**
5292
+ * The length along the path where the text ends, or `null` for its end.
5293
+ */
5294
+ endOffset: number
5295
+
5296
+ /**
5297
+ * Which part of the letters sits on the path.
5298
+ */
5299
+ alignment: string
5300
+
5301
+ /**
5302
+ * Space added between the letters, where the path bends tightly.
5303
+ */
5304
+ spacing: number
5305
+
5306
+
5307
+ /**
5308
+ * Creates a text item that runs along a path.
5309
+ *
5310
+ * @param path - the path that the text runs along
5311
+ * @param orientation - the orientation of the text
5312
+ */
5313
+ constructor(path: PathItem, orientation?: string)
5314
+
5315
+ /**
5316
+ * Creates a text item that runs along a path, from the properties
5317
+ * described by an object literal.
5318
+ *
5319
+ * @param object - an object containing properties describing the
5320
+ * text's attributes
5321
+ */
5322
+ constructor(object: object)
5323
+
5324
+ }
5325
+
4703
5326
  /**
4704
5327
  * The Point object represents a point in the two dimensional space
4705
5328
  * of the Paper.js project. It is also used to represent two dimensional
4706
5329
  * vector objects.
5330
+ *
5331
+ * Wherever a point is the only argument of a function, it can also be passed
5332
+ * as two numbers, e.g. `point.add(10, 20)` or `item.translate(10, 20)`.
4707
5333
  */
4708
5334
  class Point {
4709
5335
  /**
@@ -4805,7 +5431,7 @@ declare namespace paper {
4805
5431
  *
4806
5432
  * @return true if the points are equal
4807
5433
  */
4808
- equals(point: PointLike): boolean
5434
+ equals(point: PointLike | number[]): boolean
4809
5435
 
4810
5436
  /**
4811
5437
  * Returns a copy of the point.
@@ -4827,6 +5453,14 @@ declare namespace paper {
4827
5453
  */
4828
5454
  getAngle(point: PointLike): number
4829
5455
 
5456
+ /**
5457
+ * Returns the smaller angle between two vectors. The angle is unsigned, no
5458
+ * information about rotational direction is given.
5459
+ *
5460
+ * @return the angle in degrees
5461
+ */
5462
+ getAngle(x: number, y: number): number
5463
+
4830
5464
  /**
4831
5465
  * Returns the smaller angle between two vectors in radians. The angle is
4832
5466
  * unsigned, no information about rotational direction is given.
@@ -4835,6 +5469,14 @@ declare namespace paper {
4835
5469
  */
4836
5470
  getAngleInRadians(point: PointLike): number
4837
5471
 
5472
+ /**
5473
+ * Returns the smaller angle between two vectors in radians. The angle is
5474
+ * unsigned, no information about rotational direction is given.
5475
+ *
5476
+ * @return the angle in radians
5477
+ */
5478
+ getAngleInRadians(x: number, y: number): number
5479
+
4838
5480
  /**
4839
5481
  * Returns the angle between two vectors. The angle is directional and
4840
5482
  * signed, giving information about the rotational direction.
@@ -4846,6 +5488,17 @@ declare namespace paper {
4846
5488
  */
4847
5489
  getDirectedAngle(point: PointLike): number
4848
5490
 
5491
+ /**
5492
+ * Returns the angle between two vectors. The angle is directional and
5493
+ * signed, giving information about the rotational direction.
5494
+ *
5495
+ * Read more about angle units and orientation in the description of the
5496
+ * {@link #angle} property.
5497
+ *
5498
+ * @return the angle between the two vectors
5499
+ */
5500
+ getDirectedAngle(x: number, y: number): number
5501
+
4849
5502
  /**
4850
5503
  * Returns the distance between the point and another point.
4851
5504
  *
@@ -4911,6 +5564,17 @@ declare namespace paper {
4911
5564
  */
4912
5565
  add(point: PointLike): Point
4913
5566
 
5567
+ /**
5568
+ * Returns the addition of the supplied point to the point as a new
5569
+ * point.
5570
+ * The object itself is not modified!
5571
+ *
5572
+ * @param point - the point to add
5573
+ *
5574
+ * @return the addition of the two points as a new point
5575
+ */
5576
+ add(x: number, y: number): Point
5577
+
4914
5578
  /**
4915
5579
  * Returns the subtraction of the supplied value to both coordinates of
4916
5580
  * the point as a new point.
@@ -4933,6 +5597,17 @@ declare namespace paper {
4933
5597
  */
4934
5598
  subtract(point: PointLike): Point
4935
5599
 
5600
+ /**
5601
+ * Returns the subtraction of the supplied point to the point as a new
5602
+ * point.
5603
+ * The object itself is not modified!
5604
+ *
5605
+ * @param point - the point to subtract
5606
+ *
5607
+ * @return the subtraction of the two points as a new point
5608
+ */
5609
+ subtract(x: number, y: number): Point
5610
+
4936
5611
  /**
4937
5612
  * Returns the multiplication of the supplied value to both coordinates of
4938
5613
  * the point as a new point.
@@ -4956,6 +5631,17 @@ declare namespace paper {
4956
5631
  */
4957
5632
  multiply(point: PointLike): Point
4958
5633
 
5634
+ /**
5635
+ * Returns the multiplication of the supplied point to the point as a new
5636
+ * point.
5637
+ * The object itself is not modified!
5638
+ *
5639
+ * @param point - the point to multiply by
5640
+ *
5641
+ * @return the multiplication of the two points as a new point
5642
+ */
5643
+ multiply(x: number, y: number): Point
5644
+
4959
5645
  /**
4960
5646
  * Returns the division of the supplied value to both coordinates of
4961
5647
  * the point as a new point.
@@ -4978,6 +5664,17 @@ declare namespace paper {
4978
5664
  */
4979
5665
  divide(point: PointLike): Point
4980
5666
 
5667
+ /**
5668
+ * Returns the division of the supplied point to the point as a new
5669
+ * point.
5670
+ * The object itself is not modified!
5671
+ *
5672
+ * @param point - the point to divide by
5673
+ *
5674
+ * @return the division of the two points as a new point
5675
+ */
5676
+ divide(x: number, y: number): Point
5677
+
4981
5678
  /**
4982
5679
  * The modulo operator returns the integer remainders of dividing the point
4983
5680
  * by the supplied value as a new point.
@@ -4996,6 +5693,15 @@ declare namespace paper {
4996
5693
  */
4997
5694
  modulo(point: PointLike): Point
4998
5695
 
5696
+ /**
5697
+ * The modulo operator returns the integer remainders of dividing the point
5698
+ * by the supplied value as a new point.
5699
+ *
5700
+ * @return the integer remainders of dividing the points by each
5701
+ * other as a new point
5702
+ */
5703
+ modulo(x: number, y: number): Point
5704
+
4999
5705
  /**
5000
5706
  * Returns a new point with both coordinates negated.
5001
5707
  * PaperScript uses it for the unary minus operator.
@@ -5034,6 +5740,16 @@ declare namespace paper {
5034
5740
  */
5035
5741
  isCollinear(point: PointLike): boolean
5036
5742
 
5743
+ /**
5744
+ * Checks if the vector represented by this point is collinear (parallel) to
5745
+ * another vector.
5746
+ *
5747
+ * @param point - the vector to check against
5748
+ *
5749
+ * @return true it is collinear
5750
+ */
5751
+ isCollinear(x: number, y: number): boolean
5752
+
5037
5753
  /**
5038
5754
  * Checks if the vector represented by this point is orthogonal
5039
5755
  * (perpendicular) to another vector.
@@ -5044,6 +5760,16 @@ declare namespace paper {
5044
5760
  */
5045
5761
  isOrthogonal(point: PointLike): boolean
5046
5762
 
5763
+ /**
5764
+ * Checks if the vector represented by this point is orthogonal
5765
+ * (perpendicular) to another vector.
5766
+ *
5767
+ * @param point - the vector to check against
5768
+ *
5769
+ * @return true it is orthogonal
5770
+ */
5771
+ isOrthogonal(x: number, y: number): boolean
5772
+
5047
5773
  /**
5048
5774
  * Checks if this point has both the x and y coordinate set to 0.
5049
5775
  *
@@ -5079,6 +5805,13 @@ declare namespace paper {
5079
5805
  */
5080
5806
  dot(point: PointLike): number
5081
5807
 
5808
+ /**
5809
+ * Returns the dot product of the point and another point.
5810
+ *
5811
+ * @return the dot product of the two points
5812
+ */
5813
+ dot(x: number, y: number): number
5814
+
5082
5815
  /**
5083
5816
  * Returns the cross product of the point and another point.
5084
5817
  *
@@ -5086,6 +5819,13 @@ declare namespace paper {
5086
5819
  */
5087
5820
  cross(point: PointLike): number
5088
5821
 
5822
+ /**
5823
+ * Returns the cross product of the point and another point.
5824
+ *
5825
+ * @return the cross product of the two points
5826
+ */
5827
+ cross(x: number, y: number): number
5828
+
5089
5829
  /**
5090
5830
  * Returns the projection of the point onto another point.
5091
5831
  * Both points are interpreted as vectors.
@@ -5094,6 +5834,14 @@ declare namespace paper {
5094
5834
  */
5095
5835
  project(point: PointLike): Point
5096
5836
 
5837
+ /**
5838
+ * Returns the projection of the point onto another point.
5839
+ * Both points are interpreted as vectors.
5840
+ *
5841
+ * @return the projection of the point onto another point
5842
+ */
5843
+ project(x: number, y: number): Point
5844
+
5097
5845
  /**
5098
5846
  * Returns a new point with rounded {@link #x} and {@link #y} values. The
5099
5847
  * object itself is not modified!
@@ -5167,7 +5915,8 @@ declare namespace paper {
5167
5915
  /**
5168
5916
  * The PointText's anchor point
5169
5917
  */
5170
- point: Point
5918
+ get point(): Point
5919
+ set point(value: PointLike)
5171
5920
 
5172
5921
 
5173
5922
  /**
@@ -5209,11 +5958,11 @@ declare namespace paper {
5209
5958
  class Project {
5210
5959
  /**
5211
5960
  * The host document that the project's items come from. Setting it
5212
- * creates the project's layers from the source's records. All items
5961
+ * creates the project's layers from the host's records. All items
5213
5962
  * are created as shells that load their content and children from the
5214
- * source on first access.
5963
+ * host on first access.
5215
5964
  *
5216
- * The source provides:
5965
+ * The host provides:
5217
5966
  * - `getChildren(key)`, which returns the records of the children of
5218
5967
  * the node with the given key, or of the top level for `null`, as
5219
5968
  * columns: `keys`, `types` (indices into `typeNames`), `typeNames`,
@@ -5222,11 +5971,32 @@ declare namespace paper {
5222
5971
  * strokeBounds and roughBounds in the item's coordinates, 12 numbers
5223
5972
  * per item), and the sparse objects `names` and `matrices`.
5224
5973
  * - `getItem(key)`, which returns the node's own content in the form
5225
- * of {@link Item#importJSON}, without children.
5974
+ * of {@link Item#importJSON}, without children. Linked text
5975
+ * gives `linked`, the keys of its story's text items in order, and
5976
+ * leaves out its story.
5977
+ * - `getStory(key)`, for linked text, which returns its story with the
5978
+ * key of any of its text items: `content` or `runs`, `paragraphs`,
5979
+ * and the character and paragraph styles, as
5980
+ * {@link Item#exportJSON} writes them in the JSON of a
5981
+ * text item.
5226
5982
  * - `getAncestorKeys(key)`, which returns the keys from the top level
5227
5983
  * down to the node's parent.
5228
- */
5229
- source: any
5984
+ * - Optionally `layOut(json, start, key)`, which lays out a text item
5985
+ * from `start` in its story, given as the JSON string that
5986
+ * {@link Item#exportJSON} writes of it as the script holds
5987
+ * it, or as `null` where the script didn't change it since it
5988
+ * loaded or the host took its changes with
5989
+ * {@link Project#takeChanges}, for the host to lay out its own
5990
+ * node, and returns
5991
+ * `{ end, lines }`: where its visible text ends, and
5992
+ * its lines, each `{ start, end, x, y, width, lineHeight, ascent,
5993
+ * descent, pieces }`, with pieces `{ start, end, x, y, dx, width,
5994
+ * rotation, size, ascent, descent, lineHeight }` and an optional
5995
+ * `content`, as for a hyphen, all in the item's coordinates. `key`
5996
+ * is null for text that the host doesn't know yet. Without it,
5997
+ * Paper.js lays out text itself.
5998
+ */
5999
+ host: any
5230
6000
 
5231
6001
  /**
5232
6002
  * Specifies whether the project logs the changes of its items, to be
@@ -5256,6 +6026,13 @@ declare namespace paper {
5256
6026
  */
5257
6027
  readonly index: number
5258
6028
 
6029
+ /**
6030
+ * Gives access to the project's configurable options.
6031
+ *
6032
+ * @deprecated use {@link PaperScope#settings} instead.
6033
+ */
6034
+ readonly options: any
6035
+
5259
6036
  /**
5260
6037
  * The layers contained within the project.
5261
6038
  */
@@ -5273,6 +6050,11 @@ declare namespace paper {
5273
6050
  */
5274
6051
  readonly symbolDefinitions: SymbolDefinition[]
5275
6052
 
6053
+ /**
6054
+ * @deprecated use {@link #symbolDefinitions} instead.
6055
+ */
6056
+ readonly symbols: SymbolDefinition[]
6057
+
5276
6058
  /**
5277
6059
  * The selected items contained within the project.
5278
6060
  */
@@ -5299,13 +6081,13 @@ declare namespace paper {
5299
6081
  *
5300
6082
  * @param key - the key of the host's node
5301
6083
  *
5302
- * @return the item, or `null` if the source has no such node
6084
+ * @return the item, or `null` if the host has no such node
5303
6085
  */
5304
6086
  getItemByKey(key: number): Item
5305
6087
 
5306
6088
  /**
5307
6089
  * Updates the items of changed host nodes, given in the column format
5308
- * of the source's `getChildren()`, with two more flags: 16 when the
6090
+ * of the host's `getChildren()`, with two more flags: 16 when the
5309
6091
  * node's own content changed, so the item loads it again on next
5310
6092
  * access, and 32 when its list of children changed, so it loads them
5311
6093
  * again right away if it had loaded them, keeping the items of nodes
@@ -5326,6 +6108,14 @@ declare namespace paper {
5326
6108
  */
5327
6109
  takeChanges(): object[]
5328
6110
 
6111
+ /**
6112
+ * Checks whether changes were logged since tracking was activated or since
6113
+ * the last call of {@link #takeChanges}, without taking them.
6114
+ *
6115
+ * @return true if changes were logged
6116
+ */
6117
+ hasChanges(): boolean
6118
+
5329
6119
  /**
5330
6120
  * Activates this project, so all newly created items will be placed
5331
6121
  * in it.
@@ -5424,7 +6214,7 @@ declare namespace paper {
5424
6214
  * @return a hit result object that contains more information
5425
6215
  * about what exactly was hit or `null` if nothing was hit
5426
6216
  */
5427
- hitTest(point: PointLike, options?: object): HitResult
6217
+ hitTest(point: PointLike, options?: { tolerance?: number, class?: Function, match?: Function, fill?: boolean, stroke?: boolean, segments?: boolean, curves?: boolean, handles?: boolean, ends?: boolean, position?: boolean, center?: boolean, bounds?: boolean, guides?: boolean, selected?: boolean }): HitResult
5428
6218
 
5429
6219
  /**
5430
6220
  * Performs a hit-test on the item and its children (if it is a {@link
@@ -5441,7 +6231,7 @@ declare namespace paper {
5441
6231
  * @return hit result objects for all hits, describing what
5442
6232
  * exactly was hit or `null` if nothing was hit
5443
6233
  */
5444
- hitTestAll(point: PointLike, options?: object): HitResult[]
6234
+ hitTestAll(point: PointLike, options?: { tolerance?: number, class?: Function, match?: Function, fill?: boolean, stroke?: boolean, segments?: boolean, curves?: boolean, handles?: boolean, ends?: boolean, position?: boolean, center?: boolean, bounds?: boolean, guides?: boolean, selected?: boolean }): HitResult[]
5445
6235
 
5446
6236
  /**
5447
6237
  * Fetch items contained within the project whose properties match the
@@ -5512,7 +6302,7 @@ declare namespace paper {
5512
6302
  *
5513
6303
  * @return the exported JSON data
5514
6304
  */
5515
- exportJSON(options?: object): string
6305
+ exportJSON(options?: { asString?: boolean, precision?: number }): string
5516
6306
 
5517
6307
  /**
5518
6308
  * Imports (deserializes) the stored JSON data into the project.
@@ -5562,7 +6352,7 @@ declare namespace paper {
5562
6352
  * @return the project converted to an SVG node or a
5563
6353
  * `String` depending on `option.asString` value
5564
6354
  */
5565
- exportSVG(options?: object): SVGElement | string
6355
+ exportSVG(options?: { bounds?: string | RectangleLike, matrix?: Matrix, asString?: boolean, precision?: number, matchShapes?: boolean, embedImages?: boolean, reuseImages?: boolean, idPrefix?: string, reduceAttributes?: boolean }): SVGElement | string
5566
6356
 
5567
6357
  /**
5568
6358
  * Converts the provided SVG content into Paper.js items and adds them to
@@ -5574,6 +6364,10 @@ declare namespace paper {
5574
6364
  * the `<use>` elements that place them as {@link SymbolItem} items. The
5575
6365
  * styles that `<use>` elements inherit don't reach the symbols' content.
5576
6366
  *
6367
+ * URLs are fetched as they are, so validate URLs that come from untrusted
6368
+ * sources first, especially on servers, where they could reach internal
6369
+ * addresses.
6370
+ *
5577
6371
  * @option [options.expandShapes=false] {Boolean} whether imported shape
5578
6372
  * items should be expanded to path items
5579
6373
  * @option [options.crossOrigin] {String} the {@link Raster#crossOrigin}
@@ -5600,7 +6394,7 @@ declare namespace paper {
5600
6394
  * @return the newly created Paper.js item containing the converted
5601
6395
  * SVG content
5602
6396
  */
5603
- importSVG(svg: SVGElement | string, options?: object): Item
6397
+ importSVG(svg: SVGElement | string, options?: { expandShapes?: boolean, crossOrigin?: string, onLoad?: Function, onError?: Function, insert?: boolean, applyMatrix?: boolean }): Item
5604
6398
 
5605
6399
  /**
5606
6400
  * Imports the provided external SVG file, converts it into Paper.js items
@@ -5628,7 +6422,8 @@ declare namespace paper {
5628
6422
  /**
5629
6423
  * The size of the raster in pixels.
5630
6424
  */
5631
- size: Size
6425
+ get size(): Size
6426
+ set size(value: SizeLike)
5632
6427
 
5633
6428
  /**
5634
6429
  * The width of the raster in pixels.
@@ -5651,6 +6446,11 @@ declare namespace paper {
5651
6446
  */
5652
6447
  readonly resolution: Size
5653
6448
 
6449
+ /**
6450
+ * @deprecated use {@link #resolution} instead.
6451
+ */
6452
+ readonly ppi: Size
6453
+
5654
6454
  /**
5655
6455
  * The HTMLImageElement or Canvas element of the raster, if one is
5656
6456
  * associated.
@@ -5861,6 +6661,9 @@ declare namespace paper {
5861
6661
 
5862
6662
  createImageData(size: SizeLike): ImageData
5863
6663
 
6664
+
6665
+ createImageData(width: number, height: number): ImageData
6666
+
5864
6667
  /**
5865
6668
  * Returns the image data of the pixels within the specified rectangle, or
5866
6669
  * of the whole raster if no rectangle or an empty one is passed.
@@ -5910,12 +6713,14 @@ declare namespace paper {
5910
6713
  * The top-left point of the rectangle. Setting it moves the whole
5911
6714
  * rectangle, unlike {@link #topLeft}.
5912
6715
  */
5913
- point: Point
6716
+ get point(): Point
6717
+ set point(value: PointLike)
5914
6718
 
5915
6719
  /**
5916
6720
  * The size of the rectangle
5917
6721
  */
5918
- size: Size
6722
+ get size(): Size
6723
+ set size(value: SizeLike)
5919
6724
 
5920
6725
  /**
5921
6726
  * The position of the left hand side of the rectangle. Note that this
@@ -5944,59 +6749,68 @@ declare namespace paper {
5944
6749
  /**
5945
6750
  * The center point of the rectangle. Setting it moves the whole rectangle.
5946
6751
  */
5947
- center: Point
6752
+ get center(): Point
6753
+ set center(value: PointLike)
5948
6754
 
5949
6755
  /**
5950
6756
  * The top-left point of the rectangle. Note that this doesn't move the
5951
6757
  * whole rectangle; the bottom-right corner stays where it was.
5952
6758
  */
5953
- topLeft: Point
6759
+ get topLeft(): Point
6760
+ set topLeft(value: PointLike)
5954
6761
 
5955
6762
  /**
5956
6763
  * The top-right point of the rectangle. Note that this doesn't move the
5957
6764
  * whole rectangle; the bottom-left corner stays where it was.
5958
6765
  */
5959
- topRight: Point
6766
+ get topRight(): Point
6767
+ set topRight(value: PointLike)
5960
6768
 
5961
6769
  /**
5962
6770
  * The bottom-left point of the rectangle. Note that this doesn't move the
5963
6771
  * whole rectangle; the top-right corner stays where it was.
5964
6772
  */
5965
- bottomLeft: Point
6773
+ get bottomLeft(): Point
6774
+ set bottomLeft(value: PointLike)
5966
6775
 
5967
6776
  /**
5968
6777
  * The bottom-right point of the rectangle. Note that this doesn't move the
5969
6778
  * whole rectangle; the top-left corner stays where it was.
5970
6779
  */
5971
- bottomRight: Point
6780
+ get bottomRight(): Point
6781
+ set bottomRight(value: PointLike)
5972
6782
 
5973
6783
  /**
5974
6784
  * The left-center point of the rectangle. Setting it moves the left hand
5975
6785
  * side while the right hand side stays where it was, and moves the whole
5976
6786
  * rectangle vertically.
5977
6787
  */
5978
- leftCenter: Point
6788
+ get leftCenter(): Point
6789
+ set leftCenter(value: PointLike)
5979
6790
 
5980
6791
  /**
5981
6792
  * The top-center point of the rectangle. Setting it moves the top while
5982
6793
  * the bottom stays where it was, and moves the whole rectangle
5983
6794
  * horizontally.
5984
6795
  */
5985
- topCenter: Point
6796
+ get topCenter(): Point
6797
+ set topCenter(value: PointLike)
5986
6798
 
5987
6799
  /**
5988
6800
  * The right-center point of the rectangle. Setting it moves the right
5989
6801
  * hand side while the left hand side stays where it was, and moves the
5990
6802
  * whole rectangle vertically.
5991
6803
  */
5992
- rightCenter: Point
6804
+ get rightCenter(): Point
6805
+ set rightCenter(value: PointLike)
5993
6806
 
5994
6807
  /**
5995
6808
  * The bottom-center point of the rectangle. Setting it moves the bottom
5996
6809
  * while the top stays where it was, and moves the whole rectangle
5997
6810
  * horizontally.
5998
6811
  */
5999
- bottomCenter: Point
6812
+ get bottomCenter(): Point
6813
+ set bottomCenter(value: PointLike)
6000
6814
 
6001
6815
  /**
6002
6816
  * The area of the rectangle.
@@ -6009,10 +6823,11 @@ declare namespace paper {
6009
6823
  * Paper.js draws the bounds of items with selected bounds on top of
6010
6824
  * your project. This is very useful when debugging.
6011
6825
  *
6012
- * This property is only available on the rectangle returned by
6013
- * {@link Item#bounds}, and the selection always shows these bounds.
6014
- * Rectangles returned by other getters such as {@link
6015
- * Item#strokeBounds} don't have it.
6826
+ * This property is only available on the rectangles returned by
6827
+ * {@link Item#bounds} and {@link Item#strokeBounds}, which are
6828
+ * selected independently of each other, each showing its own
6829
+ * bounds. Rectangles returned by other getters such as {@link
6830
+ * Item#handleBounds} don't have it.
6016
6831
  */
6017
6832
  selected: boolean
6018
6833
 
@@ -6096,10 +6911,19 @@ declare namespace paper {
6096
6911
  contains(point: PointLike): boolean
6097
6912
 
6098
6913
  /**
6099
- * Tests if the interior of the rectangle entirely contains the specified
6100
- * rectangle.
6914
+ * Tests if the specified point is inside the boundary of the rectangle.
6101
6915
  *
6102
- * @param rect - the specified rectangle
6916
+ * @param point - the specified point
6917
+ *
6918
+ * @return true if the point is inside the rectangle's boundary
6919
+ */
6920
+ contains(x: number, y: number): boolean
6921
+
6922
+ /**
6923
+ * Tests if the interior of the rectangle entirely contains the specified
6924
+ * rectangle.
6925
+ *
6926
+ * @param rect - the specified rectangle
6103
6927
  *
6104
6928
  * @return true if the rectangle entirely contains the specified
6105
6929
  * rectangle
@@ -6161,6 +6985,23 @@ declare namespace paper {
6161
6985
  */
6162
6986
  include(point: PointLike): Rectangle
6163
6987
 
6988
+ /**
6989
+ * Adds a point to this rectangle. The resulting rectangle is the smallest
6990
+ * rectangle that contains both the original rectangle and the specified
6991
+ * point.
6992
+ *
6993
+ * After adding a point, a call to {@link #contains} with the added
6994
+ * point as an argument does not necessarily return `true`. The {@link
6995
+ * Rectangle#contains(point)} method does not return `true` for points on
6996
+ * the right or bottom edges of a rectangle. Therefore, if the added point
6997
+ * falls on the left or bottom edge of the enlarged rectangle, {@link
6998
+ * Rectangle#contains(point)} returns `false` for that point.
6999
+ *
7000
+ * @return the smallest rectangle that contains both the
7001
+ * original rectangle and the specified point
7002
+ */
7003
+ include(x: number, y: number): Rectangle
7004
+
6164
7005
  /**
6165
7006
  * Returns a new rectangle expanded by the specified amount in horizontal
6166
7007
  * and vertical directions.
@@ -6217,19 +7058,22 @@ declare namespace paper {
6217
7058
  /**
6218
7059
  * The anchor point of the segment.
6219
7060
  */
6220
- point: Point
7061
+ get point(): Point
7062
+ set point(value: PointLike)
6221
7063
 
6222
7064
  /**
6223
7065
  * The handle point relative to the anchor point of the segment that
6224
7066
  * describes the in tangent of the segment.
6225
7067
  */
6226
- handleIn: Point
7068
+ get handleIn(): Point
7069
+ set handleIn(value: PointLike)
6227
7070
 
6228
7071
  /**
6229
7072
  * The handle point relative to the anchor point of the segment that
6230
7073
  * describes the out tangent of the segment.
6231
7074
  */
6232
- handleOut: Point
7075
+ get handleOut(): Point
7076
+ set handleOut(value: PointLike)
6233
7077
 
6234
7078
  /**
6235
7079
  * Specifies whether the segment is selected.
@@ -6358,7 +7202,7 @@ declare namespace paper {
6358
7202
  *
6359
7203
  * @param options - the smoothing options
6360
7204
  */
6361
- smooth(options?: object): void
7205
+ smooth(options?: { type?: string, factor?: number }): void
6362
7206
 
6363
7207
  /**
6364
7208
  * Checks if the this is the first segment in the {@link Path#segments}
@@ -6435,16 +7279,23 @@ declare namespace paper {
6435
7279
  */
6436
7280
  type: string
6437
7281
 
7282
+ /**
7283
+ * @deprecated use {@link #type} instead.
7284
+ */
7285
+ shape: string
7286
+
6438
7287
  /**
6439
7288
  * The size of the shape.
6440
7289
  */
6441
- size: Size
7290
+ get size(): Size
7291
+ set size(value: SizeLike)
6442
7292
 
6443
7293
  /**
6444
7294
  * The radius of the shape, as a number if it is a circle, or a size object
6445
7295
  * for ellipses and rounded rectangles.
6446
7296
  */
6447
- radius: number | Size
7297
+ get radius(): number | Size
7298
+ set radius(value: number | SizeLike)
6448
7299
 
6449
7300
 
6450
7301
  /**
@@ -6547,6 +7398,9 @@ declare namespace paper {
6547
7398
  /**
6548
7399
  * The Size object is used to describe the size or dimensions of
6549
7400
  * something, through its {@link #width} and {@link #height} properties.
7401
+ *
7402
+ * Wherever a size is the only argument of a function, it can also be passed
7403
+ * as two numbers, e.g. `size.multiply(2, 3)`.
6550
7404
  */
6551
7405
  class Size {
6552
7406
  /**
@@ -6603,7 +7457,7 @@ declare namespace paper {
6603
7457
  *
6604
7458
  * @param size - the size to compare to
6605
7459
  */
6606
- equals(size: SizeLike): boolean
7460
+ equals(size: SizeLike | number[]): boolean
6607
7461
 
6608
7462
  /**
6609
7463
  * Returns a copy of the size.
@@ -6635,6 +7489,16 @@ declare namespace paper {
6635
7489
  */
6636
7490
  add(size: SizeLike): Size
6637
7491
 
7492
+ /**
7493
+ * Returns the addition of the width and height of the supplied size to the
7494
+ * size as a new size. The object itself is not modified!
7495
+ *
7496
+ * @param size - the size to add
7497
+ *
7498
+ * @return the addition of the two sizes as a new size
7499
+ */
7500
+ add(width: number, height: number): Size
7501
+
6638
7502
  /**
6639
7503
  * Returns the subtraction of the supplied value from the width and height
6640
7504
  * of the size as a new size. The object itself is not modified!
@@ -6656,6 +7520,16 @@ declare namespace paper {
6656
7520
  */
6657
7521
  subtract(size: SizeLike): Size
6658
7522
 
7523
+ /**
7524
+ * Returns the subtraction of the width and height of the supplied size from
7525
+ * the size as a new size. The object itself is not modified!
7526
+ *
7527
+ * @param size - the size to subtract
7528
+ *
7529
+ * @return the subtraction of the two sizes as a new size
7530
+ */
7531
+ subtract(width: number, height: number): Size
7532
+
6659
7533
  /**
6660
7534
  * Returns the multiplication of the supplied value with the width and
6661
7535
  * height of the size as a new size. The object itself is not modified!
@@ -6676,6 +7550,16 @@ declare namespace paper {
6676
7550
  */
6677
7551
  multiply(size: SizeLike): Size
6678
7552
 
7553
+ /**
7554
+ * Returns the multiplication of the width and height of the supplied size
7555
+ * with the size as a new size. The object itself is not modified!
7556
+ *
7557
+ * @param size - the size to multiply by
7558
+ *
7559
+ * @return the multiplication of the two sizes as a new size
7560
+ */
7561
+ multiply(width: number, height: number): Size
7562
+
6679
7563
  /**
6680
7564
  * Returns the division of the supplied value by the width and height of the
6681
7565
  * size as a new size. The object itself is not modified!
@@ -6696,6 +7580,16 @@ declare namespace paper {
6696
7580
  */
6697
7581
  divide(size: SizeLike): Size
6698
7582
 
7583
+ /**
7584
+ * Returns the division of the width and height of the supplied size by the
7585
+ * size as a new size. The object itself is not modified!
7586
+ *
7587
+ * @param size - the size to divide by
7588
+ *
7589
+ * @return the division of the two sizes as a new size
7590
+ */
7591
+ divide(width: number, height: number): Size
7592
+
6699
7593
  /**
6700
7594
  * The modulo operator returns the integer remainders of dividing the size
6701
7595
  * by the supplied value as a new size.
@@ -6714,6 +7608,15 @@ declare namespace paper {
6714
7608
  */
6715
7609
  modulo(size: SizeLike): Size
6716
7610
 
7611
+ /**
7612
+ * The modulo operator returns the integer remainders of dividing the size
7613
+ * by the supplied size as a new size.
7614
+ *
7615
+ * @return the integer remainders of dividing the sizes by each
7616
+ * other as a new size
7617
+ */
7618
+ modulo(width: number, height: number): Size
7619
+
6717
7620
  /**
6718
7621
  * Returns a new size with both dimensions negated.
6719
7622
  * PaperScript uses it for the unary minus operator.
@@ -6811,10 +7714,19 @@ declare namespace paper {
6811
7714
  */
6812
7715
  readonly view: View
6813
7716
 
7717
+ /**
7718
+ * The line height as a fixed length, in pixels, as Paper.js had it before
7719
+ * #lineHeight: setting a number makes it fixed, as `'18px'`.
7720
+ *
7721
+ * @deprecated use {@link #lineHeight} instead.
7722
+ */
7723
+ leading: number
7724
+
6814
7725
  /**
6815
7726
  * The color of the stroke.
6816
7727
  */
6817
- strokeColor: Color | null
7728
+ get strokeColor(): Color | null
7729
+ set strokeColor(value: ColorLike | null)
6818
7730
 
6819
7731
  /**
6820
7732
  * The width of the stroke.
@@ -6864,7 +7776,8 @@ declare namespace paper {
6864
7776
  /**
6865
7777
  * The fill color.
6866
7778
  */
6867
- fillColor: Color | null
7779
+ get fillColor(): Color | null
7780
+ set fillColor(value: ColorLike | null)
6868
7781
 
6869
7782
  /**
6870
7783
  * The fill-rule with which the shape gets filled. Please note that only
@@ -6875,7 +7788,8 @@ declare namespace paper {
6875
7788
  /**
6876
7789
  * The shadow color.
6877
7790
  */
6878
- shadowColor: Color | null
7791
+ get shadowColor(): Color | null
7792
+ set shadowColor(value: ColorLike | null)
6879
7793
 
6880
7794
  /**
6881
7795
  * The shadow's blur radius.
@@ -6885,13 +7799,15 @@ declare namespace paper {
6885
7799
  /**
6886
7800
  * The shadow's offset.
6887
7801
  */
6888
- shadowOffset: Point
7802
+ get shadowOffset(): Point
7803
+ set shadowOffset(value: PointLike)
6889
7804
 
6890
7805
  /**
6891
7806
  * The color the item is highlighted with when selected. If the item does
6892
7807
  * not specify its own color, the color defined by its layer is used instead.
6893
7808
  */
6894
- selectedColor: Color | null
7809
+ get selectedColor(): Color | null
7810
+ set selectedColor(value: ColorLike | null)
6895
7811
 
6896
7812
  /**
6897
7813
  * The font-family to be used in text content.
@@ -6910,22 +7826,181 @@ declare namespace paper {
6910
7826
  fontSize: number | string
6911
7827
 
6912
7828
  /**
6913
- * The text leading of text content.
7829
+ * The font-family to be used in text content, as one string.
7830
+ *
7831
+ * @deprecated use {@link #fontFamily} instead.
6914
7832
  */
6915
- leading: number | string
7833
+ font: string
6916
7834
 
6917
7835
  /**
6918
- * The tracking of text content: the space added after each character, in
6919
- * thousandths of an em, as in Adobe Illustrator and InDesign. A tracking of
6920
- * 100 adds a tenth of the font size.
7836
+ * The line height of text content: the distance from one line's baseline
7837
+ * to the next. Automatic, as `'auto'` (1.2) or another factor of the
7838
+ * letters' font size, each line moving down by its largest letters'; or
7839
+ * fixed, as a length with units as the font size takes them (`'18px'`,
7840
+ * `'12pt'`).
7841
+ */
7842
+ lineHeight: number | string
7843
+
7844
+ /**
7845
+ * The letter tracking of text content: the space added after each letter,
7846
+ * along the line, in thousandths of an em, as in Adobe Illustrator and
7847
+ * InDesign. A tracking of 100 adds a tenth of the font size. Also
7848
+ * `tracking`, its former name.
7849
+ */
7850
+ letterTracking: number
7851
+
7852
+ /**
7853
+ * @deprecated use {@link #letterTracking} instead.
6921
7854
  */
6922
7855
  tracking: number
6923
7856
 
7857
+ /**
7858
+ * The letter kerning of text content: the space added after a letter,
7859
+ * along the line, in thousandths of an em, in place of the font's own
7860
+ * kerning pair; `null` for the font's kerning.
7861
+ */
7862
+ letterKerning: number
7863
+
7864
+ /**
7865
+ * The font style of text content, as in CSS: upright or slanted. Together
7866
+ * with the {@link #fontWeight}, it says what a font's style name says, e.g.
7867
+ * `'Bold Italic'`.
7868
+ */
7869
+ fontStyle: string
7870
+
7871
+ /**
7872
+ * The settings of a variable font's axes, by their tags: `{ wght: 600,
7873
+ * wdth: 80 }`. Kept for hosts that lay text out with its fonts; canvas
7874
+ * doesn't draw them.
7875
+ */
7876
+ fontVariations: any
7877
+
7878
+ /**
7879
+ * How far the letters move up from the baseline, in pixels.
7880
+ */
7881
+ baselineShift: number
7882
+
7883
+ /**
7884
+ * Whether the letters are set as superscripts or subscripts: smaller, and
7885
+ * above or below the baseline.
7886
+ */
7887
+ baselinePosition: string
7888
+
7889
+ /**
7890
+ * How much the letters are scaled, as {@link Item#scaling}: one factor for
7891
+ * both directions, or a point with the horizontal and vertical ones.
7892
+ */
7893
+ get letterScaling(): number | Point
7894
+ set letterScaling(value: number | PointLike)
7895
+
7896
+ /**
7897
+ * The rotation of each letter about its origin on the baseline, in degrees.
7898
+ */
7899
+ letterRotation: number
7900
+
7901
+ /**
7902
+ * Whether the letters are set as capitals, or as small capitals.
7903
+ */
7904
+ capitals: string
7905
+
7906
+ /**
7907
+ * Whether the letters are underlined.
7908
+ */
7909
+ underline: boolean
7910
+
7911
+ /**
7912
+ * Whether the letters are struck through.
7913
+ */
7914
+ strikethrough: boolean
7915
+
7916
+ /**
7917
+ * The OpenType features to turn on (`'dlig'`) or off (`'-liga'`). Kept for
7918
+ * hosts that lay text out with its fonts; canvas doesn't draw them.
7919
+ */
7920
+ features: string[]
7921
+
6924
7922
  /**
6925
7923
  * The justification of text paragraphs.
6926
7924
  */
6927
7925
  justification: string
6928
7926
 
7927
+ /**
7928
+ * How the last line of a justified paragraph is aligned; `'all'` justifies
7929
+ * it too.
7930
+ */
7931
+ justifyLast: string
7932
+
7933
+ /**
7934
+ * How far justification may change the spacing, each as `[minimum, desired,
7935
+ * maximum]` in percent: `{ word: [80, 100, 133], letter: [0, 0, 0], glyph:
7936
+ * [100, 100, 100] }`; `null` for those. Kept for hosts: canvas text
7937
+ * justifies by the word spacing alone.
7938
+ */
7939
+ justifySpacing: any
7940
+
7941
+ /**
7942
+ * The indent where the paragraph's lines start: left in left-to-right text,
7943
+ * right in right-to-left text.
7944
+ */
7945
+ startIndent: number
7946
+
7947
+ /**
7948
+ * The indent where the paragraph's lines end.
7949
+ */
7950
+ endIndent: number
7951
+
7952
+ /**
7953
+ * The indent of the paragraph's first line, added to its start indent.
7954
+ */
7955
+ firstLineIndent: number
7956
+
7957
+ /**
7958
+ * The space above the paragraph. Between two paragraphs, the larger of this
7959
+ * one's and the space after the one before it is used.
7960
+ */
7961
+ spaceBefore: number
7962
+
7963
+ /**
7964
+ * The space below the paragraph.
7965
+ */
7966
+ spaceAfter: number
7967
+
7968
+ /**
7969
+ * Whether words are hyphenated at the ends of lines, and how: `true`, or `{
7970
+ * wordsLongerThan, afterFirst, beforeLast, limit, zone, capitalized }`.
7971
+ * Kept for hosts: canvas text breaks only at soft hyphens.
7972
+ */
7973
+ hyphenation: boolean | any
7974
+
7975
+ /**
7976
+ * How lines are broken: one line at a time, or all of the paragraph's lines
7977
+ * together, for the most even spacing. Kept for hosts: canvas text breaks
7978
+ * one line at a time.
7979
+ */
7980
+ composer: string
7981
+
7982
+ /**
7983
+ * How the lines of a paragraph in an area are evened out: `'normal'`
7984
+ * fills each line as far as it goes, `'balance'` makes them all about as
7985
+ * long, and `'pretty'` balances the last four lines when the last one is
7986
+ * shorter than a third of the one before. Both keep the paragraph's number
7987
+ * of lines.
7988
+ */
7989
+ lineWrap: string
7990
+
7991
+ /**
7992
+ * The paragraph's tab stops: `[{ position, align, leader }]`, with `align`
7993
+ * one of `'left'`, `'center'`, `'right'` and `'decimal'`. Kept for hosts:
7994
+ * canvas text doesn't set tabs yet.
7995
+ */
7996
+ tabs: object[]
7997
+
7998
+ /**
7999
+ * The direction the paragraph's lines run in, which `'start'` and `'end'`
8000
+ * follow; `null` for left to right.
8001
+ */
8002
+ direction: string
8003
+
6929
8004
 
6930
8005
  /**
6931
8006
  * Style objects don't need to be created directly. Just pass an object to
@@ -6954,6 +8029,11 @@ declare namespace paper {
6954
8029
  */
6955
8030
  item: Item
6956
8031
 
8032
+ /**
8033
+ * @deprecated use {@link #item} instead.
8034
+ */
8035
+ definition: Item
8036
+
6957
8037
 
6958
8038
  /**
6959
8039
  * Creates a Symbol definition.
@@ -6996,6 +8076,11 @@ declare namespace paper {
6996
8076
  */
6997
8077
  definition: SymbolDefinition
6998
8078
 
8079
+ /**
8080
+ * @deprecated use {@link #definition} instead.
8081
+ */
8082
+ symbol: SymbolDefinition
8083
+
6999
8084
 
7000
8085
  /**
7001
8086
  * Creates a new symbol item.
@@ -7010,16 +8095,54 @@ declare namespace paper {
7010
8095
 
7011
8096
  /**
7012
8097
  * The TextItem type allows you to create typography. Its functionality
7013
- * is inherited by different text item types such as {@link PointText}, and
7014
- * {@link AreaText} (coming soon). They each add a layer of functionality
7015
- * that is unique to their type, but share the underlying properties and
7016
- * functions that they inherit from TextItem.
8098
+ * is inherited by different text item types such as {@link PointText},
8099
+ * {@link PathText} and {@link AreaText}. They each add a layer of
8100
+ * functionality that is unique to their type, but share the underlying
8101
+ * properties and functions that they inherit from TextItem.
7017
8102
  */
7018
8103
  class TextItem extends Item {
7019
8104
  /**
7020
- * The text contents of the text item.
8105
+ * The direction the text's lines run in: `'horizontal'`, or `'vertical'`
8106
+ * from top to bottom, with the lines from right to left.
7021
8107
  */
7022
- content: string
8108
+ orientation: string
8109
+
8110
+ /**
8111
+ * The path that the text flows in ({@link AreaText}) or along
8112
+ * ({@link PathText}). It guides the text and isn't drawn itself.
8113
+ */
8114
+ textPath: PathItem
8115
+
8116
+ /**
8117
+ * The story the text item shows: the text of all the text items linked
8118
+ * with it.
8119
+ */
8120
+ readonly story: TextStory
8121
+
8122
+ /**
8123
+ * The text item after this one in its story, if any.
8124
+ */
8125
+ readonly nextTextItem: TextItem
8126
+
8127
+ /**
8128
+ * The text item before this one in its story, if any.
8129
+ */
8130
+ readonly previousTextItem: TextItem
8131
+
8132
+ /**
8133
+ * The range of the story that this text item shows, as its layout flows
8134
+ * the story through the linked text items: without the overflow, and
8135
+ * without what the ones before it show.
8136
+ */
8137
+ readonly visibleRange: TextRange
8138
+
8139
+ /**
8140
+ * The lines of the text, as its layout breaks them: each a range of its
8141
+ * story, with its `baseline`, a {@link Line} along it, and its `bounds`,
8142
+ * in the text item's own coordinates. A {@link PathText}'s one line
8143
+ * follows its path: these describe it laid out straight.
8144
+ */
8145
+ readonly lines: TextRange[]
7023
8146
 
7024
8147
  /**
7025
8148
  * The font-family to be used in text content.
@@ -7038,22 +8161,372 @@ declare namespace paper {
7038
8161
  fontSize: number | string
7039
8162
 
7040
8163
  /**
7041
- * The text leading of text content.
8164
+ * The font-family to be used in text content, as one string.
8165
+ *
8166
+ * @deprecated use {@link #fontFamily} instead.
7042
8167
  */
7043
- leading: number | string
8168
+ font: string
7044
8169
 
7045
8170
  /**
7046
- * The tracking of text content: the space added after each character, in
7047
- * thousandths of an em, as in Adobe Illustrator and InDesign. A tracking of
7048
- * 100 adds a tenth of the font size.
8171
+ * The line height of text content: the distance from one line's baseline
8172
+ * to the next. Automatic, as `'auto'` (1.2) or another factor of the
8173
+ * letters' font size, each line moving down by its largest letters'; or
8174
+ * fixed, as a length with units as the font size takes them (`'18px'`,
8175
+ * `'12pt'`). `leading`, as Paper.js had it before, sets and reads it as a
8176
+ * fixed length in pixels.
7049
8177
  */
7050
- tracking: number
8178
+ lineHeight: number | string
8179
+
8180
+ /**
8181
+ * The letter tracking of text content: the space added after each letter,
8182
+ * along the line, in thousandths of an em, as in Adobe Illustrator and
8183
+ * InDesign. A tracking of 100 adds a tenth of the font size. Also
8184
+ * `tracking`, its former name.
8185
+ */
8186
+ letterTracking: number
8187
+
8188
+ /**
8189
+ * The letter kerning of text content: the space added after a letter,
8190
+ * along the line, in thousandths of an em, in place of the font's own
8191
+ * kerning pair; `null` for the font's kerning.
8192
+ */
8193
+ letterKerning: number
8194
+
8195
+ /**
8196
+ * The font style of text content, as in CSS: upright or slanted. Together
8197
+ * with the {@link #fontWeight}, it says what a font's style name says, e.g.
8198
+ * `'Bold Italic'`.
8199
+ */
8200
+ fontStyle: string
8201
+
8202
+ /**
8203
+ * The settings of a variable font's axes, by their tags: `{ wght: 600,
8204
+ * wdth: 80 }`. Kept for hosts that lay text out with its fonts; canvas
8205
+ * doesn't draw them.
8206
+ */
8207
+ fontVariations: any
8208
+
8209
+ /**
8210
+ * How far the letters move up from the baseline, in pixels.
8211
+ */
8212
+ baselineShift: number
8213
+
8214
+ /**
8215
+ * Whether the letters are set as superscripts or subscripts: smaller, and
8216
+ * above or below the baseline.
8217
+ */
8218
+ baselinePosition: string
8219
+
8220
+ /**
8221
+ * How much the letters are scaled, as {@link Item#scaling}: one factor for
8222
+ * both directions, or a point with the horizontal and vertical ones.
8223
+ */
8224
+ get letterScaling(): number | Point
8225
+ set letterScaling(value: number | PointLike)
8226
+
8227
+ /**
8228
+ * The rotation of each letter about its origin on the baseline, in degrees.
8229
+ */
8230
+ letterRotation: number
8231
+
8232
+ /**
8233
+ * Whether the letters are set as capitals, or as small capitals.
8234
+ */
8235
+ capitals: string
8236
+
8237
+ /**
8238
+ * Whether the letters are underlined.
8239
+ */
8240
+ underline: boolean
8241
+
8242
+ /**
8243
+ * Whether the letters are struck through.
8244
+ */
8245
+ strikethrough: boolean
8246
+
8247
+ /**
8248
+ * The OpenType features to turn on (`'dlig'`) or off (`'-liga'`). Kept for
8249
+ * hosts that lay text out with its fonts; canvas doesn't draw them.
8250
+ */
8251
+ features: string[]
7051
8252
 
7052
8253
  /**
7053
8254
  * The justification of text paragraphs.
7054
8255
  */
7055
8256
  justification: string
7056
8257
 
8258
+ /**
8259
+ * How the last line of a justified paragraph is aligned; `'all'` justifies
8260
+ * it too.
8261
+ */
8262
+ justifyLast: string
8263
+
8264
+ /**
8265
+ * How far justification may change the spacing, each as `[minimum, desired,
8266
+ * maximum]` in percent: `{ word: [80, 100, 133], letter: [0, 0, 0], glyph:
8267
+ * [100, 100, 100] }`; `null` for those. Kept for hosts: canvas text
8268
+ * justifies by the word spacing alone.
8269
+ */
8270
+ justifySpacing: any
8271
+
8272
+ /**
8273
+ * The indent where the paragraph's lines start: left in left-to-right text,
8274
+ * right in right-to-left text.
8275
+ */
8276
+ startIndent: number
8277
+
8278
+ /**
8279
+ * The indent where the paragraph's lines end.
8280
+ */
8281
+ endIndent: number
8282
+
8283
+ /**
8284
+ * The indent of the paragraph's first line, added to its start indent.
8285
+ */
8286
+ firstLineIndent: number
8287
+
8288
+ /**
8289
+ * The space above the paragraph. Between two paragraphs, the larger of this
8290
+ * one's and the space after the one before it is used.
8291
+ */
8292
+ spaceBefore: number
8293
+
8294
+ /**
8295
+ * The space below the paragraph.
8296
+ */
8297
+ spaceAfter: number
8298
+
8299
+ /**
8300
+ * Whether words are hyphenated at the ends of lines, and how: `true`, or `{
8301
+ * wordsLongerThan, afterFirst, beforeLast, limit, zone, capitalized }`.
8302
+ * Kept for hosts: canvas text breaks only at soft hyphens.
8303
+ */
8304
+ hyphenation: boolean | any
8305
+
8306
+ /**
8307
+ * How lines are broken: one line at a time, or all of the paragraph's lines
8308
+ * together, for the most even spacing. Kept for hosts: canvas text breaks
8309
+ * one line at a time.
8310
+ */
8311
+ composer: string
8312
+
8313
+ /**
8314
+ * How the lines of a paragraph in an area are evened out: `'normal'`
8315
+ * fills each line as far as it goes, `'balance'` makes them all about as
8316
+ * long, and `'pretty'` balances the last four lines when the last one is
8317
+ * shorter than a third of the one before. Both keep the paragraph's number
8318
+ * of lines.
8319
+ */
8320
+ lineWrap: string
8321
+
8322
+ /**
8323
+ * The paragraph's tab stops: `[{ position, align, leader }]`, with `align`
8324
+ * one of `'left'`, `'center'`, `'right'` and `'decimal'`. Kept for hosts:
8325
+ * canvas text doesn't set tabs yet.
8326
+ */
8327
+ tabs: object[]
8328
+
8329
+ /**
8330
+ * The direction the paragraph's lines run in, which `'start'` and `'end'`
8331
+ * follow; `null` for left to right.
8332
+ */
8333
+ direction: string
8334
+
8335
+ /**
8336
+ * The line height as a fixed length, in pixels: setting a number makes it
8337
+ * fixed, as `'18px'`.
8338
+ *
8339
+ * @deprecated use {@link #lineHeight} instead.
8340
+ */
8341
+ leading: number
8342
+
8343
+ /**
8344
+ * @deprecated use {@link #letterTracking} instead.
8345
+ */
8346
+ tracking: number
8347
+
8348
+ /**
8349
+ * The text of the item's story, see {@link TextStory#content}.
8350
+ */
8351
+ content: string
8352
+
8353
+ /**
8354
+ * The runs of the item's story, see {@link TextStory#runs}.
8355
+ */
8356
+ runs: TextRange[]
8357
+
8358
+ /**
8359
+ * The paragraphs of the item's story, see {@link TextStory#paragraphs}.
8360
+ */
8361
+ paragraphs: TextRange[]
8362
+
8363
+ /**
8364
+ * The words of the item's story, see {@link TextStory#words}.
8365
+ */
8366
+ words: TextRange[]
8367
+
8368
+ /**
8369
+ * The letters of the item's story, see {@link TextStory#letters}.
8370
+ */
8371
+ letters: TextRange[]
8372
+
8373
+ /**
8374
+ * @deprecated use {@link #style} instead.
8375
+ */
8376
+ characterStyle: Style
8377
+
8378
+ /**
8379
+ * @deprecated use {@link #style} instead.
8380
+ */
8381
+ paragraphStyle: Style
8382
+
8383
+
8384
+ /**
8385
+ * Links the text item `next` after this one, so the story flows on into
8386
+ * it. Its own story joins the end of this one.
8387
+ *
8388
+ * @param next - the text item to link
8389
+ *
8390
+ * @return true if the text item was linked
8391
+ */
8392
+ link(next: TextItem): boolean
8393
+
8394
+ /**
8395
+ * {@true if the text item is linked with others}
8396
+ */
8397
+ isLinked(): boolean
8398
+
8399
+ /**
8400
+ * Unlinks the text item: `'both'` takes it out of its story, which flows
8401
+ * on through the others, `'before'` and `'after'` break the story into
8402
+ * two there.
8403
+ *
8404
+ * @param which - `'both'`, `'before'` or `'after'`
8405
+ *
8406
+ * @return true if the text item was unlinked
8407
+ */
8408
+ unlink(which?: string): boolean
8409
+
8410
+ /**
8411
+ * Replaces the content from `start` to `end` of the item's story, see
8412
+ * {@link TextStory#replace}.
8413
+ *
8414
+ * @param content - the new content
8415
+ * @param start - the index of the first character to replace
8416
+ * @param end - the index after the last character to replace
8417
+ */
8418
+ replace(content: string, start: number, end: number): void
8419
+
8420
+ /**
8421
+ * The range of the item's story from `start` to `end`.
8422
+ *
8423
+ * @param start - the index of its first character
8424
+ * @param end - the index after its last character
8425
+ */
8426
+ range(start: number, end: number): TextRange
8427
+
8428
+ }
8429
+
8430
+ /**
8431
+ * A part of a {@link TextStory}'s content, from its {@link #start}
8432
+ * to its {@link #end}, whose style is that of its letters and paragraphs:
8433
+ * read, a property is the one they share, or `undefined`; set, it changes
8434
+ * them. It has the same style properties as items, e.g.
8435
+ * `text.words[0].fontSize = 24`. A range is a snapshot of two indices:
8436
+ * changing styles never moves it, but changing the content leaves ranges
8437
+ * taken before out of date, as indices into any string.
8438
+ */
8439
+ class TextRange {
8440
+ /**
8441
+ * The story the range is part of.
8442
+ */
8443
+ readonly story: TextStory
8444
+
8445
+ /**
8446
+ * The index of the range's first character.
8447
+ */
8448
+ readonly start: number
8449
+
8450
+ /**
8451
+ * The index after the range's last character.
8452
+ */
8453
+ readonly end: number
8454
+
8455
+ /**
8456
+ * The content of the range.
8457
+ */
8458
+ readonly content: string
8459
+
8460
+ /**
8461
+ * The style of the range: of its characters, and of the paragraphs it
8462
+ * touches.
8463
+ */
8464
+ style: Style
8465
+
8466
+
8467
+ }
8468
+
8469
+ /**
8470
+ * The text of one or more linked {@link TextItem}s, which it flows
8471
+ * through in order: its content, kept in runs of characters that share a
8472
+ * style, and the styles of its paragraphs. A text item that isn't linked
8473
+ * has a story of its own.
8474
+ */
8475
+ class TextStory {
8476
+ /**
8477
+ * The text items that the story flows through, in order.
8478
+ */
8479
+ readonly textItems: TextItem[]
8480
+
8481
+ /**
8482
+ * The text of the story, from the first of its text items to the last.
8483
+ */
8484
+ content: string
8485
+
8486
+ /**
8487
+ * The runs of the text: its ranges that each have one style throughout.
8488
+ * Set it to plain objects with a `content` and style properties, which
8489
+ * then make the whole text.
8490
+ */
8491
+ runs: TextRange[]
8492
+
8493
+ /**
8494
+ * The paragraphs of the text, without their line breaks. Set it to plain
8495
+ * objects with paragraph style properties, one per paragraph.
8496
+ */
8497
+ paragraphs: TextRange[]
8498
+
8499
+ /**
8500
+ * The words of the text, as the browser finds them (Intl.Segmenter), or
8501
+ * else separated by white space.
8502
+ */
8503
+ readonly words: TextRange[]
8504
+
8505
+ /**
8506
+ * The letters of the text, each as readers see one (a grapheme: an emoji,
8507
+ * or a letter with its accents), spaces and punctuation included.
8508
+ */
8509
+ readonly letters: TextRange[]
8510
+
8511
+
8512
+ /**
8513
+ * Replaces the content from `start` to `end`, or of a range, with new
8514
+ * content, which takes the style of the content it replaces, or of the
8515
+ * character before it when it's inserted.
8516
+ *
8517
+ * @param content - the new content
8518
+ * @param start - the index of the first character to replace
8519
+ * @param end - the index after the last character to replace
8520
+ */
8521
+ replace(content: string, start: number, end: number): void
8522
+
8523
+ /**
8524
+ * The range of the text from `start` to `end`.
8525
+ *
8526
+ * @param start - the index of its first character
8527
+ * @param end - the index after its last character
8528
+ */
8529
+ range(start: number, end: number): TextRange
7057
8530
 
7058
8531
  }
7059
8532
 
@@ -7268,19 +8741,22 @@ declare namespace paper {
7268
8741
  * The position of the mouse in project coordinates when the event was
7269
8742
  * fired.
7270
8743
  */
7271
- point: Point
8744
+ get point(): Point
8745
+ set point(value: PointLike)
7272
8746
 
7273
8747
  /**
7274
8748
  * The position of the mouse in project coordinates when the previous
7275
8749
  * event was fired.
7276
8750
  */
7277
- lastPoint: Point
8751
+ get lastPoint(): Point
8752
+ set lastPoint(value: PointLike)
7278
8753
 
7279
8754
  /**
7280
8755
  * The position of the mouse in project coordinates when the mouse button
7281
8756
  * was last clicked.
7282
8757
  */
7283
- downPoint: Point
8758
+ get downPoint(): Point
8759
+ set downPoint(value: PointLike)
7284
8760
 
7285
8761
  /**
7286
8762
  * The point in the middle between {@link #lastPoint} and
@@ -7288,14 +8764,37 @@ declare namespace paper {
7288
8764
  * artwork based on the moving direction of the mouse, as returned by
7289
8765
  * {@link #delta}.
7290
8766
  */
7291
- middlePoint: Point
8767
+ get middlePoint(): Point
8768
+ set middlePoint(value: PointLike)
7292
8769
 
7293
8770
  /**
7294
8771
  * The difference between the current position and the last position of the
7295
8772
  * mouse when the event was fired. In case of the mouseup event, the
7296
8773
  * difference to the mousedown position is returned.
7297
8774
  */
7298
- delta: Point
8775
+ get delta(): Point
8776
+ set delta(value: PointLike)
8777
+
8778
+ /**
8779
+ * The velocity of the mouse, in points per second: the distance it moved
8780
+ * since the last tool event, divided by the time between them, so it
8781
+ * points in the direction of the move, and its length is the speed. It
8782
+ * stays even when the system misses a mouse report. The events that
8783
+ * {@link Tool#maxDistance} adds along one move share its velocity, and the
8784
+ * repeats of {@link Tool#eventInterval} have none. On mousedown, and when
8785
+ * no time passed, it's zero.
8786
+ */
8787
+ get velocity(): Point
8788
+ set velocity(value: PointLike)
8789
+
8790
+ /**
8791
+ * The time since the last tool event, in seconds, measured between the
8792
+ * reports of the mouse as {@link #velocity} is: the events that
8793
+ * {@link Tool#maxDistance} adds along one move share it, and the repeats
8794
+ * of {@link Tool#eventInterval} have the interval. It's zero on the first
8795
+ * event.
8796
+ */
8797
+ elapsed: number
7299
8798
 
7300
8799
  /**
7301
8800
  * The number of times the mouse event was fired.
@@ -7433,12 +8932,18 @@ declare namespace paper {
7433
8932
  * The size of the view. Changing the view's size will resize it's
7434
8933
  * underlying element.
7435
8934
  */
7436
- viewSize: Size
8935
+ get viewSize(): Size
8936
+ set viewSize(value: SizeLike)
7437
8937
 
7438
8938
  /**
7439
8939
  * The bounds of the currently visible area in project coordinates.
8940
+ * Setting them fits the view to the given rectangle, as
8941
+ * {@link #fitBounds} does. Since the view keeps its aspect
8942
+ * ratio, the bounds read back can be larger than the rectangle in one
8943
+ * direction.
7440
8944
  */
7441
- readonly bounds: Rectangle
8945
+ get bounds(): Rectangle
8946
+ set bounds(value: RectangleLike)
7442
8947
 
7443
8948
  /**
7444
8949
  * The size of the visible area in project coordinates.
@@ -7448,7 +8953,8 @@ declare namespace paper {
7448
8953
  /**
7449
8954
  * The center of the visible area in project coordinates.
7450
8955
  */
7451
- center: Point
8956
+ get center(): Point
8957
+ set center(value: PointLike)
7452
8958
 
7453
8959
  /**
7454
8960
  * The view's zoom factor by which the project coordinates are magnified.
@@ -7470,7 +8976,8 @@ declare namespace paper {
7470
8976
  *
7471
8977
  * @see #zoom
7472
8978
  */
7473
- scaling: Point
8979
+ get scaling(): Point
8980
+ set scaling(value: PointLike)
7474
8981
 
7475
8982
  /**
7476
8983
  * The view's transformation matrix, defining the view onto the project's
@@ -7634,6 +9141,13 @@ declare namespace paper {
7634
9141
  */
7635
9142
  update(force?: boolean): boolean
7636
9143
 
9144
+ /**
9145
+ * Updates the view if there are changes.
9146
+ *
9147
+ * @deprecated use {@link #update} instead.
9148
+ */
9149
+ draw(): void
9150
+
7637
9151
  /**
7638
9152
  * Requests an update of the view if there are changes through the browser's
7639
9153
  * requestAnimationFrame() mechanism for smooth animation. Note that when
@@ -7676,6 +9190,13 @@ declare namespace paper {
7676
9190
  */
7677
9191
  translate(delta: PointLike): void
7678
9192
 
9193
+ /**
9194
+ * Translates (scrolls) the view by the given offset vector.
9195
+ *
9196
+ * @param delta - the offset to translate the view by
9197
+ */
9198
+ translate(x: number, y: number): void
9199
+
7679
9200
  /**
7680
9201
  * Rotates the view by a given angle around the given center point.
7681
9202
  *
@@ -7766,6 +9287,22 @@ declare namespace paper {
7766
9287
  */
7767
9288
  fitBounds(rectangle: RectangleLike, fit?: string): void
7768
9289
 
9290
+ /**
9291
+ * Scrolls the view by the given vector.
9292
+ *
9293
+ * @deprecated use {@link #translate} instead (using opposite
9294
+ * direction).
9295
+ */
9296
+ scrollBy(point: PointLike): void
9297
+
9298
+ /**
9299
+ * Scrolls the view by the given vector.
9300
+ *
9301
+ * @deprecated use {@link #translate} instead (using opposite
9302
+ * direction).
9303
+ */
9304
+ scrollBy(x: number, y: number): void
9305
+
7769
9306
  /**
7770
9307
  * Converts the passed point from project coordinate space to view
7771
9308
  * coordinate space, which is measured in browser pixels in relation to the
@@ -7777,6 +9314,17 @@ declare namespace paper {
7777
9314
  */
7778
9315
  projectToView(point: PointLike): Point
7779
9316
 
9317
+ /**
9318
+ * Converts the passed point from project coordinate space to view
9319
+ * coordinate space, which is measured in browser pixels in relation to the
9320
+ * position of the view element.
9321
+ *
9322
+ * @param point - the point in project coordinates to be converted
9323
+ *
9324
+ * @return the point converted into view coordinates
9325
+ */
9326
+ projectToView(x: number, y: number): Point
9327
+
7780
9328
  /**
7781
9329
  * Converts the passed point from view coordinate space to project
7782
9330
  * coordinate space.
@@ -7787,6 +9335,16 @@ declare namespace paper {
7787
9335
  */
7788
9336
  viewToProject(point: PointLike): Point
7789
9337
 
9338
+ /**
9339
+ * Converts the passed point from view coordinate space to project
9340
+ * coordinate space.
9341
+ *
9342
+ * @param point - the point in view coordinates to be converted
9343
+ *
9344
+ * @return the point converted into project coordinates
9345
+ */
9346
+ viewToProject(x: number, y: number): Point
9347
+
7790
9348
  /**
7791
9349
  * Determines and returns the event location in project coordinate space.
7792
9350
  *
@@ -7875,12 +9433,15 @@ declare namespace paper {
7875
9433
  * with {@link Tool#minDistance} and the like, then those of the items
7876
9434
  * under the point and of the view, including the events that Paper.js
7877
9435
  * derives itself: `'mousedrag'`, `'click'`, `'doubleclick'`,
7878
- * `'mouseenter'` and `'mouseleave'`.
9436
+ * `'mouseenter'` and `'mouseleave'`. Points outside the view's bounds
9437
+ * are handled too, since the host decides which events belong to its
9438
+ * drawing surface.
7879
9439
  *
7880
9440
  * @option [options.modifiers] {Object} the state of the modifier keys,
7881
9441
  * see {@link Key#modifiers}
7882
9442
  * @option [options.button=0] {Number} the mouse button
7883
- * @option [options.timeStamp=Date.now()] {Number} the time stamp
9443
+ * @option [options.time=Date.now() / 1000] {Number} the time of the
9444
+ * event in seconds, see {@link Event#time}
7884
9445
  *
7885
9446
  * @param type - the type of the event: {@values 'mousedown',
7886
9447
  * 'mousemove', 'mouseup'}
@@ -7889,7 +9450,7 @@ declare namespace paper {
7889
9450
  *
7890
9451
  * @return true if a handler prevented the event's default
7891
9452
  */
7892
- dispatchMouseEvent(type: string, point: PointLike, options?: object): boolean
9453
+ dispatchMouseEvent(type: string, point: PointLike, options?: { modifiers?: object, button?: number, time?: number }): boolean
7893
9454
 
7894
9455
  /**
7895
9456
  * Handles a key event that the host provides, for hosts without a DOM,
@@ -7899,17 +9460,20 @@ declare namespace paper {
7899
9460
  *
7900
9461
  * @option [options.character] {String} the character that the key
7901
9462
  * produces. By default, keydown takes the key itself if it is a
7902
- * single character, and keyup the character of its keydown
9463
+ * single character, the space, carriage return and tab characters
9464
+ * for 'space', 'enter' and 'tab', and keyup the character of its
9465
+ * keydown
7903
9466
  * @option [options.modifiers] {Object} the state of the modifier keys,
7904
9467
  * see {@link Key#modifiers}
7905
- * @option [options.timeStamp=Date.now()] {Number} the time stamp
9468
+ * @option [options.time=Date.now() / 1000] {Number} the time of the
9469
+ * event in seconds, see {@link Event#time}
7906
9470
  *
7907
9471
  * @param type - the type of the event: {@values 'keydown',
7908
9472
  * 'keyup'}
7909
9473
  * @param key - the key, as in {@link KeyEvent#key}
7910
9474
  * @param options - the details of the event
7911
9475
  */
7912
- dispatchKeyEvent(type: string, key: string, options?: object): void
9476
+ dispatchKeyEvent(type: string, key: string, options?: { character?: string, modifiers?: object, time?: number }): void
7913
9477
 
7914
9478
  }
7915
9479
  }