paper 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +337 -0
  2. package/README.md +19 -14
  3. package/dist/docs/assets/js/paper.js +7351 -1706
  4. package/dist/docs/classes/AreaText.html +8658 -0
  5. package/dist/docs/classes/ChangeFlag.html +385 -0
  6. package/dist/docs/classes/Color.html +2 -1
  7. package/dist/docs/classes/CompoundPath.html +208 -69
  8. package/dist/docs/classes/Curve.html +2 -1
  9. package/dist/docs/classes/CurveLocation.html +2 -1
  10. package/dist/docs/classes/Event.html +5 -4
  11. package/dist/docs/classes/Gradient.html +2 -1
  12. package/dist/docs/classes/GradientStop.html +2 -1
  13. package/dist/docs/classes/Group.html +204 -17
  14. package/dist/docs/classes/HitResult.html +4 -2
  15. package/dist/docs/classes/HostItem.html +6786 -0
  16. package/dist/docs/classes/Item.html +193 -17
  17. package/dist/docs/classes/Key.html +2 -1
  18. package/dist/docs/classes/KeyEvent.html +5 -4
  19. package/dist/docs/classes/Layer.html +201 -17
  20. package/dist/docs/classes/Matrix.html +2 -1
  21. package/dist/docs/classes/MouseEvent.html +5 -4
  22. package/dist/docs/classes/PaperScope.html +5 -2
  23. package/dist/docs/classes/PaperScript.html +6 -2
  24. package/dist/docs/classes/Path.html +183 -70
  25. package/dist/docs/classes/PathItem.html +326 -187
  26. package/dist/docs/classes/PathText.html +8528 -0
  27. package/dist/docs/classes/Point.html +13 -2
  28. package/dist/docs/classes/PointText.html +1404 -63
  29. package/dist/docs/classes/Project.html +221 -1
  30. package/dist/docs/classes/Raster.html +136 -17
  31. package/dist/docs/classes/Rectangle.html +3 -2
  32. package/dist/docs/classes/Segment.html +2 -1
  33. package/dist/docs/classes/Shape.html +136 -17
  34. package/dist/docs/classes/Size.html +4 -2
  35. package/dist/docs/classes/Style.html +768 -15
  36. package/dist/docs/classes/SymbolDefinition.html +2 -1
  37. package/dist/docs/classes/SymbolItem.html +136 -17
  38. package/dist/docs/classes/TextItem.html +1566 -222
  39. package/dist/docs/classes/TextRange.html +186 -0
  40. package/dist/docs/classes/TextStory.html +355 -0
  41. package/dist/docs/classes/Tool.html +127 -1
  42. package/dist/docs/classes/ToolEvent.html +57 -4
  43. package/dist/docs/classes/Tween.html +17 -1
  44. package/dist/docs/classes/View.html +148 -5
  45. package/dist/docs/classes/global.html +2 -1
  46. package/dist/docs/classes/index.html +2 -2
  47. package/dist/docs/index.html +1 -1
  48. package/dist/paper-core.js +7160 -1663
  49. package/dist/paper-core.min.js +3 -3
  50. package/dist/paper-full.js +7351 -1706
  51. package/dist/paper-full.min.js +3 -3
  52. package/dist/paper-hosted.js +24058 -0
  53. package/dist/paper.d.ts +1996 -155
  54. package/examples/Scripts/AreaText.html +65 -0
  55. package/examples/Scripts/PathText.html +48 -0
  56. package/examples/Scripts/TextRanges.html +51 -0
  57. package/package.json +8 -11
package/dist/paper.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Paper.js v0.13.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: Mon Oct 19 15:31:53 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,176 @@ 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
+
139
+
140
+ class ChangeFlag {
141
+ /**
142
+ * Anything affecting the appearance of an item, including GEOMETRY,
143
+ * STROKE, STYLE and ATTRIBUTE (except for the invisible ones: locked, name)
144
+ */
145
+ static APPEARANCE: number
146
+
147
+ /**
148
+ * A change in the item's children
149
+ */
150
+ static CHILDREN: number
151
+
152
+ /**
153
+ * A change of the item's place in the scene graph (removed, inserted,
154
+ * moved)
155
+ */
156
+ static INSERTION: number
157
+
158
+ /**
159
+ * Item geometry (path, bounds)
160
+ */
161
+ static GEOMETRY: number
162
+
163
+ /**
164
+ * The item's matrix has changed
165
+ */
166
+ static MATRIX: number
167
+
168
+ /**
169
+ * Only segment(s) have changed, and affected curves have already been
170
+ * notified. This is to implement an optimization in _changed() calls
171
+ */
172
+ static SEGMENTS: number
173
+
174
+ /**
175
+ * Stroke geometry (excluding color)
176
+ */
177
+ static STROKE: number
178
+
179
+ /**
180
+ * Fill style or stroke color / dash
181
+ */
182
+ static STYLE: number
183
+
184
+ /**
185
+ * Item attributes: visible, blendMode, locked, name, opacity, clipMask ...
186
+ */
187
+ static ATTRIBUTE: number
188
+
189
+ /**
190
+ * Text content
191
+ */
192
+ static CONTENT: number
193
+
194
+ /**
195
+ * Raster pixels
196
+ */
197
+ static PIXELS: number
198
+
199
+ /**
200
+ * Clipping in one of the child items
201
+ */
202
+ static CLIPPING: number
203
+
204
+ /**
205
+ * The view has been transformed
206
+ */
207
+ static VIEW: number
208
+
209
+
210
+ }
211
+
41
212
  /**
42
213
  * All properties and functions that expect color values in the form
43
214
  * of instances of Color objects, also accept named colors and hex values as
@@ -112,7 +283,8 @@ declare namespace paper {
112
283
  /**
113
284
  * The highlight point of the gradient.
114
285
  */
115
- highlight: Point
286
+ get highlight(): Point
287
+ set highlight(value: PointLike)
116
288
 
117
289
 
118
290
  /**
@@ -456,22 +628,26 @@ declare namespace paper {
456
628
  /**
457
629
  * The first anchor point of the curve.
458
630
  */
459
- point1: Point
631
+ get point1(): Point
632
+ set point1(value: PointLike)
460
633
 
461
634
  /**
462
635
  * The second anchor point of the curve.
463
636
  */
464
- point2: Point
637
+ get point2(): Point
638
+ set point2(value: PointLike)
465
639
 
466
640
  /**
467
641
  * The handle point that describes the tangent in the first anchor point.
468
642
  */
469
- handle1: Point
643
+ get handle1(): Point
644
+ set handle1(value: PointLike)
470
645
 
471
646
  /**
472
647
  * The handle point that describes the tangent in the second anchor point.
473
648
  */
474
- handle2: Point
649
+ get handle2(): Point
650
+ set handle2(value: PointLike)
475
651
 
476
652
  /**
477
653
  * The first segment of the curve.
@@ -541,12 +717,14 @@ declare namespace paper {
541
717
  /**
542
718
  * The bounding rectangle of the curve excluding stroke width.
543
719
  */
544
- bounds: Rectangle
720
+ get bounds(): Rectangle
721
+ set bounds(value: RectangleLike)
545
722
 
546
723
  /**
547
724
  * The bounding rectangle of the curve including stroke width.
548
725
  */
549
- strokeBounds: Rectangle
726
+ get strokeBounds(): Rectangle
727
+ set strokeBounds(value: RectangleLike)
550
728
 
551
729
  /**
552
730
  * The bounding rectangle of the curve including handles.
@@ -681,6 +859,18 @@ declare namespace paper {
681
859
  */
682
860
  splitAtTime(time: number): Path
683
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
+
684
874
  /**
685
875
  * Returns a reversed version of the curve, without modifying the curve
686
876
  * itself.
@@ -797,6 +987,11 @@ declare namespace paper {
797
987
  */
798
988
  getTimeAt(offset: number, start?: number): number
799
989
 
990
+ /**
991
+ * @deprecated use use {@link #getTimeAt} instead.
992
+ */
993
+ getParameterAt(offset: number, start?: number): number
994
+
800
995
  /**
801
996
  * Calculates the curve-time parameters where the curve is tangential to
802
997
  * provided tangent. Note that tangents at the start or end are included.
@@ -808,6 +1003,17 @@ declare namespace paper {
808
1003
  */
809
1004
  getTimesWithTangent(tangent: PointLike): number[]
810
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
+
811
1017
  /**
812
1018
  * Calculates the curve offset at the specified curve-time parameter on
813
1019
  * the curve.
@@ -828,6 +1034,16 @@ declare namespace paper {
828
1034
  */
829
1035
  getLocationOf(point: PointLike): CurveLocation | null
830
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
+
831
1047
  /**
832
1048
  * Returns the length of the path from its beginning up to up to the
833
1049
  * specified point if it lies on the path, `null` otherwise.
@@ -838,6 +1054,16 @@ declare namespace paper {
838
1054
  */
839
1055
  getOffsetOf(point: PointLike): number | null
840
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
+
841
1067
  /**
842
1068
  * Returns the curve-time parameter of the specified point if it lies on the
843
1069
  * curve, `null` otherwise.
@@ -850,6 +1076,28 @@ declare namespace paper {
850
1076
  */
851
1077
  getTimeOf(point: PointLike): number | null
852
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
+
853
1101
  /**
854
1102
  * Returns the nearest location on the curve to the specified point.
855
1103
  *
@@ -860,6 +1108,16 @@ declare namespace paper {
860
1108
  */
861
1109
  getNearestLocation(point: PointLike): CurveLocation
862
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
+
863
1121
  /**
864
1122
  * Returns the nearest point on the curve to the specified point.
865
1123
  *
@@ -870,6 +1128,16 @@ declare namespace paper {
870
1128
  */
871
1129
  getNearestPoint(point: PointLike): Point
872
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
+
873
1141
  /**
874
1142
  * Calculates the point on the curve at the given location.
875
1143
  *
@@ -1054,6 +1322,11 @@ declare namespace paper {
1054
1322
  */
1055
1323
  readonly time: number
1056
1324
 
1325
+ /**
1326
+ * @deprecated use {@link #time} instead.
1327
+ */
1328
+ readonly parameter: number
1329
+
1057
1330
  /**
1058
1331
  * The point which is defined by the {@link #curve} and
1059
1332
  * {@link #time}.
@@ -1165,7 +1438,18 @@ declare namespace paper {
1165
1438
  */
1166
1439
  class Event {
1167
1440
  /**
1168
- * 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.
1169
1453
  */
1170
1454
  readonly timeStamp: number
1171
1455
 
@@ -1238,10 +1522,16 @@ declare namespace paper {
1238
1522
  */
1239
1523
  offset: number
1240
1524
 
1525
+ /**
1526
+ * @deprecated use {@link #offset} instead.
1527
+ */
1528
+ rampPoint: number
1529
+
1241
1530
  /**
1242
1531
  * The color of the gradient stop.
1243
1532
  */
1244
- color: Color
1533
+ get color(): Color
1534
+ set color(value: ColorLike)
1245
1535
 
1246
1536
 
1247
1537
  /**
@@ -1274,6 +1564,16 @@ declare namespace paper {
1274
1564
  */
1275
1565
  clipped: boolean
1276
1566
 
1567
+ /**
1568
+ * Specifies whether the group is isolated, drawn through a temporary
1569
+ * canvas, so that the blend modes of its children only apply within it,
1570
+ * like CSS's `isolation: isolate`. Without it, a compositing mode such as
1571
+ * `'destination-out'` affects everything drawn below the group, also in
1572
+ * other layers. Groups with an {@link Item#opacity} below 1 or a
1573
+ * {@link Item#blendMode} are isolated anyway.
1574
+ */
1575
+ isolated: boolean
1576
+
1277
1577
 
1278
1578
  /**
1279
1579
  * Creates a new Group item and places it at the top of the active layer.
@@ -1291,6 +1591,14 @@ declare namespace paper {
1291
1591
  */
1292
1592
  constructor(object: object)
1293
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
+
1294
1602
  }
1295
1603
 
1296
1604
  /**
@@ -1308,6 +1616,14 @@ declare namespace paper {
1308
1616
  /**
1309
1617
  * If the HitResult has a {@link HitResult#type} of `'bounds'`, this
1310
1618
  * property describes which corner of the bounding rectangle was hit.
1619
+ *
1620
+ * The names refer to the item's own bounding rectangle, transformed by its
1621
+ * {@link Item#matrix}, which is the rectangle that the item's selection
1622
+ * draws. On mirrored or rotated items, a handle can therefore appear
1623
+ * elsewhere on screen than its name says, while its opposite handle and
1624
+ * the rectangle's axes stay the ones to transform the item by. To choose
1625
+ * a cursor, use the direction from the rectangle's center to
1626
+ * {@link HitResult#point}, both in project coordinates.
1311
1627
  */
1312
1628
  name: string
1313
1629
 
@@ -1326,7 +1642,8 @@ declare namespace paper {
1326
1642
  * If the HitResult has a type of 'pixel', this property refers to the color
1327
1643
  * of the pixel on the {@link Raster} that was hit.
1328
1644
  */
1329
- color: Color | null
1645
+ get color(): Color | null
1646
+ set color(value: ColorLike | null)
1330
1647
 
1331
1648
  /**
1332
1649
  * If the HitResult has a type of 'stroke', 'segment', 'handle-in' or
@@ -1339,9 +1656,21 @@ declare namespace paper {
1339
1656
  * Describes the actual coordinates of the segment, handle or bounding box
1340
1657
  * corner that was hit.
1341
1658
  */
1342
- point: Point
1659
+ get point(): Point
1660
+ set point(value: PointLike)
1343
1661
 
1344
1662
 
1663
+ }
1664
+
1665
+ /**
1666
+ * A HostItem represents a node of a host document that has no
1667
+ * counterpart in Paper.js. Its bounds come from the host, it draws nothing,
1668
+ * and only its matrix and attributes can be changed. Hosts can extend it to
1669
+ * expose their own node kinds, storing their properties in `_values`, and
1670
+ * declare `_hasChildren: true` for kinds that contain other items.
1671
+ */
1672
+ class HostItem extends Item {
1673
+
1345
1674
  }
1346
1675
 
1347
1676
  /**
@@ -1353,6 +1682,14 @@ declare namespace paper {
1353
1682
  * that they inherit from Item.
1354
1683
  */
1355
1684
  class Item {
1685
+ /**
1686
+ * The key of the host's node that the item represents, in a project
1687
+ * backed by a host document, see {@link Project#host}. It can only be
1688
+ * set once, on an item created by a script, to register the key that
1689
+ * the host gave its new node.
1690
+ */
1691
+ key: number
1692
+
1356
1693
  /**
1357
1694
  * The unique id of the item.
1358
1695
  */
@@ -1393,8 +1730,10 @@ declare namespace paper {
1393
1730
  /**
1394
1731
  * The blend mode with which the item is composited onto the canvas. Both
1395
1732
  * the standard canvas compositing modes, as well as the new CSS blend modes
1396
- * are supported. If blend-modes cannot be rendered natively, they are
1397
- * 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.
1398
1737
  */
1399
1738
  blendMode: string
1400
1739
 
@@ -1411,6 +1750,14 @@ declare namespace paper {
1411
1750
  */
1412
1751
  guide: boolean
1413
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
+
1414
1761
  /**
1415
1762
  * Specifies whether the item is selected. This will also return `true` for
1416
1763
  * {@link Group} items if they are partially selected, e.g. groups
@@ -1428,6 +1775,12 @@ declare namespace paper {
1428
1775
  */
1429
1776
  selected: boolean
1430
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
+
1431
1784
  /**
1432
1785
  * Specifies whether the item defines a clip mask. This can only be set on
1433
1786
  * paths and compound paths, and only if the item is already contained
@@ -1446,7 +1799,8 @@ declare namespace paper {
1446
1799
  * default, this is the {@link Rectangle#center} of the item's
1447
1800
  * {@link #bounds} rectangle.
1448
1801
  */
1449
- position: Point
1802
+ get position(): Point
1803
+ set position(value: PointLike)
1450
1804
 
1451
1805
  /**
1452
1806
  * The item's pivot point specified in the item coordinate system, defining
@@ -1455,22 +1809,31 @@ declare namespace paper {
1455
1809
  * meaning the {@link Rectangle#center} of the item's {@link #bounds}
1456
1810
  * rectangle is used as pivot.
1457
1811
  */
1458
- pivot: Point
1812
+ get pivot(): Point
1813
+ set pivot(value: PointLike)
1459
1814
 
1460
1815
  /**
1461
1816
  * The bounding rectangle of the item excluding stroke width.
1462
1817
  */
1463
- bounds: Rectangle
1818
+ get bounds(): Rectangle
1819
+ set bounds(value: RectangleLike)
1464
1820
 
1465
1821
  /**
1466
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.
1467
1828
  */
1468
- strokeBounds: Rectangle
1829
+ get strokeBounds(): Rectangle
1830
+ set strokeBounds(value: RectangleLike)
1469
1831
 
1470
1832
  /**
1471
1833
  * The bounding rectangle of the item including handles.
1472
1834
  */
1473
- handleBounds: Rectangle
1835
+ get handleBounds(): Rectangle
1836
+ set handleBounds(value: RectangleLike)
1474
1837
 
1475
1838
  /**
1476
1839
  * The bounding rectangle of the item without any matrix transformations.
@@ -1479,7 +1842,8 @@ declare namespace paper {
1479
1842
  * want to draw something of the same size, position, rotation, and scaling,
1480
1843
  * like a selection frame.
1481
1844
  */
1482
- internalBounds: Rectangle
1845
+ get internalBounds(): Rectangle
1846
+ set internalBounds(value: RectangleLike)
1483
1847
 
1484
1848
  /**
1485
1849
  * The current rotation angle of the item, as described by its
@@ -1497,7 +1861,8 @@ declare namespace paper {
1497
1861
  * {@link #applyMatrix} set to `false`, meaning they do not directly bake
1498
1862
  * transformations into their content.
1499
1863
  */
1500
- scaling: Point
1864
+ get scaling(): Point
1865
+ set scaling(value: PointLike)
1501
1866
 
1502
1867
  /**
1503
1868
  * The item's transformation matrix, defining position and dimensions in
@@ -1529,6 +1894,11 @@ declare namespace paper {
1529
1894
  */
1530
1895
  applyMatrix: boolean
1531
1896
 
1897
+ /**
1898
+ * @deprecated use {@link #applyMatrix} instead.
1899
+ */
1900
+ transformContent: boolean
1901
+
1532
1902
  /**
1533
1903
  * The project that this item belongs to.
1534
1904
  */
@@ -1539,6 +1909,11 @@ declare namespace paper {
1539
1909
  */
1540
1910
  readonly view: View
1541
1911
 
1912
+ /**
1913
+ * The scope that this item belongs to, through its project.
1914
+ */
1915
+ readonly scope: PaperScope
1916
+
1542
1917
  /**
1543
1918
  * The layer that this item is contained within.
1544
1919
  */
@@ -1596,7 +1971,8 @@ declare namespace paper {
1596
1971
  /**
1597
1972
  * The color of the stroke.
1598
1973
  */
1599
- strokeColor: Color | null
1974
+ get strokeColor(): Color | null
1975
+ set strokeColor(value: ColorLike | null)
1600
1976
 
1601
1977
  /**
1602
1978
  * The width of the stroke.
@@ -1623,7 +1999,9 @@ declare namespace paper {
1623
1999
  /**
1624
2000
  * Specifies whether the stroke is to be drawn taking the current affine
1625
2001
  * transformation into account (the default behavior), or whether it should
1626
- * appear as a non-scaling stroke.
2002
+ * appear as a non-scaling stroke. On text, non-scaling strokes are exact for
2003
+ * uniform scaling only, as the glyphs are always stroked through the
2004
+ * transformation.
1627
2005
  */
1628
2006
  strokeScaling: boolean
1629
2007
 
@@ -1645,7 +2023,8 @@ declare namespace paper {
1645
2023
  /**
1646
2024
  * The fill color of the item.
1647
2025
  */
1648
- fillColor: Color | null
2026
+ get fillColor(): Color | null
2027
+ set fillColor(value: ColorLike | null)
1649
2028
 
1650
2029
  /**
1651
2030
  * The fill-rule with which the shape gets filled. Please note that only
@@ -1656,7 +2035,8 @@ declare namespace paper {
1656
2035
  /**
1657
2036
  * The shadow color.
1658
2037
  */
1659
- shadowColor: Color | null
2038
+ get shadowColor(): Color | null
2039
+ set shadowColor(value: ColorLike | null)
1660
2040
 
1661
2041
  /**
1662
2042
  * The shadow's blur radius.
@@ -1666,13 +2046,15 @@ declare namespace paper {
1666
2046
  /**
1667
2047
  * The shadow's offset.
1668
2048
  */
1669
- shadowOffset: Point
2049
+ get shadowOffset(): Point
2050
+ set shadowOffset(value: PointLike)
1670
2051
 
1671
2052
  /**
1672
2053
  * The color the item is highlighted with when selected. If the item does
1673
2054
  * not specify its own color, the color defined by its layer is used instead.
1674
2055
  */
1675
- selectedColor: Color | null
2056
+ get selectedColor(): Color | null
2057
+ set selectedColor(value: ColorLike | null)
1676
2058
 
1677
2059
  /**
1678
2060
  * Item level handler function to be called on each frame of an animation.
@@ -1797,6 +2179,24 @@ declare namespace paper {
1797
2179
  */
1798
2180
  set(props: object): this
1799
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
+
1800
2200
  /**
1801
2201
  * Clones the item within the same project and places the copy above the
1802
2202
  * item.
@@ -1829,27 +2229,32 @@ declare namespace paper {
1829
2229
  */
1830
2230
  copyAttributes(source: Item, excludeMatrix: boolean): void
1831
2231
 
2232
+ /**
2233
+ * @deprecated use {@link #rasterize} instead.
2234
+ */
2235
+ rasterize(resolution?: number, insert?: boolean): Raster
2236
+
1832
2237
  /**
1833
2238
  * Rasterizes the item into a newly created Raster object. The item itself
1834
2239
  * is not removed after rasterization.
1835
2240
  *
1836
- * @option [resolution=view.resolution] {Number} the desired resolution to
1837
- * be used when rasterizing, in pixels per inch (DPI). If not specified,
1838
- * the value of `view.resolution` is used by default.
1839
- * @option [raster=null] {Raster} specifies a raster to be reused when
1840
- * 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
1841
2246
  * underlying canvas is reused and no new memory needs to be allocated.
1842
2247
  * If no raster is provided, a new raster item is created and returned
1843
2248
  * instead.
1844
- * @option [insert=true] {Boolean} specifies whether the raster should be
1845
- * inserted into the scene graph. When set to `true`, it is inserted
1846
- * 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.
1847
2252
  *
1848
2253
  * @param options - the rasterization options
1849
2254
  *
1850
2255
  * @return the reused raster or the newly created raster item
1851
2256
  */
1852
- rasterize(options?: object): Raster
2257
+ rasterize(options?: { resolution?: number, raster?: Raster, insert?: boolean }): Raster
1853
2258
 
1854
2259
  /**
1855
2260
  * Checks whether the item's geometry contains the given point.
@@ -1858,13 +2263,28 @@ declare namespace paper {
1858
2263
  */
1859
2264
  contains(point: PointLike): boolean
1860
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
+
1861
2273
  /**
1862
2274
  * @param rect - the rectangle to check against
1863
2275
  */
1864
2276
  isInside(rect: RectangleLike): boolean
1865
2277
 
1866
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
+ *
1867
2285
  * @param item - the item to check against
2286
+ *
2287
+ * @return true if the items overlap
1868
2288
  */
1869
2289
  intersects(item: Item): boolean
1870
2290
 
@@ -1915,7 +2335,7 @@ declare namespace paper {
1915
2335
  * @return a hit result object describing what exactly was hit
1916
2336
  * or `null` if nothing was hit
1917
2337
  */
1918
- 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
1919
2339
 
1920
2340
  /**
1921
2341
  * Performs a hit-test on the item and its children (if it is a {@link
@@ -1933,7 +2353,7 @@ declare namespace paper {
1933
2353
  * @return hit result objects for all hits, describing what
1934
2354
  * exactly was hit or `null` if nothing was hit
1935
2355
  */
1936
- 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[]
1937
2357
 
1938
2358
  /**
1939
2359
  * Checks whether the item matches the criteria described by the given
@@ -2043,7 +2463,7 @@ declare namespace paper {
2043
2463
  *
2044
2464
  * @return the exported JSON data
2045
2465
  */
2046
- exportJSON(options?: object): string
2466
+ exportJSON(options?: { asString?: boolean, precision?: number }): string
2047
2467
 
2048
2468
  /**
2049
2469
  * Imports (deserializes) the stored JSON data into this item. If the data
@@ -2092,7 +2512,7 @@ declare namespace paper {
2092
2512
  * @return the item converted to an SVG node or a
2093
2513
  * `String` depending on `option.asString` value
2094
2514
  */
2095
- 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
2096
2516
 
2097
2517
  /**
2098
2518
  * Converts the provided SVG content into Paper.js items and adds them to
@@ -2103,6 +2523,10 @@ declare namespace paper {
2103
2523
  * the `<use>` elements that place them as {@link SymbolItem} items. The
2104
2524
  * styles that `<use>` elements inherit don't reach the symbols' content.
2105
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
+ *
2106
2530
  * @option [options.expandShapes=false] {Boolean} whether imported shape
2107
2531
  * items should be expanded to path items
2108
2532
  * @option [options.crossOrigin] {String} the {@link Raster#crossOrigin}
@@ -2129,7 +2553,7 @@ declare namespace paper {
2129
2553
  * @return the newly created Paper.js item containing the converted
2130
2554
  * SVG content
2131
2555
  */
2132
- 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
2133
2557
 
2134
2558
  /**
2135
2559
  * Imports the provided external SVG file, converts it into Paper.js items
@@ -2221,6 +2645,50 @@ declare namespace paper {
2221
2645
  */
2222
2646
  bringToFront(): void
2223
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
+
2224
2692
  /**
2225
2693
  * Adds it to the specified owner, which can be either a {@link Item} or a
2226
2694
  * {@link Project}.
@@ -2264,14 +2732,16 @@ declare namespace paper {
2264
2732
  remove(): boolean
2265
2733
 
2266
2734
  /**
2267
- * Replaces this item with the provided new item which will takes its place
2268
- * 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}.
2269
2739
  *
2270
- * @param item - the item that will replace this item
2740
+ * @param item - the items that will replace this item
2271
2741
  *
2272
2742
  * @return true if the item was replaced
2273
2743
  */
2274
- replaceWith(item: Item): boolean
2744
+ replaceWith(...item: Item[]): boolean
2275
2745
 
2276
2746
  /**
2277
2747
  * Removes all of the item's {@link #children} (if any).
@@ -2308,9 +2778,10 @@ declare namespace paper {
2308
2778
  isEmpty(recursively?: boolean): boolean
2309
2779
 
2310
2780
  /**
2311
- * Checks whether the item has a fill.
2781
+ * Checks whether the item has a visible fill, a fill color with an alpha
2782
+ * above 0. Hit-tests also hit transparent fills, see {@link #hitTest}.
2312
2783
  *
2313
- * @return true if the item has a fill
2784
+ * @return true if the item has a visible fill
2314
2785
  */
2315
2786
  hasFill(): boolean
2316
2787
 
@@ -2425,6 +2896,13 @@ declare namespace paper {
2425
2896
  */
2426
2897
  translate(delta: PointLike): void
2427
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
+
2428
2906
  /**
2429
2907
  * Rotates the item by a given angle around the given center point.
2430
2908
  *
@@ -2513,24 +2991,54 @@ declare namespace paper {
2513
2991
  globalToLocal(point: PointLike): Point
2514
2992
 
2515
2993
  /**
2516
- * Converts the specified point from the item's own local coordinate space
2517
- * to the global project coordinate space.
2994
+ * Converts the specified point from global project coordinate space to the
2995
+ * item's own local coordinate space.
2518
2996
  *
2519
2997
  * @param point - the point to be transformed
2520
2998
  *
2521
2999
  * @return the transformed point as a new instance
2522
3000
  */
2523
- localToGlobal(point: PointLike): Point
3001
+ globalToLocal(x: number, y: number): Point
2524
3002
 
2525
3003
  /**
2526
- * Converts the specified point from the parent's coordinate space to
2527
- * item's own local coordinate space.
3004
+ * Converts the specified point from the item's own local coordinate space
3005
+ * to the global project coordinate space.
2528
3006
  *
2529
3007
  * @param point - the point to be transformed
2530
3008
  *
2531
3009
  * @return the transformed point as a new instance
2532
3010
  */
2533
- parentToLocal(point: PointLike): Point
3011
+ localToGlobal(point: PointLike): Point
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
+
3023
+ /**
3024
+ * Converts the specified point from the parent's coordinate space to
3025
+ * item's own local coordinate space.
3026
+ *
3027
+ * @param point - the point to be transformed
3028
+ *
3029
+ * @return the transformed point as a new instance
3030
+ */
3031
+ parentToLocal(point: PointLike): Point
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
2534
3042
 
2535
3043
  /**
2536
3044
  * Converts the specified point from the item's own local coordinate space
@@ -2542,6 +3050,16 @@ declare namespace paper {
2542
3050
  */
2543
3051
  localToParent(point: PointLike): Point
2544
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
+
2545
3063
  /**
2546
3064
  * Transform the item so that its {@link #bounds} are centered in the
2547
3065
  * specified rectangle and fitted to it as described by `fit`.
@@ -2631,16 +3149,16 @@ declare namespace paper {
2631
3149
  * Removes the item when the events specified in the passed options object
2632
3150
  * occur.
2633
3151
  *
2634
- * @option options.move {Boolean) remove the item when the next {@link
3152
+ * @option options.move {Boolean} remove the item when the next {@link
2635
3153
  * Tool#onMouseMove} event is fired.
2636
- * @option options.drag {Boolena) remove the item when the next {@link
3154
+ * @option options.drag {Boolean} remove the item when the next {@link
2637
3155
  * Tool#onMouseDrag} event is fired.
2638
- * @option options.down {Boolean) remove the item when the next {@link
3156
+ * @option options.down {Boolean} remove the item when the next {@link
2639
3157
  * Tool#onMouseDown} event is fired.
2640
- * @option options.up {Boolean) remove the item when the next {@link
3158
+ * @option options.up {Boolean} remove the item when the next {@link
2641
3159
  * Tool#onMouseUp} event is fired.
2642
3160
  */
2643
- removeOn(options: object): void
3161
+ removeOn(options: { move?: boolean, drag?: boolean, down?: boolean, up?: boolean }): void
2644
3162
 
2645
3163
  /**
2646
3164
  * Removes the item when the next {@link Tool#onMouseMove} event is fired.
@@ -3155,6 +3673,21 @@ declare namespace paper {
3155
3673
  */
3156
3674
  inverted(): Matrix
3157
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
+
3158
3691
  /**
3159
3692
  * @return whether this matrix is the identity matrix
3160
3693
  */
@@ -3185,6 +3718,15 @@ declare namespace paper {
3185
3718
  */
3186
3719
  transform(point: PointLike): Point
3187
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
+
3188
3730
  /**
3189
3731
  * Transforms an array of coordinates by this matrix and stores the results
3190
3732
  * into the destination array, which is also returned.
@@ -3206,6 +3748,13 @@ declare namespace paper {
3206
3748
  */
3207
3749
  inverseTransform(point: PointLike): Point
3208
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
+
3209
3758
  /**
3210
3759
  * Decomposes the affine transformation described by this matrix into
3211
3760
  * `scaling`, `rotation` and `skewing`, and returns an object with
@@ -3240,7 +3789,8 @@ declare namespace paper {
3240
3789
  * The position of the mouse in project coordinates when the event was
3241
3790
  * fired.
3242
3791
  */
3243
- point: Point
3792
+ get point(): Point
3793
+ set point(value: PointLike)
3244
3794
 
3245
3795
  /**
3246
3796
  * The item that dispatched the event. It is different from
@@ -3258,7 +3808,8 @@ declare namespace paper {
3258
3808
  currentTarget: Item
3259
3809
 
3260
3810
 
3261
- delta: Point
3811
+ get delta(): Point
3812
+ set delta(value: PointLike)
3262
3813
 
3263
3814
 
3264
3815
  /**
@@ -3305,8 +3856,17 @@ declare namespace paper {
3305
3856
  * (Note that not all items can set this to `false`)
3306
3857
  * @option [settings.handleSize=4] {Number} the size of the curve handles
3307
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
3308
3862
  * @option [settings.hitTolerance=0] {Number} the default tolerance for hit-
3309
- * tests, when no value is specified
3863
+ * tests, when no value is specified, and for the mouse events of items
3864
+ * @option [settings.scaleStrokes=false] {Boolean} controls whether applying
3865
+ * a matrix to the content of paths and compound paths also scales their
3866
+ * {@link Style#strokeWidth}, by the geometric mean of the scale factors
3867
+ * for non-uniform scaling. Items that keep their matrix, with
3868
+ * {@link Item#applyMatrix} set to `false`, scale their strokes when
3869
+ * drawing anyway, unless {@link Style#strokeScaling} is `false`
3310
3870
  */
3311
3871
  settings: any
3312
3872
 
@@ -3335,6 +3895,8 @@ declare namespace paper {
3335
3895
  */
3336
3896
  tools: Tool[]
3337
3897
 
3898
+ AreaText: typeof AreaText
3899
+ ChangeFlag: typeof ChangeFlag
3338
3900
  Color: typeof Color
3339
3901
  CompoundPath: typeof CompoundPath
3340
3902
  Curve: typeof Curve
@@ -3344,6 +3906,7 @@ declare namespace paper {
3344
3906
  GradientStop: typeof GradientStop
3345
3907
  Group: typeof Group
3346
3908
  HitResult: typeof HitResult
3909
+ HostItem: typeof HostItem
3347
3910
  Item: typeof Item
3348
3911
  Key: typeof Key
3349
3912
  KeyEvent: typeof KeyEvent
@@ -3354,6 +3917,7 @@ declare namespace paper {
3354
3917
  PaperScript: typeof PaperScript
3355
3918
  Path: typeof Path
3356
3919
  PathItem: typeof PathItem
3920
+ PathText: typeof PathText
3357
3921
  Point: typeof Point
3358
3922
  PointText: typeof PointText
3359
3923
  Project: typeof Project
@@ -3366,6 +3930,8 @@ declare namespace paper {
3366
3930
  SymbolDefinition: typeof SymbolDefinition
3367
3931
  SymbolItem: typeof SymbolItem
3368
3932
  TextItem: typeof TextItem
3933
+ TextRange: typeof TextRange
3934
+ TextStory: typeof TextStory
3369
3935
  Tool: typeof Tool
3370
3936
  ToolEvent: typeof ToolEvent
3371
3937
  Tween: typeof Tween
@@ -3391,7 +3957,7 @@ declare namespace paper {
3391
3957
  * @param code - the PaperScript code
3392
3958
  * @param options - the compilation options
3393
3959
  */
3394
- execute(code: string, options?: object): void
3960
+ execute(code: string, options?: { url?: string, source?: string }): void
3395
3961
 
3396
3962
  /**
3397
3963
  * Injects the paper scope into any other given scope. Can be used for
@@ -3469,7 +4035,7 @@ declare namespace paper {
3469
4035
  * @return an object holding the compiled PaperScript translated
3470
4036
  * into JavaScript code along with source-maps and other information.
3471
4037
  */
3472
- static compile(code: string, options?: object): object
4038
+ static compile(code: string, options?: { url?: string, source?: string }): object
3473
4039
 
3474
4040
  /**
3475
4041
  * Compiles the PaperScript code into a compiled function and executes it.
@@ -3482,14 +4048,34 @@ declare namespace paper {
3482
4048
  * generation
3483
4049
  * @option options.source {String} the source to be used for the source-
3484
4050
  * mapping, in case the code that's passed in has already been mingled.
4051
+ * @option options.handlers {String[]} the names of further global
4052
+ * handlers to export next to `onFrame`, `onResize` and the tool's
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`.
3485
4070
  *
3486
4071
  * @param code - the PaperScript code
3487
4072
  * @param scope - the scope for which the code is executed
3488
4073
  * @param options - the compilation options
3489
4074
  *
3490
- * @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
3491
4077
  */
3492
- 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>
3493
4079
 
3494
4080
  /**
3495
4081
  * Loads, compiles and executes PaperScript code in the HTML document. Note
@@ -3719,6 +4305,11 @@ declare namespace paper {
3719
4305
  */
3720
4306
  splitAt(location: number | CurveLocation): Path | null
3721
4307
 
4308
+ /**
4309
+ * @deprecated use use {@link #splitAt} instead.
4310
+ */
4311
+ split(index: number, time?: number): Path
4312
+
3722
4313
  /**
3723
4314
  * Joins the path with the other specified path, which will be removed in
3724
4315
  * the process. They can be joined if the first or last segments of either
@@ -3748,7 +4339,7 @@ declare namespace paper {
3748
4339
  *
3749
4340
  * @return the reduced path
3750
4341
  */
3751
- reduce(options?: object): Path
4342
+ reduce(options?: { simplify?: boolean }): Path
3752
4343
 
3753
4344
  /**
3754
4345
  * Attempts to create a new shape item with same geometry as this path item,
@@ -3775,6 +4366,16 @@ declare namespace paper {
3775
4366
  */
3776
4367
  getLocationOf(point: PointLike): CurveLocation | null
3777
4368
 
4369
+ /**
4370
+ * Returns the curve location of the specified point if it lies on the
4371
+ * path, `null` otherwise.
4372
+ *
4373
+ * @param point - the point on the path
4374
+ *
4375
+ * @return the curve location of the specified point
4376
+ */
4377
+ getLocationOf(x: number, y: number): CurveLocation | null
4378
+
3778
4379
  /**
3779
4380
  * Returns the length of the path from its beginning up to up to the
3780
4381
  * specified point if it lies on the path, `null` otherwise.
@@ -3785,6 +4386,16 @@ declare namespace paper {
3785
4386
  */
3786
4387
  getOffsetOf(point: PointLike): number | null
3787
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
4398
+
3788
4399
  /**
3789
4400
  * Returns the curve location of the specified offset on the path, or
3790
4401
  * `null` if the offset exceeds the length of the path.
@@ -3872,6 +4483,19 @@ declare namespace paper {
3872
4483
  */
3873
4484
  getOffsetsWithTangent(tangent: PointLike): number[]
3874
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
+
3875
4499
  }
3876
4500
  namespace Path {
3877
4501
 
@@ -3954,6 +4578,14 @@ declare namespace paper {
3954
4578
 
3955
4579
  }
3956
4580
 
4581
+ class RoundRectangle extends Path {
4582
+ /**
4583
+ * @deprecated use {@link #Path.Rectangle} instead.
4584
+ */
4585
+ constructor(rectangle: RectangleLike, radius: SizeLike)
4586
+
4587
+ }
4588
+
3957
4589
  class Ellipse extends Path {
3958
4590
  /**
3959
4591
  * Creates an elliptical path item.
@@ -3973,6 +4605,14 @@ declare namespace paper {
3973
4605
 
3974
4606
  }
3975
4607
 
4608
+ class Oval extends Path {
4609
+ /**
4610
+ * @deprecated use {@link #Path.Ellipse} instead.
4611
+ */
4612
+ constructor(rectangle: RectangleLike)
4613
+
4614
+ }
4615
+
3976
4616
  class Arc extends Path {
3977
4617
  /**
3978
4618
  * Creates a circular arc path item.
@@ -3996,7 +4636,10 @@ declare namespace paper {
3996
4636
 
3997
4637
  class RegularPolygon extends Path {
3998
4638
  /**
3999
- * Creates a regular polygon shaped path item.
4639
+ * Creates a regular polygon shaped path item. As in Illustrator, it
4640
+ * stands on a flat bottom edge, and its segments run counterclockwise
4641
+ * from its top vertex, or with an even number of sides, from the right
4642
+ * end of its top edge.
4000
4643
  *
4001
4644
  * @param center - the center point of the polygon
4002
4645
  * @param sides - the number of sides of the polygon
@@ -4070,73 +4713,83 @@ declare namespace paper {
4070
4713
 
4071
4714
  /**
4072
4715
  * Unites the geometry of the specified path with this path's geometry
4073
- * 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.
4074
4719
  *
4075
4720
  * @option [options.insert=true] {Boolean} whether the resulting item
4076
- * should be inserted back into the scene graph, above both paths
4721
+ * should be inserted back into the scene graph, above all paths
4077
4722
  * involved in the operation
4078
4723
  *
4079
- * @param path - the path to unite with
4724
+ * @param path - the path or paths to unite with
4080
4725
  * @param options - the boolean operation options
4081
4726
  *
4082
4727
  * @return the resulting path item
4083
4728
  */
4084
- unite(path: PathItem, options?: object): PathItem
4729
+ unite(path: PathItem | PathItem[], options?: { insert?: boolean }): PathItem
4085
4730
 
4086
4731
  /**
4087
4732
  * Intersects the geometry of the specified path with this path's
4088
- * 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.
4089
4736
  *
4090
4737
  * @option [options.insert=true] {Boolean} whether the resulting item
4091
- * should be inserted back into the scene graph, above both paths
4738
+ * should be inserted back into the scene graph, above all paths
4092
4739
  * involved in the operation
4093
4740
  * @option [options.trace=true] {Boolean} whether the tracing method is
4094
- * used, treating both paths as areas when determining which parts
4741
+ * used, treating all paths as areas when determining which parts
4095
4742
  * of the paths are to be kept in the result, or whether the first
4096
4743
  * path is only to be split at intersections, keeping the parts of
4097
- * the curves that intersect with the area of the second path.
4744
+ * the curves that intersect with the areas of all other paths.
4098
4745
  *
4099
- * @param path - the path to intersect with
4746
+ * @param path - the path or paths to intersect
4747
+ * with
4100
4748
  * @param options - the boolean operation options
4101
4749
  *
4102
4750
  * @return the resulting path item
4103
4751
  */
4104
- intersect(path: PathItem, options?: object): PathItem
4752
+ intersect(path: PathItem | PathItem[], options?: { insert?: boolean, trace?: boolean }): PathItem
4105
4753
 
4106
4754
  /**
4107
4755
  * Subtracts the geometry of the specified path from this path's
4108
- * 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.
4109
4759
  *
4110
4760
  * @option [options.insert=true] {Boolean} whether the resulting item
4111
- * should be inserted back into the scene graph, above both paths
4761
+ * should be inserted back into the scene graph, above all paths
4112
4762
  * involved in the operation
4113
4763
  * @option [options.trace=true] {Boolean} whether the tracing method is
4114
- * used, treating both paths as areas when determining which parts
4764
+ * used, treating all paths as areas when determining which parts
4115
4765
  * of the paths are to be kept in the result, or whether the first
4116
4766
  * path is only to be split at intersections, removing the parts of
4117
- * the curves that intersect with the area of the second path.
4767
+ * the curves that intersect with the area of any other path.
4118
4768
  *
4119
- * @param path - the path to subtract
4769
+ * @param path - the path or paths to subtract
4120
4770
  * @param options - the boolean operation options
4121
4771
  *
4122
4772
  * @return the resulting path item
4123
4773
  */
4124
- subtract(path: PathItem, options?: object): PathItem
4774
+ subtract(path: PathItem | PathItem[], options?: { insert?: boolean, trace?: boolean }): PathItem
4125
4775
 
4126
4776
  /**
4127
4777
  * Excludes the intersection of the geometry of the specified path with
4128
- * 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.
4129
4781
  *
4130
4782
  * @option [options.insert=true] {Boolean} whether the resulting item
4131
- * should be inserted back into the scene graph, above both paths
4783
+ * should be inserted back into the scene graph, above all paths
4132
4784
  * involved in the operation
4133
4785
  *
4134
- * @param path - the path to exclude the intersection of
4786
+ * @param path - the path or paths to exclude the
4787
+ * intersection of
4135
4788
  * @param options - the boolean operation options
4136
4789
  *
4137
4790
  * @return the resulting path item
4138
4791
  */
4139
- exclude(path: PathItem, options?: object): PathItem
4792
+ exclude(path: PathItem | PathItem[], options?: { insert?: boolean }): PathItem
4140
4793
 
4141
4794
  /**
4142
4795
  * Splits the geometry of this path along the geometry of the specified
@@ -4157,7 +4810,7 @@ declare namespace paper {
4157
4810
  *
4158
4811
  * @return the resulting path item
4159
4812
  */
4160
- divide(path: PathItem, options?: object): PathItem
4813
+ divide(path: PathItem, options?: { insert?: boolean, trace?: boolean }): PathItem
4161
4814
 
4162
4815
  /**
4163
4816
  * Fixes the orientation of the sub-paths of a compound-path, assuming
@@ -4253,6 +4906,16 @@ declare namespace paper {
4253
4906
  */
4254
4907
  getNearestLocation(point: PointLike): CurveLocation
4255
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
+
4256
4919
  /**
4257
4920
  * Returns the nearest point on the path item to the specified point.
4258
4921
  *
@@ -4263,6 +4926,16 @@ declare namespace paper {
4263
4926
  */
4264
4927
  getNearestPoint(point: PointLike): Point
4265
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
+
4266
4939
  /**
4267
4940
  * Reverses the orientation of the path item. When called on
4268
4941
  * {@link CompoundPath} items, each of the nested paths is reversed. On
@@ -4347,7 +5020,7 @@ declare namespace paper {
4347
5020
  *
4348
5021
  * @param options - the smoothing options
4349
5022
  */
4350
- smooth(options?: object): void
5023
+ smooth(options?: { type?: string, factor?: number, from?: number | Segment | Curve, to?: number | Segment | Curve }): void
4351
5024
 
4352
5025
  /**
4353
5026
  * Fits a sequence of as few curves as possible through the path's anchor
@@ -4404,6 +5077,15 @@ declare namespace paper {
4404
5077
  */
4405
5078
  moveTo(point: PointLike): void
4406
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
+
4407
5089
  /**
4408
5090
  * Adds a straight curve to the path, from the the last segment in the path
4409
5091
  * to the specified point.
@@ -4413,6 +5095,15 @@ declare namespace paper {
4413
5095
  */
4414
5096
  lineTo(point: PointLike): void
4415
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
+
4416
5107
  /**
4417
5108
  * Adds an arc from the position of the last segment in the path, passing
4418
5109
  * through the specified `through` point, to the specified `to` point, by
@@ -4494,6 +5185,13 @@ declare namespace paper {
4494
5185
  */
4495
5186
  moveBy(to: PointLike): void
4496
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
+
4497
5195
  /**
4498
5196
  * Adds a straight curve to the path, from the the last segment in the path
4499
5197
  * to the `to` vector specified relatively to it.
@@ -4503,6 +5201,15 @@ declare namespace paper {
4503
5201
  */
4504
5202
  lineBy(point: PointLike): void
4505
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
+
4506
5213
  /**
4507
5214
  * Adds an arc from the position of the last segment in the path, passing
4508
5215
  * through the specified `through` vector, to the specified `to` vector, all
@@ -4568,10 +5275,61 @@ declare namespace paper {
4568
5275
 
4569
5276
  }
4570
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
+
4571
5326
  /**
4572
5327
  * The Point object represents a point in the two dimensional space
4573
5328
  * of the Paper.js project. It is also used to represent two dimensional
4574
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)`.
4575
5333
  */
4576
5334
  class Point {
4577
5335
  /**
@@ -4673,7 +5431,7 @@ declare namespace paper {
4673
5431
  *
4674
5432
  * @return true if the points are equal
4675
5433
  */
4676
- equals(point: PointLike): boolean
5434
+ equals(point: PointLike | number[]): boolean
4677
5435
 
4678
5436
  /**
4679
5437
  * Returns a copy of the point.
@@ -4695,6 +5453,14 @@ declare namespace paper {
4695
5453
  */
4696
5454
  getAngle(point: PointLike): number
4697
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
+
4698
5464
  /**
4699
5465
  * Returns the smaller angle between two vectors in radians. The angle is
4700
5466
  * unsigned, no information about rotational direction is given.
@@ -4703,6 +5469,14 @@ declare namespace paper {
4703
5469
  */
4704
5470
  getAngleInRadians(point: PointLike): number
4705
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
+
4706
5480
  /**
4707
5481
  * Returns the angle between two vectors. The angle is directional and
4708
5482
  * signed, giving information about the rotational direction.
@@ -4714,6 +5488,17 @@ declare namespace paper {
4714
5488
  */
4715
5489
  getDirectedAngle(point: PointLike): number
4716
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
+
4717
5502
  /**
4718
5503
  * Returns the distance between the point and another point.
4719
5504
  *
@@ -4779,6 +5564,17 @@ declare namespace paper {
4779
5564
  */
4780
5565
  add(point: PointLike): Point
4781
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
+
4782
5578
  /**
4783
5579
  * Returns the subtraction of the supplied value to both coordinates of
4784
5580
  * the point as a new point.
@@ -4801,6 +5597,17 @@ declare namespace paper {
4801
5597
  */
4802
5598
  subtract(point: PointLike): Point
4803
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
+
4804
5611
  /**
4805
5612
  * Returns the multiplication of the supplied value to both coordinates of
4806
5613
  * the point as a new point.
@@ -4824,6 +5631,17 @@ declare namespace paper {
4824
5631
  */
4825
5632
  multiply(point: PointLike): Point
4826
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
+
4827
5645
  /**
4828
5646
  * Returns the division of the supplied value to both coordinates of
4829
5647
  * the point as a new point.
@@ -4846,6 +5664,17 @@ declare namespace paper {
4846
5664
  */
4847
5665
  divide(point: PointLike): Point
4848
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
+
4849
5678
  /**
4850
5679
  * The modulo operator returns the integer remainders of dividing the point
4851
5680
  * by the supplied value as a new point.
@@ -4865,9 +5694,18 @@ declare namespace paper {
4865
5694
  modulo(point: PointLike): Point
4866
5695
 
4867
5696
  /**
4868
- * Returns a new point with both coordinates negated.
4869
- * PaperScript uses it for the unary minus operator.
4870
- * The object itself is not modified!
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
+
5705
+ /**
5706
+ * Returns a new point with both coordinates negated.
5707
+ * PaperScript uses it for the unary minus operator.
5708
+ * The object itself is not modified!
4871
5709
  *
4872
5710
  * @return the negation of the point as a new point
4873
5711
  */
@@ -4902,6 +5740,16 @@ declare namespace paper {
4902
5740
  */
4903
5741
  isCollinear(point: PointLike): boolean
4904
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
+
4905
5753
  /**
4906
5754
  * Checks if the vector represented by this point is orthogonal
4907
5755
  * (perpendicular) to another vector.
@@ -4912,6 +5760,16 @@ declare namespace paper {
4912
5760
  */
4913
5761
  isOrthogonal(point: PointLike): boolean
4914
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
+
4915
5773
  /**
4916
5774
  * Checks if this point has both the x and y coordinate set to 0.
4917
5775
  *
@@ -4947,6 +5805,13 @@ declare namespace paper {
4947
5805
  */
4948
5806
  dot(point: PointLike): number
4949
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
+
4950
5815
  /**
4951
5816
  * Returns the cross product of the point and another point.
4952
5817
  *
@@ -4954,6 +5819,13 @@ declare namespace paper {
4954
5819
  */
4955
5820
  cross(point: PointLike): number
4956
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
+
4957
5829
  /**
4958
5830
  * Returns the projection of the point onto another point.
4959
5831
  * Both points are interpreted as vectors.
@@ -4962,6 +5834,14 @@ declare namespace paper {
4962
5834
  */
4963
5835
  project(point: PointLike): Point
4964
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
+
4965
5845
  /**
4966
5846
  * Returns a new point with rounded {@link #x} and {@link #y} values. The
4967
5847
  * object itself is not modified!
@@ -5035,7 +5915,8 @@ declare namespace paper {
5035
5915
  /**
5036
5916
  * The PointText's anchor point
5037
5917
  */
5038
- point: Point
5918
+ get point(): Point
5919
+ set point(value: PointLike)
5039
5920
 
5040
5921
 
5041
5922
  /**
@@ -5075,6 +5956,60 @@ declare namespace paper {
5075
5956
  * {@link PaperScope#projects} variable.
5076
5957
  */
5077
5958
  class Project {
5959
+ /**
5960
+ * The host document that the project's items come from. Setting it
5961
+ * creates the project's layers from the host's records. All items
5962
+ * are created as shells that load their content and children from the
5963
+ * host on first access.
5964
+ *
5965
+ * The host provides:
5966
+ * - `getChildren(key)`, which returns the records of the children of
5967
+ * the node with the given key, or of the top level for `null`, as
5968
+ * columns: `keys`, `types` (indices into `typeNames`), `typeNames`,
5969
+ * `flags` (selected: 1, visible: 2, locked: 4, strokeScaling: 8,
5970
+ * clipMask: 64, guide: 128, empty: 256), `boxes` (bounds,
5971
+ * strokeBounds and roughBounds in the item's coordinates, 12 numbers
5972
+ * per item), and the sparse objects `names` and `matrices`.
5973
+ * - `getItem(key)`, which returns the node's own content in the form
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.
5982
+ * - `getAncestorKeys(key)`, which returns the keys from the top level
5983
+ * down to the node's parent.
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
6000
+
6001
+ /**
6002
+ * Specifies whether the project logs the changes of its items, to be
6003
+ * retrieved through {@link #takeChanges}. This allows hosts that keep
6004
+ * their own document to update only what has changed.
6005
+ */
6006
+ trackChanges: boolean
6007
+
6008
+ /**
6009
+ * The scope that this project belongs to.
6010
+ */
6011
+ readonly scope: PaperScope
6012
+
5078
6013
  /**
5079
6014
  * The reference to the project's view.
5080
6015
  */
@@ -5091,6 +6026,13 @@ declare namespace paper {
5091
6026
  */
5092
6027
  readonly index: number
5093
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
+
5094
6036
  /**
5095
6037
  * The layers contained within the project.
5096
6038
  */
@@ -5108,6 +6050,11 @@ declare namespace paper {
5108
6050
  */
5109
6051
  readonly symbolDefinitions: SymbolDefinition[]
5110
6052
 
6053
+ /**
6054
+ * @deprecated use {@link #symbolDefinitions} instead.
6055
+ */
6056
+ readonly symbols: SymbolDefinition[]
6057
+
5111
6058
  /**
5112
6059
  * The selected items contained within the project.
5113
6060
  */
@@ -5128,6 +6075,47 @@ declare namespace paper {
5128
6075
  */
5129
6076
  constructor(element: HTMLCanvasElement | string | SizeLike)
5130
6077
 
6078
+ /**
6079
+ * Returns the item of the host's node with the given key, loading only
6080
+ * the children of its ancestors.
6081
+ *
6082
+ * @param key - the key of the host's node
6083
+ *
6084
+ * @return the item, or `null` if the host has no such node
6085
+ */
6086
+ getItemByKey(key: number): Item
6087
+
6088
+ /**
6089
+ * Updates the items of changed host nodes, given in the column format
6090
+ * of the host's `getChildren()`, with two more flags: 16 when the
6091
+ * node's own content changed, so the item loads it again on next
6092
+ * access, and 32 when its list of children changed, so it loads them
6093
+ * again right away if it had loaded them, keeping the items of nodes
6094
+ * that remain. Nodes without items are skipped.
6095
+ *
6096
+ * @param columns - the records of the changed nodes
6097
+ */
6098
+ invalidate(columns: object): void
6099
+
6100
+ /**
6101
+ * Returns the changes logged since tracking was activated or since the
6102
+ * last call, and clears the log. Each item is listed once, with the
6103
+ * {@link ChangeFlag} values of all its changes combined. Removed items are
6104
+ * listed with the `ChangeFlag.INSERTION` flag.
6105
+ *
6106
+ * @return the changes as `{ item, flags }` objects, or `null`
6107
+ * if {link #trackChanges} is off
6108
+ */
6109
+ takeChanges(): object[]
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
+
5131
6119
  /**
5132
6120
  * Activates this project, so all newly created items will be placed
5133
6121
  * in it.
@@ -5226,7 +6214,7 @@ declare namespace paper {
5226
6214
  * @return a hit result object that contains more information
5227
6215
  * about what exactly was hit or `null` if nothing was hit
5228
6216
  */
5229
- 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
5230
6218
 
5231
6219
  /**
5232
6220
  * Performs a hit-test on the item and its children (if it is a {@link
@@ -5243,7 +6231,7 @@ declare namespace paper {
5243
6231
  * @return hit result objects for all hits, describing what
5244
6232
  * exactly was hit or `null` if nothing was hit
5245
6233
  */
5246
- 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[]
5247
6235
 
5248
6236
  /**
5249
6237
  * Fetch items contained within the project whose properties match the
@@ -5314,7 +6302,7 @@ declare namespace paper {
5314
6302
  *
5315
6303
  * @return the exported JSON data
5316
6304
  */
5317
- exportJSON(options?: object): string
6305
+ exportJSON(options?: { asString?: boolean, precision?: number }): string
5318
6306
 
5319
6307
  /**
5320
6308
  * Imports (deserializes) the stored JSON data into the project.
@@ -5364,7 +6352,7 @@ declare namespace paper {
5364
6352
  * @return the project converted to an SVG node or a
5365
6353
  * `String` depending on `option.asString` value
5366
6354
  */
5367
- 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
5368
6356
 
5369
6357
  /**
5370
6358
  * Converts the provided SVG content into Paper.js items and adds them to
@@ -5376,6 +6364,10 @@ declare namespace paper {
5376
6364
  * the `<use>` elements that place them as {@link SymbolItem} items. The
5377
6365
  * styles that `<use>` elements inherit don't reach the symbols' content.
5378
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
+ *
5379
6371
  * @option [options.expandShapes=false] {Boolean} whether imported shape
5380
6372
  * items should be expanded to path items
5381
6373
  * @option [options.crossOrigin] {String} the {@link Raster#crossOrigin}
@@ -5402,7 +6394,7 @@ declare namespace paper {
5402
6394
  * @return the newly created Paper.js item containing the converted
5403
6395
  * SVG content
5404
6396
  */
5405
- 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
5406
6398
 
5407
6399
  /**
5408
6400
  * Imports the provided external SVG file, converts it into Paper.js items
@@ -5430,7 +6422,8 @@ declare namespace paper {
5430
6422
  /**
5431
6423
  * The size of the raster in pixels.
5432
6424
  */
5433
- size: Size
6425
+ get size(): Size
6426
+ set size(value: SizeLike)
5434
6427
 
5435
6428
  /**
5436
6429
  * The width of the raster in pixels.
@@ -5453,6 +6446,11 @@ declare namespace paper {
5453
6446
  */
5454
6447
  readonly resolution: Size
5455
6448
 
6449
+ /**
6450
+ * @deprecated use {@link #resolution} instead.
6451
+ */
6452
+ readonly ppi: Size
6453
+
5456
6454
  /**
5457
6455
  * The HTMLImageElement or Canvas element of the raster, if one is
5458
6456
  * associated.
@@ -5663,6 +6661,9 @@ declare namespace paper {
5663
6661
 
5664
6662
  createImageData(size: SizeLike): ImageData
5665
6663
 
6664
+
6665
+ createImageData(width: number, height: number): ImageData
6666
+
5666
6667
  /**
5667
6668
  * Returns the image data of the pixels within the specified rectangle, or
5668
6669
  * of the whole raster if no rectangle or an empty one is passed.
@@ -5712,12 +6713,14 @@ declare namespace paper {
5712
6713
  * The top-left point of the rectangle. Setting it moves the whole
5713
6714
  * rectangle, unlike {@link #topLeft}.
5714
6715
  */
5715
- point: Point
6716
+ get point(): Point
6717
+ set point(value: PointLike)
5716
6718
 
5717
6719
  /**
5718
6720
  * The size of the rectangle
5719
6721
  */
5720
- size: Size
6722
+ get size(): Size
6723
+ set size(value: SizeLike)
5721
6724
 
5722
6725
  /**
5723
6726
  * The position of the left hand side of the rectangle. Note that this
@@ -5746,59 +6749,68 @@ declare namespace paper {
5746
6749
  /**
5747
6750
  * The center point of the rectangle. Setting it moves the whole rectangle.
5748
6751
  */
5749
- center: Point
6752
+ get center(): Point
6753
+ set center(value: PointLike)
5750
6754
 
5751
6755
  /**
5752
6756
  * The top-left point of the rectangle. Note that this doesn't move the
5753
6757
  * whole rectangle; the bottom-right corner stays where it was.
5754
6758
  */
5755
- topLeft: Point
6759
+ get topLeft(): Point
6760
+ set topLeft(value: PointLike)
5756
6761
 
5757
6762
  /**
5758
6763
  * The top-right point of the rectangle. Note that this doesn't move the
5759
6764
  * whole rectangle; the bottom-left corner stays where it was.
5760
6765
  */
5761
- topRight: Point
6766
+ get topRight(): Point
6767
+ set topRight(value: PointLike)
5762
6768
 
5763
6769
  /**
5764
6770
  * The bottom-left point of the rectangle. Note that this doesn't move the
5765
6771
  * whole rectangle; the top-right corner stays where it was.
5766
6772
  */
5767
- bottomLeft: Point
6773
+ get bottomLeft(): Point
6774
+ set bottomLeft(value: PointLike)
5768
6775
 
5769
6776
  /**
5770
6777
  * The bottom-right point of the rectangle. Note that this doesn't move the
5771
6778
  * whole rectangle; the top-left corner stays where it was.
5772
6779
  */
5773
- bottomRight: Point
6780
+ get bottomRight(): Point
6781
+ set bottomRight(value: PointLike)
5774
6782
 
5775
6783
  /**
5776
6784
  * The left-center point of the rectangle. Setting it moves the left hand
5777
6785
  * side while the right hand side stays where it was, and moves the whole
5778
6786
  * rectangle vertically.
5779
6787
  */
5780
- leftCenter: Point
6788
+ get leftCenter(): Point
6789
+ set leftCenter(value: PointLike)
5781
6790
 
5782
6791
  /**
5783
6792
  * The top-center point of the rectangle. Setting it moves the top while
5784
6793
  * the bottom stays where it was, and moves the whole rectangle
5785
6794
  * horizontally.
5786
6795
  */
5787
- topCenter: Point
6796
+ get topCenter(): Point
6797
+ set topCenter(value: PointLike)
5788
6798
 
5789
6799
  /**
5790
6800
  * The right-center point of the rectangle. Setting it moves the right
5791
6801
  * hand side while the left hand side stays where it was, and moves the
5792
6802
  * whole rectangle vertically.
5793
6803
  */
5794
- rightCenter: Point
6804
+ get rightCenter(): Point
6805
+ set rightCenter(value: PointLike)
5795
6806
 
5796
6807
  /**
5797
6808
  * The bottom-center point of the rectangle. Setting it moves the bottom
5798
6809
  * while the top stays where it was, and moves the whole rectangle
5799
6810
  * horizontally.
5800
6811
  */
5801
- bottomCenter: Point
6812
+ get bottomCenter(): Point
6813
+ set bottomCenter(value: PointLike)
5802
6814
 
5803
6815
  /**
5804
6816
  * The area of the rectangle.
@@ -5811,10 +6823,11 @@ declare namespace paper {
5811
6823
  * Paper.js draws the bounds of items with selected bounds on top of
5812
6824
  * your project. This is very useful when debugging.
5813
6825
  *
5814
- * This property is only available on the rectangle returned by
5815
- * {@link Item#bounds}, and the selection always shows these bounds.
5816
- * Rectangles returned by other getters such as {@link
5817
- * 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.
5818
6831
  */
5819
6832
  selected: boolean
5820
6833
 
@@ -5897,6 +6910,15 @@ declare namespace paper {
5897
6910
  */
5898
6911
  contains(point: PointLike): boolean
5899
6912
 
6913
+ /**
6914
+ * Tests if the specified point is inside the boundary of the rectangle.
6915
+ *
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
+
5900
6922
  /**
5901
6923
  * Tests if the interior of the rectangle entirely contains the specified
5902
6924
  * rectangle.
@@ -5963,6 +6985,23 @@ declare namespace paper {
5963
6985
  */
5964
6986
  include(point: PointLike): Rectangle
5965
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
+
5966
7005
  /**
5967
7006
  * Returns a new rectangle expanded by the specified amount in horizontal
5968
7007
  * and vertical directions.
@@ -6019,19 +7058,22 @@ declare namespace paper {
6019
7058
  /**
6020
7059
  * The anchor point of the segment.
6021
7060
  */
6022
- point: Point
7061
+ get point(): Point
7062
+ set point(value: PointLike)
6023
7063
 
6024
7064
  /**
6025
7065
  * The handle point relative to the anchor point of the segment that
6026
7066
  * describes the in tangent of the segment.
6027
7067
  */
6028
- handleIn: Point
7068
+ get handleIn(): Point
7069
+ set handleIn(value: PointLike)
6029
7070
 
6030
7071
  /**
6031
7072
  * The handle point relative to the anchor point of the segment that
6032
7073
  * describes the out tangent of the segment.
6033
7074
  */
6034
- handleOut: Point
7075
+ get handleOut(): Point
7076
+ set handleOut(value: PointLike)
6035
7077
 
6036
7078
  /**
6037
7079
  * Specifies whether the segment is selected.
@@ -6160,7 +7202,7 @@ declare namespace paper {
6160
7202
  *
6161
7203
  * @param options - the smoothing options
6162
7204
  */
6163
- smooth(options?: object): void
7205
+ smooth(options?: { type?: string, factor?: number }): void
6164
7206
 
6165
7207
  /**
6166
7208
  * Checks if the this is the first segment in the {@link Path#segments}
@@ -6237,16 +7279,23 @@ declare namespace paper {
6237
7279
  */
6238
7280
  type: string
6239
7281
 
7282
+ /**
7283
+ * @deprecated use {@link #type} instead.
7284
+ */
7285
+ shape: string
7286
+
6240
7287
  /**
6241
7288
  * The size of the shape.
6242
7289
  */
6243
- size: Size
7290
+ get size(): Size
7291
+ set size(value: SizeLike)
6244
7292
 
6245
7293
  /**
6246
7294
  * The radius of the shape, as a number if it is a circle, or a size object
6247
7295
  * for ellipses and rounded rectangles.
6248
7296
  */
6249
- radius: number | Size
7297
+ get radius(): number | Size
7298
+ set radius(value: number | SizeLike)
6250
7299
 
6251
7300
 
6252
7301
  /**
@@ -6349,6 +7398,9 @@ declare namespace paper {
6349
7398
  /**
6350
7399
  * The Size object is used to describe the size or dimensions of
6351
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)`.
6352
7404
  */
6353
7405
  class Size {
6354
7406
  /**
@@ -6405,7 +7457,7 @@ declare namespace paper {
6405
7457
  *
6406
7458
  * @param size - the size to compare to
6407
7459
  */
6408
- equals(size: SizeLike): boolean
7460
+ equals(size: SizeLike | number[]): boolean
6409
7461
 
6410
7462
  /**
6411
7463
  * Returns a copy of the size.
@@ -6437,6 +7489,16 @@ declare namespace paper {
6437
7489
  */
6438
7490
  add(size: SizeLike): Size
6439
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
+
6440
7502
  /**
6441
7503
  * Returns the subtraction of the supplied value from the width and height
6442
7504
  * of the size as a new size. The object itself is not modified!
@@ -6458,6 +7520,16 @@ declare namespace paper {
6458
7520
  */
6459
7521
  subtract(size: SizeLike): Size
6460
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
+
6461
7533
  /**
6462
7534
  * Returns the multiplication of the supplied value with the width and
6463
7535
  * height of the size as a new size. The object itself is not modified!
@@ -6478,6 +7550,16 @@ declare namespace paper {
6478
7550
  */
6479
7551
  multiply(size: SizeLike): Size
6480
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
+
6481
7563
  /**
6482
7564
  * Returns the division of the supplied value by the width and height of the
6483
7565
  * size as a new size. The object itself is not modified!
@@ -6498,6 +7580,16 @@ declare namespace paper {
6498
7580
  */
6499
7581
  divide(size: SizeLike): Size
6500
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
+
6501
7593
  /**
6502
7594
  * The modulo operator returns the integer remainders of dividing the size
6503
7595
  * by the supplied value as a new size.
@@ -6516,6 +7608,15 @@ declare namespace paper {
6516
7608
  */
6517
7609
  modulo(size: SizeLike): Size
6518
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
+
6519
7620
  /**
6520
7621
  * Returns a new size with both dimensions negated.
6521
7622
  * PaperScript uses it for the unary minus operator.
@@ -6613,10 +7714,19 @@ declare namespace paper {
6613
7714
  */
6614
7715
  readonly view: View
6615
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
+
6616
7725
  /**
6617
7726
  * The color of the stroke.
6618
7727
  */
6619
- strokeColor: Color | null
7728
+ get strokeColor(): Color | null
7729
+ set strokeColor(value: ColorLike | null)
6620
7730
 
6621
7731
  /**
6622
7732
  * The width of the stroke.
@@ -6638,7 +7748,9 @@ declare namespace paper {
6638
7748
  /**
6639
7749
  * Specifies whether the stroke is to be drawn taking the current affine
6640
7750
  * transformation into account (the default behavior), or whether it should
6641
- * appear as a non-scaling stroke.
7751
+ * appear as a non-scaling stroke. On text, non-scaling strokes are exact for
7752
+ * uniform scaling only, as the glyphs are always stroked through the
7753
+ * transformation.
6642
7754
  */
6643
7755
  strokeScaling: boolean
6644
7756
 
@@ -6664,7 +7776,8 @@ declare namespace paper {
6664
7776
  /**
6665
7777
  * The fill color.
6666
7778
  */
6667
- fillColor: Color | null
7779
+ get fillColor(): Color | null
7780
+ set fillColor(value: ColorLike | null)
6668
7781
 
6669
7782
  /**
6670
7783
  * The fill-rule with which the shape gets filled. Please note that only
@@ -6675,7 +7788,8 @@ declare namespace paper {
6675
7788
  /**
6676
7789
  * The shadow color.
6677
7790
  */
6678
- shadowColor: Color | null
7791
+ get shadowColor(): Color | null
7792
+ set shadowColor(value: ColorLike | null)
6679
7793
 
6680
7794
  /**
6681
7795
  * The shadow's blur radius.
@@ -6685,13 +7799,15 @@ declare namespace paper {
6685
7799
  /**
6686
7800
  * The shadow's offset.
6687
7801
  */
6688
- shadowOffset: Point
7802
+ get shadowOffset(): Point
7803
+ set shadowOffset(value: PointLike)
6689
7804
 
6690
7805
  /**
6691
7806
  * The color the item is highlighted with when selected. If the item does
6692
7807
  * not specify its own color, the color defined by its layer is used instead.
6693
7808
  */
6694
- selectedColor: Color | null
7809
+ get selectedColor(): Color | null
7810
+ set selectedColor(value: ColorLike | null)
6695
7811
 
6696
7812
  /**
6697
7813
  * The font-family to be used in text content.
@@ -6710,22 +7826,181 @@ declare namespace paper {
6710
7826
  fontSize: number | string
6711
7827
 
6712
7828
  /**
6713
- * 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.
7832
+ */
7833
+ font: string
7834
+
7835
+ /**
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'`).
6714
7841
  */
6715
- leading: number | string
7842
+ lineHeight: number | string
6716
7843
 
6717
7844
  /**
6718
- * The tracking of text content: the space added after each character, in
6719
- * thousandths of an em, as in Adobe Illustrator and InDesign. A tracking of
6720
- * 100 adds a tenth of the font size.
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.
6721
7854
  */
6722
7855
  tracking: number
6723
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
+
6724
7922
  /**
6725
7923
  * The justification of text paragraphs.
6726
7924
  */
6727
7925
  justification: string
6728
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
+
6729
8004
 
6730
8005
  /**
6731
8006
  * Style objects don't need to be created directly. Just pass an object to
@@ -6754,6 +8029,11 @@ declare namespace paper {
6754
8029
  */
6755
8030
  item: Item
6756
8031
 
8032
+ /**
8033
+ * @deprecated use {@link #item} instead.
8034
+ */
8035
+ definition: Item
8036
+
6757
8037
 
6758
8038
  /**
6759
8039
  * Creates a Symbol definition.
@@ -6796,6 +8076,11 @@ declare namespace paper {
6796
8076
  */
6797
8077
  definition: SymbolDefinition
6798
8078
 
8079
+ /**
8080
+ * @deprecated use {@link #definition} instead.
8081
+ */
8082
+ symbol: SymbolDefinition
8083
+
6799
8084
 
6800
8085
  /**
6801
8086
  * Creates a new symbol item.
@@ -6810,16 +8095,54 @@ declare namespace paper {
6810
8095
 
6811
8096
  /**
6812
8097
  * The TextItem type allows you to create typography. Its functionality
6813
- * is inherited by different text item types such as {@link PointText}, and
6814
- * {@link AreaText} (coming soon). They each add a layer of functionality
6815
- * that is unique to their type, but share the underlying properties and
6816
- * 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.
6817
8102
  */
6818
8103
  class TextItem extends Item {
6819
8104
  /**
6820
- * 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.
6821
8107
  */
6822
- 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[]
6823
8146
 
6824
8147
  /**
6825
8148
  * The font-family to be used in text content.
@@ -6838,22 +8161,372 @@ declare namespace paper {
6838
8161
  fontSize: number | string
6839
8162
 
6840
8163
  /**
6841
- * 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.
6842
8167
  */
6843
- leading: number | string
8168
+ font: string
6844
8169
 
6845
8170
  /**
6846
- * The tracking of text content: the space added after each character, in
6847
- * thousandths of an em, as in Adobe Illustrator and InDesign. A tracking of
6848
- * 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.
6849
8177
  */
6850
- 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[]
6851
8252
 
6852
8253
  /**
6853
8254
  * The justification of text paragraphs.
6854
8255
  */
6855
8256
  justification: string
6856
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
6857
8530
 
6858
8531
  }
6859
8532
 
@@ -6869,6 +8542,11 @@ declare namespace paper {
6869
8542
  * {@link #onKeyUp}).
6870
8543
  */
6871
8544
  class Tool {
8545
+ /**
8546
+ * The scope that this tool belongs to.
8547
+ */
8548
+ readonly scope: PaperScope
8549
+
6872
8550
  /**
6873
8551
  * The minimum distance the mouse has to drag before firing the onMouseDrag
6874
8552
  * event, since the last onMouseDrag event.
@@ -6881,6 +8559,15 @@ declare namespace paper {
6881
8559
  */
6882
8560
  maxDistance: number
6883
8561
 
8562
+ /**
8563
+ * The interval in milliseconds at which the onMouseDrag event fires again
8564
+ * while the mouse button is held, also when the mouse doesn't move. The
8565
+ * repeated events are at the last point, with a zero
8566
+ * {@link ToolEvent#delta}. `null`, the default, or anything up to 0 turns
8567
+ * it off.
8568
+ */
8569
+ eventInterval: number
8570
+
6884
8571
 
6885
8572
  fixedDistance: number
6886
8573
 
@@ -6937,6 +8624,19 @@ declare namespace paper {
6937
8624
  */
6938
8625
  onKeyUp: Function | null
6939
8626
 
8627
+ /**
8628
+ * The function to be called when the tool is activated through
8629
+ * {@link #activate}. The function receives the previously active tool,
8630
+ * which is the tool itself when it was already active.
8631
+ */
8632
+ onActivate: Function | null
8633
+
8634
+ /**
8635
+ * The function to be called when another tool is activated through
8636
+ * {@link #activate}, while this one is active.
8637
+ */
8638
+ onDeactivate: Function | null
8639
+
6940
8640
 
6941
8641
  /**
6942
8642
  * Activates this tool, meaning {@link PaperScope#tool} will
@@ -7041,19 +8741,22 @@ declare namespace paper {
7041
8741
  * The position of the mouse in project coordinates when the event was
7042
8742
  * fired.
7043
8743
  */
7044
- point: Point
8744
+ get point(): Point
8745
+ set point(value: PointLike)
7045
8746
 
7046
8747
  /**
7047
8748
  * The position of the mouse in project coordinates when the previous
7048
8749
  * event was fired.
7049
8750
  */
7050
- lastPoint: Point
8751
+ get lastPoint(): Point
8752
+ set lastPoint(value: PointLike)
7051
8753
 
7052
8754
  /**
7053
8755
  * The position of the mouse in project coordinates when the mouse button
7054
8756
  * was last clicked.
7055
8757
  */
7056
- downPoint: Point
8758
+ get downPoint(): Point
8759
+ set downPoint(value: PointLike)
7057
8760
 
7058
8761
  /**
7059
8762
  * The point in the middle between {@link #lastPoint} and
@@ -7061,14 +8764,37 @@ declare namespace paper {
7061
8764
  * artwork based on the moving direction of the mouse, as returned by
7062
8765
  * {@link #delta}.
7063
8766
  */
7064
- middlePoint: Point
8767
+ get middlePoint(): Point
8768
+ set middlePoint(value: PointLike)
7065
8769
 
7066
8770
  /**
7067
8771
  * The difference between the current position and the last position of the
7068
8772
  * mouse when the event was fired. In case of the mouseup event, the
7069
8773
  * difference to the mousedown position is returned.
7070
8774
  */
7071
- 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
7072
8798
 
7073
8799
  /**
7074
8800
  * The number of times the mouse event was fired.
@@ -7159,6 +8885,8 @@ declare namespace paper {
7159
8885
  * `html, body { height: 100%; }` and `canvas[resize] { width: 100%; height:
7160
8886
  * 100%; }` for a canvas that fills the window. Without such CSS, the view does
7161
8887
  * not follow the window, and on HiDPI screens it grows with each resize.
8888
+ * Without the attribute, the view sets the element's CSS width and height to
8889
+ * its own size, see {@link #viewSize}.
7162
8890
  */
7163
8891
  class View {
7164
8892
  /**
@@ -7180,6 +8908,11 @@ declare namespace paper {
7180
8908
  */
7181
8909
  readonly project: Project
7182
8910
 
8911
+ /**
8912
+ * The scope that this view belongs to.
8913
+ */
8914
+ readonly scope: PaperScope
8915
+
7183
8916
  /**
7184
8917
  * The ratio between physical pixels and device-independent pixels (DIPs)
7185
8918
  * of the underlying canvas / device.
@@ -7199,12 +8932,18 @@ declare namespace paper {
7199
8932
  * The size of the view. Changing the view's size will resize it's
7200
8933
  * underlying element.
7201
8934
  */
7202
- viewSize: Size
8935
+ get viewSize(): Size
8936
+ set viewSize(value: SizeLike)
7203
8937
 
7204
8938
  /**
7205
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.
7206
8944
  */
7207
- readonly bounds: Rectangle
8945
+ get bounds(): Rectangle
8946
+ set bounds(value: RectangleLike)
7208
8947
 
7209
8948
  /**
7210
8949
  * The size of the visible area in project coordinates.
@@ -7214,7 +8953,8 @@ declare namespace paper {
7214
8953
  /**
7215
8954
  * The center of the visible area in project coordinates.
7216
8955
  */
7217
- center: Point
8956
+ get center(): Point
8957
+ set center(value: PointLike)
7218
8958
 
7219
8959
  /**
7220
8960
  * The view's zoom factor by which the project coordinates are magnified.
@@ -7236,7 +8976,8 @@ declare namespace paper {
7236
8976
  *
7237
8977
  * @see #zoom
7238
8978
  */
7239
- scaling: Point
8979
+ get scaling(): Point
8980
+ set scaling(value: PointLike)
7240
8981
 
7241
8982
  /**
7242
8983
  * The view's transformation matrix, defining the view onto the project's
@@ -7400,6 +9141,13 @@ declare namespace paper {
7400
9141
  */
7401
9142
  update(force?: boolean): boolean
7402
9143
 
9144
+ /**
9145
+ * Updates the view if there are changes.
9146
+ *
9147
+ * @deprecated use {@link #update} instead.
9148
+ */
9149
+ draw(): void
9150
+
7403
9151
  /**
7404
9152
  * Requests an update of the view if there are changes through the browser's
7405
9153
  * requestAnimationFrame() mechanism for smooth animation. Note that when
@@ -7442,6 +9190,13 @@ declare namespace paper {
7442
9190
  */
7443
9191
  translate(delta: PointLike): void
7444
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
+
7445
9200
  /**
7446
9201
  * Rotates the view by a given angle around the given center point.
7447
9202
  *
@@ -7532,6 +9287,22 @@ declare namespace paper {
7532
9287
  */
7533
9288
  fitBounds(rectangle: RectangleLike, fit?: string): void
7534
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
+
7535
9306
  /**
7536
9307
  * Converts the passed point from project coordinate space to view
7537
9308
  * coordinate space, which is measured in browser pixels in relation to the
@@ -7543,6 +9314,17 @@ declare namespace paper {
7543
9314
  */
7544
9315
  projectToView(point: PointLike): Point
7545
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
+
7546
9328
  /**
7547
9329
  * Converts the passed point from view coordinate space to project
7548
9330
  * coordinate space.
@@ -7553,6 +9335,16 @@ declare namespace paper {
7553
9335
  */
7554
9336
  viewToProject(point: PointLike): Point
7555
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
+
7556
9348
  /**
7557
9349
  * Determines and returns the event location in project coordinate space.
7558
9350
  *
@@ -7634,6 +9426,55 @@ declare namespace paper {
7634
9426
  */
7635
9427
  responds(type: string): boolean
7636
9428
 
9429
+ /**
9430
+ * Handles a mouse event that the host provides, for hosts without a
9431
+ * DOM, such as workers, or with their own event source. It runs the
9432
+ * same handling as the DOM's mouse events: the active tool's handlers,
9433
+ * with {@link Tool#minDistance} and the like, then those of the items
9434
+ * under the point and of the view, including the events that Paper.js
9435
+ * derives itself: `'mousedrag'`, `'click'`, `'doubleclick'`,
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.
9439
+ *
9440
+ * @option [options.modifiers] {Object} the state of the modifier keys,
9441
+ * see {@link Key#modifiers}
9442
+ * @option [options.button=0] {Number} the mouse button
9443
+ * @option [options.time=Date.now() / 1000] {Number} the time of the
9444
+ * event in seconds, see {@link Event#time}
9445
+ *
9446
+ * @param type - the type of the event: {@values 'mousedown',
9447
+ * 'mousemove', 'mouseup'}
9448
+ * @param point - the location of the mouse in project coordinates
9449
+ * @param options - the details of the event
9450
+ *
9451
+ * @return true if a handler prevented the event's default
9452
+ */
9453
+ dispatchMouseEvent(type: string, point: PointLike, options?: { modifiers?: object, button?: number, time?: number }): boolean
9454
+
9455
+ /**
9456
+ * Handles a key event that the host provides, for hosts without a DOM,
9457
+ * such as workers, or with their own event source. It updates
9458
+ * {@link Key#modifiers} and {@link Key#isDown}, and calls the
9459
+ * view's and the active tool's handlers, as the DOM's key events do.
9460
+ *
9461
+ * @option [options.character] {String} the character that the key
9462
+ * produces. By default, keydown takes the key itself if it is a
9463
+ * single character, the space, carriage return and tab characters
9464
+ * for 'space', 'enter' and 'tab', and keyup the character of its
9465
+ * keydown
9466
+ * @option [options.modifiers] {Object} the state of the modifier keys,
9467
+ * see {@link Key#modifiers}
9468
+ * @option [options.time=Date.now() / 1000] {Number} the time of the
9469
+ * event in seconds, see {@link Event#time}
9470
+ *
9471
+ * @param type - the type of the event: {@values 'keydown',
9472
+ * 'keyup'}
9473
+ * @param key - the key, as in {@link KeyEvent#key}
9474
+ * @param options - the details of the event
9475
+ */
9476
+ dispatchKeyEvent(type: string, key: string, options?: { character?: string, modifiers?: object, time?: number }): void
9477
+
7637
9478
  }
7638
9479
  }
7639
9480