paper 0.12.20 → 0.14.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.
- package/CHANGELOG.md +318 -0
- package/README.md +45 -26
- package/dist/docs/assets/js/paper.js +1210 -481
- package/dist/docs/classes/ChangeFlag.html +384 -0
- package/dist/docs/classes/Color.html +63 -47
- package/dist/docs/classes/CompoundPath.html +219 -62
- package/dist/docs/classes/Curve.html +9 -7
- package/dist/docs/classes/CurveLocation.html +1 -1
- package/dist/docs/classes/Event.html +1 -1
- package/dist/docs/classes/Gradient.html +1 -1
- package/dist/docs/classes/GradientStop.html +1 -1
- package/dist/docs/classes/Group.html +151 -27
- package/dist/docs/classes/HitResult.html +3 -2
- package/dist/docs/classes/HostItem.html +6721 -0
- package/dist/docs/classes/Item.html +120 -27
- package/dist/docs/classes/Key.html +1 -1
- package/dist/docs/classes/KeyEvent.html +1 -1
- package/dist/docs/classes/Layer.html +151 -27
- package/dist/docs/classes/Matrix.html +1 -1
- package/dist/docs/classes/MouseEvent.html +1 -1
- package/dist/docs/classes/PaperScope.html +88 -1
- package/dist/docs/classes/PaperScript.html +2 -1
- package/dist/docs/classes/Path.html +232 -72
- package/dist/docs/classes/PathItem.html +337 -180
- package/dist/docs/classes/Point.html +143 -21
- package/dist/docs/classes/PointText.html +151 -27
- package/dist/docs/classes/Project.html +201 -8
- package/dist/docs/classes/Raster.html +150 -38
- package/dist/docs/classes/Rectangle.html +12 -11
- package/dist/docs/classes/Segment.html +1 -1
- package/dist/docs/classes/Shape.html +120 -27
- package/dist/docs/classes/Size.html +81 -21
- package/dist/docs/classes/Style.html +35 -3
- package/dist/docs/classes/SymbolDefinition.html +1 -1
- package/dist/docs/classes/SymbolItem.html +121 -28
- package/dist/docs/classes/TextItem.html +151 -27
- package/dist/docs/classes/Tool.html +127 -1
- package/dist/docs/classes/ToolEvent.html +27 -1
- package/dist/docs/classes/Tween.html +1 -1
- package/dist/docs/classes/View.html +345 -10
- package/dist/docs/classes/global.html +1 -1
- package/dist/docs/classes/index.html +2 -2
- package/dist/docs/index.html +1 -1
- package/dist/node/canvas.js +1 -1
- package/dist/node/self.js +4 -3
- package/dist/paper-core.js +1182 -465
- package/dist/paper-core.min.js +3 -3
- package/dist/paper-full.js +1210 -481
- package/dist/paper-full.min.js +3 -3
- package/dist/paper-sourced.js +18631 -0
- package/dist/paper.d.ts +606 -78
- package/examples/Rasters/Smoothing.html +1 -1
- package/package.json +6 -17
- package/dist/node/xml.js +0 -40
package/dist/paper.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Paper.js v0.
|
|
2
|
+
* Paper.js v0.14.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:
|
|
12
|
+
* Date: Tue Oct 20 01:20:31 2026 +0200
|
|
13
13
|
*
|
|
14
14
|
* This is an auto-generated type definition.
|
|
15
15
|
*/
|
|
@@ -38,6 +38,79 @@ declare namespace paper {
|
|
|
38
38
|
| { from: PointLike, to: PointLike }
|
|
39
39
|
)
|
|
40
40
|
|
|
41
|
+
|
|
42
|
+
class ChangeFlag {
|
|
43
|
+
/**
|
|
44
|
+
* Anything affecting the appearance of an item, including GEOMETRY,
|
|
45
|
+
* STROKE, STYLE and ATTRIBUTE (except for the invisible ones: locked, name)
|
|
46
|
+
*/
|
|
47
|
+
static APPEARANCE: number
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A change in the item's children
|
|
51
|
+
*/
|
|
52
|
+
static CHILDREN: number
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A change of the item's place in the scene graph (removed, inserted,
|
|
56
|
+
* moved)
|
|
57
|
+
*/
|
|
58
|
+
static INSERTION: number
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Item geometry (path, bounds)
|
|
62
|
+
*/
|
|
63
|
+
static GEOMETRY: number
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The item's matrix has changed
|
|
67
|
+
*/
|
|
68
|
+
static MATRIX: number
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Only segment(s) have changed, and affected curves have already been
|
|
72
|
+
* notified. This is to implement an optimization in _changed() calls
|
|
73
|
+
*/
|
|
74
|
+
static SEGMENTS: number
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Stroke geometry (excluding color)
|
|
78
|
+
*/
|
|
79
|
+
static STROKE: number
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Fill style or stroke color / dash
|
|
83
|
+
*/
|
|
84
|
+
static STYLE: number
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Item attributes: visible, blendMode, locked, name, opacity, clipMask ...
|
|
88
|
+
*/
|
|
89
|
+
static ATTRIBUTE: number
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Text content
|
|
93
|
+
*/
|
|
94
|
+
static CONTENT: number
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Raster pixels
|
|
98
|
+
*/
|
|
99
|
+
static PIXELS: number
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Clipping in one of the child items
|
|
103
|
+
*/
|
|
104
|
+
static CLIPPING: number
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The view has been transformed
|
|
108
|
+
*/
|
|
109
|
+
static VIEW: number
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
41
114
|
/**
|
|
42
115
|
* All properties and functions that expect color values in the form
|
|
43
116
|
* of instances of Color objects, also accept named colors and hex values as
|
|
@@ -262,7 +335,7 @@ declare namespace paper {
|
|
|
262
335
|
static random(): Color
|
|
263
336
|
|
|
264
337
|
/**
|
|
265
|
-
* Returns the addition of the supplied value to
|
|
338
|
+
* Returns the addition of the supplied value to all components of
|
|
266
339
|
* the color as a new color.
|
|
267
340
|
* The object itself is not modified!
|
|
268
341
|
*
|
|
@@ -285,7 +358,7 @@ declare namespace paper {
|
|
|
285
358
|
add(color: Color): Color
|
|
286
359
|
|
|
287
360
|
/**
|
|
288
|
-
* Returns the subtraction of the supplied value to
|
|
361
|
+
* Returns the subtraction of the supplied value to all components of
|
|
289
362
|
* the color as a new color.
|
|
290
363
|
* The object itself is not modified!
|
|
291
364
|
*
|
|
@@ -308,7 +381,7 @@ declare namespace paper {
|
|
|
308
381
|
subtract(color: Color): Color
|
|
309
382
|
|
|
310
383
|
/**
|
|
311
|
-
* Returns the multiplication of the supplied value to
|
|
384
|
+
* Returns the multiplication of the supplied value to all components
|
|
312
385
|
* of the color as a new color.
|
|
313
386
|
* The object itself is not modified!
|
|
314
387
|
*
|
|
@@ -331,7 +404,7 @@ declare namespace paper {
|
|
|
331
404
|
multiply(color: Color): Color
|
|
332
405
|
|
|
333
406
|
/**
|
|
334
|
-
* Returns the division of the supplied value to
|
|
407
|
+
* Returns the division of the supplied value to all components of
|
|
335
408
|
* the color as a new color.
|
|
336
409
|
* The object itself is not modified!
|
|
337
410
|
*
|
|
@@ -551,7 +624,7 @@ declare namespace paper {
|
|
|
551
624
|
/**
|
|
552
625
|
* The bounding rectangle of the curve including handles.
|
|
553
626
|
*/
|
|
554
|
-
handleBounds: Rectangle
|
|
627
|
+
readonly handleBounds: Rectangle
|
|
555
628
|
|
|
556
629
|
|
|
557
630
|
/**
|
|
@@ -761,7 +834,8 @@ declare namespace paper {
|
|
|
761
834
|
isVertical(): boolean
|
|
762
835
|
|
|
763
836
|
/**
|
|
764
|
-
* Calculates the curve location at the specified offset on the curve
|
|
837
|
+
* Calculates the curve location at the specified offset on the curve, or
|
|
838
|
+
* `null` if the offset exceeds the length of the curve.
|
|
765
839
|
*
|
|
766
840
|
* @param offset - the offset on the curve
|
|
767
841
|
*
|
|
@@ -771,7 +845,7 @@ declare namespace paper {
|
|
|
771
845
|
|
|
772
846
|
/**
|
|
773
847
|
* Calculates the curve location at the specified curve-time parameter on
|
|
774
|
-
* the curve
|
|
848
|
+
* the curve, or `null` if the parameter lies outside of `0..1`.
|
|
775
849
|
*
|
|
776
850
|
* @param time - the curve-time parameter on the curve
|
|
777
851
|
*
|
|
@@ -791,7 +865,8 @@ declare namespace paper {
|
|
|
791
865
|
* @param start - the curve-time in relation to which the offset is
|
|
792
866
|
* determined
|
|
793
867
|
*
|
|
794
|
-
* @return the curve-time parameter at the specified location
|
|
868
|
+
* @return the curve-time parameter at the specified location, or
|
|
869
|
+
* `null` if the offset exceeds the length of the curve
|
|
795
870
|
*/
|
|
796
871
|
getTimeAt(offset: number, start?: number): number
|
|
797
872
|
|
|
@@ -824,7 +899,7 @@ declare namespace paper {
|
|
|
824
899
|
*
|
|
825
900
|
* @return the curve location of the specified point
|
|
826
901
|
*/
|
|
827
|
-
getLocationOf(point: PointLike): CurveLocation
|
|
902
|
+
getLocationOf(point: PointLike): CurveLocation | null
|
|
828
903
|
|
|
829
904
|
/**
|
|
830
905
|
* Returns the length of the path from its beginning up to up to the
|
|
@@ -834,7 +909,7 @@ declare namespace paper {
|
|
|
834
909
|
*
|
|
835
910
|
* @return the length of the path up to the specified point
|
|
836
911
|
*/
|
|
837
|
-
getOffsetOf(point: PointLike): number
|
|
912
|
+
getOffsetOf(point: PointLike): number | null
|
|
838
913
|
|
|
839
914
|
/**
|
|
840
915
|
* Returns the curve-time parameter of the specified point if it lies on the
|
|
@@ -846,7 +921,7 @@ declare namespace paper {
|
|
|
846
921
|
*
|
|
847
922
|
* @return the curve-time parameter of the specified point
|
|
848
923
|
*/
|
|
849
|
-
getTimeOf(point: PointLike): number
|
|
924
|
+
getTimeOf(point: PointLike): number | null
|
|
850
925
|
|
|
851
926
|
/**
|
|
852
927
|
* Returns the nearest location on the curve to the specified point.
|
|
@@ -1272,6 +1347,16 @@ declare namespace paper {
|
|
|
1272
1347
|
*/
|
|
1273
1348
|
clipped: boolean
|
|
1274
1349
|
|
|
1350
|
+
/**
|
|
1351
|
+
* Specifies whether the group is isolated, drawn through a temporary
|
|
1352
|
+
* canvas, so that the blend modes of its children only apply within it,
|
|
1353
|
+
* like CSS's `isolation: isolate`. Without it, a compositing mode such as
|
|
1354
|
+
* `'destination-out'` affects everything drawn below the group, also in
|
|
1355
|
+
* other layers. Groups with an {@link Item#opacity} below 1 or a
|
|
1356
|
+
* {@link Item#blendMode} are isolated anyway.
|
|
1357
|
+
*/
|
|
1358
|
+
isolated: boolean
|
|
1359
|
+
|
|
1275
1360
|
|
|
1276
1361
|
/**
|
|
1277
1362
|
* Creates a new Group item and places it at the top of the active layer.
|
|
@@ -1306,6 +1391,14 @@ declare namespace paper {
|
|
|
1306
1391
|
/**
|
|
1307
1392
|
* If the HitResult has a {@link HitResult#type} of `'bounds'`, this
|
|
1308
1393
|
* property describes which corner of the bounding rectangle was hit.
|
|
1394
|
+
*
|
|
1395
|
+
* The names refer to the item's own bounding rectangle, transformed by its
|
|
1396
|
+
* {@link Item#matrix}, which is the rectangle that the item's selection
|
|
1397
|
+
* draws. On mirrored or rotated items, a handle can therefore appear
|
|
1398
|
+
* elsewhere on screen than its name says, while its opposite handle and
|
|
1399
|
+
* the rectangle's axes stay the ones to transform the item by. To choose
|
|
1400
|
+
* a cursor, use the direction from the rectangle's center to
|
|
1401
|
+
* {@link HitResult#point}, both in project coordinates.
|
|
1309
1402
|
*/
|
|
1310
1403
|
name: string
|
|
1311
1404
|
|
|
@@ -1340,6 +1433,17 @@ declare namespace paper {
|
|
|
1340
1433
|
point: Point
|
|
1341
1434
|
|
|
1342
1435
|
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
/**
|
|
1439
|
+
* A HostItem represents a node of a host document that has no
|
|
1440
|
+
* counterpart in Paper.js. Its bounds come from the host, it draws nothing,
|
|
1441
|
+
* and only its matrix and attributes can be changed. Hosts can extend it to
|
|
1442
|
+
* expose their own node kinds, storing their properties in `_values`, and
|
|
1443
|
+
* declare `_hasChildren: true` for kinds that contain other items.
|
|
1444
|
+
*/
|
|
1445
|
+
class HostItem extends Item {
|
|
1446
|
+
|
|
1343
1447
|
}
|
|
1344
1448
|
|
|
1345
1449
|
/**
|
|
@@ -1351,6 +1455,14 @@ declare namespace paper {
|
|
|
1351
1455
|
* that they inherit from Item.
|
|
1352
1456
|
*/
|
|
1353
1457
|
class Item {
|
|
1458
|
+
/**
|
|
1459
|
+
* The key of the host's node that the item represents, in a project
|
|
1460
|
+
* backed by a host document, see {@link Project#source}. It can only be
|
|
1461
|
+
* set once, on an item created by a script, to register the key that
|
|
1462
|
+
* the host gave its new node.
|
|
1463
|
+
*/
|
|
1464
|
+
key: number
|
|
1465
|
+
|
|
1354
1466
|
/**
|
|
1355
1467
|
* The unique id of the item.
|
|
1356
1468
|
*/
|
|
@@ -1369,6 +1481,10 @@ declare namespace paper {
|
|
|
1369
1481
|
|
|
1370
1482
|
/**
|
|
1371
1483
|
* The path style of the item.
|
|
1484
|
+
*
|
|
1485
|
+
* Styles set on a {@link Group} or {@link Layer} are applied to the
|
|
1486
|
+
* children that it contains at that moment. Items added to it later do not
|
|
1487
|
+
* receive them.
|
|
1372
1488
|
*/
|
|
1373
1489
|
style: Style
|
|
1374
1490
|
|
|
@@ -1397,6 +1513,14 @@ declare namespace paper {
|
|
|
1397
1513
|
*/
|
|
1398
1514
|
opacity: number
|
|
1399
1515
|
|
|
1516
|
+
/**
|
|
1517
|
+
* Specifies whether the item functions as a guide. When set to `true`, the
|
|
1518
|
+
* item is drawn as usual, but left out of hit-tests and mouse
|
|
1519
|
+
* interactions. Hit-tests only find guides when `options.guides` is set,
|
|
1520
|
+
* and then only them, see {@link #hitTest}.
|
|
1521
|
+
*/
|
|
1522
|
+
guide: boolean
|
|
1523
|
+
|
|
1400
1524
|
/**
|
|
1401
1525
|
* Specifies whether the item is selected. This will also return `true` for
|
|
1402
1526
|
* {@link Group} items if they are partially selected, e.g. groups
|
|
@@ -1525,6 +1649,11 @@ declare namespace paper {
|
|
|
1525
1649
|
*/
|
|
1526
1650
|
readonly view: View
|
|
1527
1651
|
|
|
1652
|
+
/**
|
|
1653
|
+
* The scope that this item belongs to, through its project.
|
|
1654
|
+
*/
|
|
1655
|
+
readonly scope: PaperScope
|
|
1656
|
+
|
|
1528
1657
|
/**
|
|
1529
1658
|
* The layer that this item is contained within.
|
|
1530
1659
|
*/
|
|
@@ -1539,6 +1668,11 @@ declare namespace paper {
|
|
|
1539
1668
|
* The children items contained within this item. Items that define a
|
|
1540
1669
|
* {@link #name} can also be accessed by name.
|
|
1541
1670
|
*
|
|
1671
|
+
* Only {@link Group}, {@link Layer} and {@link CompoundPath} items can have
|
|
1672
|
+
* children. On all other items, such as {@link Path}, {@link Shape},
|
|
1673
|
+
* {@link Raster}, {@link SymbolItem} and {@link PointText}, `children` is
|
|
1674
|
+
* `undefined`.
|
|
1675
|
+
*
|
|
1542
1676
|
* <b>Please note:</b> The children array should not be modified directly
|
|
1543
1677
|
* using array functions. To remove single items from the children list, use
|
|
1544
1678
|
* {@link Item#remove}, to remove all items from the children list, use
|
|
@@ -1604,7 +1738,9 @@ declare namespace paper {
|
|
|
1604
1738
|
/**
|
|
1605
1739
|
* Specifies whether the stroke is to be drawn taking the current affine
|
|
1606
1740
|
* transformation into account (the default behavior), or whether it should
|
|
1607
|
-
* appear as a non-scaling stroke.
|
|
1741
|
+
* appear as a non-scaling stroke. On text, non-scaling strokes are exact for
|
|
1742
|
+
* uniform scaling only, as the glyphs are always stroked through the
|
|
1743
|
+
* transformation.
|
|
1608
1744
|
*/
|
|
1609
1745
|
strokeScaling: boolean
|
|
1610
1746
|
|
|
@@ -1854,11 +1990,13 @@ declare namespace paper {
|
|
|
1854
1990
|
* Group} or {@link Layer}) at the location of the specified point,
|
|
1855
1991
|
* returning the first found hit.
|
|
1856
1992
|
*
|
|
1857
|
-
* The options object allows you to control the specifics of the hit-
|
|
1858
|
-
*
|
|
1993
|
+
* The options object allows you to control the specifics of the hit-test.
|
|
1994
|
+
* Without options, `fill`, `stroke` and `segments` are hit-tested. As soon
|
|
1995
|
+
* as an options object is passed, only the hit-tests that it sets to `true`
|
|
1996
|
+
* are performed. It may contain a combination of the following values:
|
|
1859
1997
|
*
|
|
1860
1998
|
* @option [options.tolerance={@link PaperScope#settings}.hitTolerance]
|
|
1861
|
-
* {Number} the tolerance of the hit-test
|
|
1999
|
+
* {Number} the tolerance of the hit-test, in project coordinates
|
|
1862
2000
|
* @option options.class {Function} only hit-test against a specific item
|
|
1863
2001
|
* class, or any of its sub-classes, by providing the constructor
|
|
1864
2002
|
* function against which an `instanceof` check is performed:
|
|
@@ -1867,11 +2005,11 @@ declare namespace paper {
|
|
|
1867
2005
|
* @option options.match {Function} a match function to be called for each
|
|
1868
2006
|
* found hit result: Return `true` to return the result, `false` to keep
|
|
1869
2007
|
* searching
|
|
1870
|
-
* @option
|
|
1871
|
-
* @option
|
|
1872
|
-
*
|
|
1873
|
-
* @option
|
|
1874
|
-
*
|
|
2008
|
+
* @option options.fill {Boolean} hit-test the fill of items
|
|
2009
|
+
* @option options.stroke {Boolean} hit-test the stroke of path items,
|
|
2010
|
+
* taking into account the setting of stroke color and width
|
|
2011
|
+
* @option options.segments {Boolean} hit-test for {@link Segment#point} of
|
|
2012
|
+
* {@link Path} items
|
|
1875
2013
|
* @option options.curves {Boolean} hit-test the curves of path items,
|
|
1876
2014
|
* without taking the stroke color or width into account
|
|
1877
2015
|
* @option options.handles {Boolean} hit-test for the handles ({@link
|
|
@@ -1884,7 +2022,7 @@ declare namespace paper {
|
|
|
1884
2022
|
* the bounding rectangle of items ({@link Item#bounds})
|
|
1885
2023
|
* @option options.bounds {Boolean} hit-test the corners and side-centers of
|
|
1886
2024
|
* the bounding rectangle of items ({@link Item#bounds})
|
|
1887
|
-
* @option options.guides {Boolean} hit-test items that have {@link
|
|
2025
|
+
* @option options.guides {Boolean} only hit-test items that have {@link
|
|
1888
2026
|
* Item#guide} set to `true`
|
|
1889
2027
|
* @option options.selected {Boolean} only hit selected items
|
|
1890
2028
|
*
|
|
@@ -1984,7 +2122,9 @@ declare namespace paper {
|
|
|
1984
2122
|
*
|
|
1985
2123
|
* @param options - the criteria to match against
|
|
1986
2124
|
*
|
|
1987
|
-
* @return the list of matching descendant items
|
|
2125
|
+
* @return the list of matching descendant items, in their
|
|
2126
|
+
* stacking order from bottom to top, with each item listed before its
|
|
2127
|
+
* own descendants
|
|
1988
2128
|
*/
|
|
1989
2129
|
getItems(options: object | Function): Item[]
|
|
1990
2130
|
|
|
@@ -2054,6 +2194,12 @@ declare namespace paper {
|
|
|
2054
2194
|
* @option [options.embedImages=true] {Boolean} whether raster images should
|
|
2055
2195
|
* be embedded as base64 data inlined in the xlink:href attribute, or
|
|
2056
2196
|
* kept as a link to their external URL.
|
|
2197
|
+
* @option [options.reuseImages=false] {Boolean} whether raster images with
|
|
2198
|
+
* the same content should only be exported once into the `<defs>`
|
|
2199
|
+
* element, and placed through `<use>` elements referencing it
|
|
2200
|
+
* @option [options.idPrefix=''] {String} a prefix for the ids generated
|
|
2201
|
+
* for definitions such as gradients, clip paths and symbols, to keep
|
|
2202
|
+
* them unique when several exported SVGs are placed in one document
|
|
2057
2203
|
* @option [options.reduceAttributes=true] {Boolean} wether to only include
|
|
2058
2204
|
* style attributes in the SVG output that differ from their parents,
|
|
2059
2205
|
* or to always include them (much faster but leading to redundancies).
|
|
@@ -2070,8 +2216,15 @@ declare namespace paper {
|
|
|
2070
2216
|
* the this item's children list. Note that the item is not cleared first.
|
|
2071
2217
|
* You can call {@link Item#removeChildren} to do so.
|
|
2072
2218
|
*
|
|
2219
|
+
* `<symbol>` elements are imported as {@link SymbolDefinition} items, and
|
|
2220
|
+
* the `<use>` elements that place them as {@link SymbolItem} items. The
|
|
2221
|
+
* styles that `<use>` elements inherit don't reach the symbols' content.
|
|
2222
|
+
*
|
|
2073
2223
|
* @option [options.expandShapes=false] {Boolean} whether imported shape
|
|
2074
2224
|
* items should be expanded to path items
|
|
2225
|
+
* @option [options.crossOrigin] {String} the {@link Raster#crossOrigin}
|
|
2226
|
+
* value of the rasters created for `<image>` elements, to load their
|
|
2227
|
+
* images with CORS
|
|
2075
2228
|
* @option options.onLoad {Function} the callback function to call once the
|
|
2076
2229
|
* SVG content is loaded from the given URL receiving two arguments: the
|
|
2077
2230
|
* converted `item` and the original `svg` data as a string. Only
|
|
@@ -2212,9 +2365,12 @@ declare namespace paper {
|
|
|
2212
2365
|
* the child-item is moved outside and the parent is erased. Otherwise, the
|
|
2213
2366
|
* item itself is returned unmodified.
|
|
2214
2367
|
*
|
|
2368
|
+
* @param options - the options passed on to {@link
|
|
2369
|
+
* Path#reduce(options)}
|
|
2370
|
+
*
|
|
2215
2371
|
* @return the reduced item
|
|
2216
2372
|
*/
|
|
2217
|
-
reduce(options
|
|
2373
|
+
reduce(options?: object): Item
|
|
2218
2374
|
|
|
2219
2375
|
/**
|
|
2220
2376
|
* Removes the item and all its children from the project. The item is not
|
|
@@ -2269,9 +2425,10 @@ declare namespace paper {
|
|
|
2269
2425
|
isEmpty(recursively?: boolean): boolean
|
|
2270
2426
|
|
|
2271
2427
|
/**
|
|
2272
|
-
* Checks whether the item has a fill
|
|
2428
|
+
* Checks whether the item has a visible fill, a fill color with an alpha
|
|
2429
|
+
* above 0. Hit-tests also hit transparent fills, see {@link #hitTest}.
|
|
2273
2430
|
*
|
|
2274
|
-
* @return true if the item has a fill
|
|
2431
|
+
* @return true if the item has a visible fill
|
|
2275
2432
|
*/
|
|
2276
2433
|
hasFill(): boolean
|
|
2277
2434
|
|
|
@@ -2306,7 +2463,8 @@ declare namespace paper {
|
|
|
2306
2463
|
|
|
2307
2464
|
/**
|
|
2308
2465
|
* Checks if this item is above the specified item in the stacking order
|
|
2309
|
-
* of the project.
|
|
2466
|
+
* of the project. If one item is a descendant of the other, neither is
|
|
2467
|
+
* above the other and `false` is returned.
|
|
2310
2468
|
*
|
|
2311
2469
|
* @param item - the item to check against
|
|
2312
2470
|
*
|
|
@@ -2316,7 +2474,8 @@ declare namespace paper {
|
|
|
2316
2474
|
|
|
2317
2475
|
/**
|
|
2318
2476
|
* Checks if the item is below the specified item in the stacking order of
|
|
2319
|
-
* the project.
|
|
2477
|
+
* the project. If one item is a descendant of the other, neither is below
|
|
2478
|
+
* the other and `false` is returned.
|
|
2320
2479
|
*
|
|
2321
2480
|
* @param item - the item to check against
|
|
2322
2481
|
*
|
|
@@ -2502,10 +2661,16 @@ declare namespace paper {
|
|
|
2502
2661
|
localToParent(point: PointLike): Point
|
|
2503
2662
|
|
|
2504
2663
|
/**
|
|
2505
|
-
* Transform the item so that its {@link #bounds}
|
|
2506
|
-
* rectangle
|
|
2664
|
+
* Transform the item so that its {@link #bounds} are centered in the
|
|
2665
|
+
* specified rectangle and fitted to it as described by `fit`.
|
|
2666
|
+
*
|
|
2667
|
+
* @param fit - how to fit the item, as in CSS's
|
|
2668
|
+
* `object-fit`: `'contain'` fits all of it within the rectangle, `'cover'`
|
|
2669
|
+
* makes it cover the whole rectangle, and `'fill'` stretches it to the
|
|
2670
|
+
* rectangle, changing its aspect ratio. The deprecated `true` and `false`
|
|
2671
|
+
* stand for `'cover'` and `'contain'`.
|
|
2507
2672
|
*/
|
|
2508
|
-
fitBounds(rectangle: RectangleLike,
|
|
2673
|
+
fitBounds(rectangle: RectangleLike, fit?: string | boolean): void
|
|
2509
2674
|
|
|
2510
2675
|
/**
|
|
2511
2676
|
* Attaches an event handler to the item.
|
|
@@ -2623,7 +2788,9 @@ declare namespace paper {
|
|
|
2623
2788
|
* of the easing: {@values 'linear' 'easeInQuad' 'easeOutQuad'
|
|
2624
2789
|
* 'easeInOutQuad' 'easeInCubic' 'easeOutCubic' 'easeInOutCubic'
|
|
2625
2790
|
* 'easeInQuart' 'easeOutQuart' 'easeInOutQuart' 'easeInQuint'
|
|
2626
|
-
* 'easeOutQuint' 'easeInOutQuint'
|
|
2791
|
+
* 'easeOutQuint' 'easeInOutQuint' 'easeInSine' 'easeOutSine'
|
|
2792
|
+
* 'easeInOutSine' 'easeInExpo' 'easeOutExpo' 'easeInOutExpo'
|
|
2793
|
+
* 'easeInCirc' 'easeOutCirc' 'easeInOutCirc'}
|
|
2627
2794
|
* @option [options.start=true] {Boolean} whether to start tweening automatically
|
|
2628
2795
|
*
|
|
2629
2796
|
* @param from - the state at the start of the tweening
|
|
@@ -3258,6 +3425,12 @@ declare namespace paper {
|
|
|
3258
3425
|
* when drawing selections
|
|
3259
3426
|
* @option [settings.hitTolerance=0] {Number} the default tolerance for hit-
|
|
3260
3427
|
* tests, when no value is specified
|
|
3428
|
+
* @option [settings.scaleStrokes=false] {Boolean} controls whether applying
|
|
3429
|
+
* a matrix to the content of paths and compound paths also scales their
|
|
3430
|
+
* {@link Style#strokeWidth}, by the geometric mean of the scale factors
|
|
3431
|
+
* for non-uniform scaling. Items that keep their matrix, with
|
|
3432
|
+
* {@link Item#applyMatrix} set to `false`, scale their strokes when
|
|
3433
|
+
* drawing anyway, unless {@link Style#strokeScaling} is `false`
|
|
3261
3434
|
*/
|
|
3262
3435
|
settings: any
|
|
3263
3436
|
|
|
@@ -3286,6 +3459,7 @@ declare namespace paper {
|
|
|
3286
3459
|
*/
|
|
3287
3460
|
tools: Tool[]
|
|
3288
3461
|
|
|
3462
|
+
ChangeFlag: typeof ChangeFlag
|
|
3289
3463
|
Color: typeof Color
|
|
3290
3464
|
CompoundPath: typeof CompoundPath
|
|
3291
3465
|
Curve: typeof Curve
|
|
@@ -3295,6 +3469,7 @@ declare namespace paper {
|
|
|
3295
3469
|
GradientStop: typeof GradientStop
|
|
3296
3470
|
Group: typeof Group
|
|
3297
3471
|
HitResult: typeof HitResult
|
|
3472
|
+
HostItem: typeof HostItem
|
|
3298
3473
|
Item: typeof Item
|
|
3299
3474
|
Key: typeof Key
|
|
3300
3475
|
KeyEvent: typeof KeyEvent
|
|
@@ -3368,12 +3543,34 @@ declare namespace paper {
|
|
|
3368
3543
|
*/
|
|
3369
3544
|
setup(element: HTMLCanvasElement | string | SizeLike): void
|
|
3370
3545
|
|
|
3546
|
+
/**
|
|
3547
|
+
* Creates a canvas of the given size, or reuses one that was released
|
|
3548
|
+
* internally.
|
|
3549
|
+
*
|
|
3550
|
+
* @param width - the width of the canvas
|
|
3551
|
+
* @param height - the height of the canvas
|
|
3552
|
+
*
|
|
3553
|
+
* @return the canvas
|
|
3554
|
+
*/
|
|
3555
|
+
createCanvas(width: number, height: number): HTMLCanvasElement
|
|
3556
|
+
|
|
3371
3557
|
/**
|
|
3372
3558
|
* Activates this PaperScope, so all newly created items will be placed
|
|
3373
3559
|
* in its active project.
|
|
3374
3560
|
*/
|
|
3375
3561
|
activate(): void
|
|
3376
3562
|
|
|
3563
|
+
/**
|
|
3564
|
+
* Removes all projects, views and tools of this scope, along with their
|
|
3565
|
+
* installed event handlers.
|
|
3566
|
+
*/
|
|
3567
|
+
clear(): void
|
|
3568
|
+
|
|
3569
|
+
/**
|
|
3570
|
+
* Clears this scope and removes it from the list of scopes.
|
|
3571
|
+
*/
|
|
3572
|
+
remove(): void
|
|
3573
|
+
|
|
3377
3574
|
/**
|
|
3378
3575
|
* Retrieves a PaperScope object with the given scope id.
|
|
3379
3576
|
*/
|
|
@@ -3411,6 +3608,9 @@ declare namespace paper {
|
|
|
3411
3608
|
* generation
|
|
3412
3609
|
* @option options.source {String} the source to be used for the source-
|
|
3413
3610
|
* mapping, in case the code that's passed in has already been mingled.
|
|
3611
|
+
* @option options.handlers {String[]} the names of further global
|
|
3612
|
+
* handlers to export next to `onFrame`, `onResize` and the tool's
|
|
3613
|
+
* handlers, for hosts that call them themselves
|
|
3414
3614
|
*
|
|
3415
3615
|
* @param code - the PaperScript code
|
|
3416
3616
|
* @param scope - the scope for which the code is executed
|
|
@@ -3508,7 +3708,10 @@ declare namespace paper {
|
|
|
3508
3708
|
|
|
3509
3709
|
/**
|
|
3510
3710
|
* Creates a new path item from SVG path-data and places it at the top of
|
|
3511
|
-
* the active layer.
|
|
3711
|
+
* the active layer. A path holds a single sub-path: further `M` commands
|
|
3712
|
+
* are ignored, and the commands that follow them continue the same path.
|
|
3713
|
+
* Use {@link CompoundPath} or {@link PathItem.create} to create
|
|
3714
|
+
* items with multiple sub-paths.
|
|
3512
3715
|
*
|
|
3513
3716
|
* @param pathData - the SVG path-data that describes the geometry
|
|
3514
3717
|
* of this path
|
|
@@ -3591,12 +3794,15 @@ declare namespace paper {
|
|
|
3591
3794
|
|
|
3592
3795
|
/**
|
|
3593
3796
|
* Removes the segments from the specified `from` index to the `to` index
|
|
3594
|
-
* from the path's {@link #segments} array.
|
|
3797
|
+
* from the path's {@link #segments} array. On closed paths, `from` can be
|
|
3798
|
+
* bigger than `to`, to remove the segments from `from` to the end and then
|
|
3799
|
+
* from the beginning up to `to`, wrapping around the closing curve.
|
|
3595
3800
|
*
|
|
3596
3801
|
* @param from - the beginning index, inclusive
|
|
3597
3802
|
* @param to - the ending index, exclusive
|
|
3598
3803
|
*
|
|
3599
|
-
* @return an array containing the removed segments
|
|
3804
|
+
* @return an array containing the removed segments, in the
|
|
3805
|
+
* order in which they appeared along the path
|
|
3600
3806
|
*/
|
|
3601
3807
|
removeSegments(from: number, to?: number): Segment[]
|
|
3602
3808
|
|
|
@@ -3640,7 +3846,7 @@ declare namespace paper {
|
|
|
3640
3846
|
*
|
|
3641
3847
|
* @return the newly created path after splitting, if any
|
|
3642
3848
|
*/
|
|
3643
|
-
splitAt(location: number | CurveLocation): Path
|
|
3849
|
+
splitAt(location: number | CurveLocation): Path | null
|
|
3644
3850
|
|
|
3645
3851
|
/**
|
|
3646
3852
|
* Joins the path with the other specified path, which will be removed in
|
|
@@ -3659,12 +3865,19 @@ declare namespace paper {
|
|
|
3659
3865
|
join(path: Path, tolerance?: number): void
|
|
3660
3866
|
|
|
3661
3867
|
/**
|
|
3662
|
-
* Reduces the path by removing curves that have a length of 0
|
|
3663
|
-
*
|
|
3868
|
+
* Reduces the path by removing straight curves that have a length of 0.
|
|
3869
|
+
* With `options.simplify`, it also removes straight curves that are almost
|
|
3870
|
+
* 0 in length, and unnecessary segments between two collinear straight
|
|
3871
|
+
* curves.
|
|
3872
|
+
*
|
|
3873
|
+
* @option [options.simplify=false] {Boolean} also remove almost zero-length
|
|
3874
|
+
* curves and segments between collinear straight curves
|
|
3875
|
+
*
|
|
3876
|
+
* @param options - the reduce options
|
|
3664
3877
|
*
|
|
3665
3878
|
* @return the reduced path
|
|
3666
3879
|
*/
|
|
3667
|
-
reduce(options
|
|
3880
|
+
reduce(options?: object): Path
|
|
3668
3881
|
|
|
3669
3882
|
/**
|
|
3670
3883
|
* Attempts to create a new shape item with same geometry as this path item,
|
|
@@ -3689,7 +3902,7 @@ declare namespace paper {
|
|
|
3689
3902
|
*
|
|
3690
3903
|
* @return the curve location of the specified point
|
|
3691
3904
|
*/
|
|
3692
|
-
getLocationOf(point: PointLike): CurveLocation
|
|
3905
|
+
getLocationOf(point: PointLike): CurveLocation | null
|
|
3693
3906
|
|
|
3694
3907
|
/**
|
|
3695
3908
|
* Returns the length of the path from its beginning up to up to the
|
|
@@ -3699,10 +3912,11 @@ declare namespace paper {
|
|
|
3699
3912
|
*
|
|
3700
3913
|
* @return the length of the path up to the specified point
|
|
3701
3914
|
*/
|
|
3702
|
-
getOffsetOf(point: PointLike): number
|
|
3915
|
+
getOffsetOf(point: PointLike): number | null
|
|
3703
3916
|
|
|
3704
3917
|
/**
|
|
3705
|
-
* Returns the curve location of the specified offset on the path
|
|
3918
|
+
* Returns the curve location of the specified offset on the path, or
|
|
3919
|
+
* `null` if the offset exceeds the length of the path.
|
|
3706
3920
|
*
|
|
3707
3921
|
* @param offset - the offset on the path, where `0` is at
|
|
3708
3922
|
* the beginning of the path and {@link Path#length} at the end
|
|
@@ -3911,7 +4125,10 @@ declare namespace paper {
|
|
|
3911
4125
|
|
|
3912
4126
|
class RegularPolygon extends Path {
|
|
3913
4127
|
/**
|
|
3914
|
-
* Creates a regular polygon shaped path item.
|
|
4128
|
+
* Creates a regular polygon shaped path item. As in Illustrator, it
|
|
4129
|
+
* stands on a flat bottom edge, and its segments run counterclockwise
|
|
4130
|
+
* from its top vertex, or with an even number of sides, from the right
|
|
4131
|
+
* end of its top edge.
|
|
3915
4132
|
*
|
|
3916
4133
|
* @param center - the center point of the polygon
|
|
3917
4134
|
* @param sides - the number of sides of the polygon
|
|
@@ -4141,7 +4358,7 @@ declare namespace paper {
|
|
|
4141
4358
|
* @return the locations of all intersection between the
|
|
4142
4359
|
* paths
|
|
4143
4360
|
*/
|
|
4144
|
-
getIntersections(path
|
|
4361
|
+
getIntersections(path?: PathItem, include?: Function): CurveLocation[]
|
|
4145
4362
|
|
|
4146
4363
|
/**
|
|
4147
4364
|
* Returns all crossings between two {@link PathItem} items as an array of
|
|
@@ -4779,6 +4996,15 @@ declare namespace paper {
|
|
|
4779
4996
|
*/
|
|
4780
4997
|
modulo(point: PointLike): Point
|
|
4781
4998
|
|
|
4999
|
+
/**
|
|
5000
|
+
* Returns a new point with both coordinates negated.
|
|
5001
|
+
* PaperScript uses it for the unary minus operator.
|
|
5002
|
+
* The object itself is not modified!
|
|
5003
|
+
*
|
|
5004
|
+
* @return the negation of the point as a new point
|
|
5005
|
+
*/
|
|
5006
|
+
negate(): Point
|
|
5007
|
+
|
|
4782
5008
|
/**
|
|
4783
5009
|
* Checks whether the point is inside the boundaries of the rectangle.
|
|
4784
5010
|
*
|
|
@@ -4894,6 +5120,18 @@ declare namespace paper {
|
|
|
4894
5120
|
*/
|
|
4895
5121
|
abs(): Point
|
|
4896
5122
|
|
|
5123
|
+
/**
|
|
5124
|
+
* Returns a new point with the {@link #x} and {@link #y} values clamped to
|
|
5125
|
+
* the range between the given minimum and maximum points. The object
|
|
5126
|
+
* itself is not modified!
|
|
5127
|
+
*
|
|
5128
|
+
* @param min - the point with the smallest values
|
|
5129
|
+
* @param max - the point with the largest values
|
|
5130
|
+
*
|
|
5131
|
+
* @return the clamped point as a new point
|
|
5132
|
+
*/
|
|
5133
|
+
clamp(min: PointLike, max: PointLike): Point
|
|
5134
|
+
|
|
4897
5135
|
/**
|
|
4898
5136
|
* Returns a new point object with the smallest {@link #x} and
|
|
4899
5137
|
* {@link #y} of the supplied points.
|
|
@@ -4969,6 +5207,39 @@ declare namespace paper {
|
|
|
4969
5207
|
* {@link PaperScope#projects} variable.
|
|
4970
5208
|
*/
|
|
4971
5209
|
class Project {
|
|
5210
|
+
/**
|
|
5211
|
+
* The host document that the project's items come from. Setting it
|
|
5212
|
+
* creates the project's layers from the source's records. All items
|
|
5213
|
+
* are created as shells that load their content and children from the
|
|
5214
|
+
* source on first access.
|
|
5215
|
+
*
|
|
5216
|
+
* The source provides:
|
|
5217
|
+
* - `getChildren(key)`, which returns the records of the children of
|
|
5218
|
+
* the node with the given key, or of the top level for `null`, as
|
|
5219
|
+
* columns: `keys`, `types` (indices into `typeNames`), `typeNames`,
|
|
5220
|
+
* `flags` (selected: 1, visible: 2, locked: 4, strokeScaling: 8,
|
|
5221
|
+
* clipMask: 64, guide: 128, empty: 256), `boxes` (bounds,
|
|
5222
|
+
* strokeBounds and roughBounds in the item's coordinates, 12 numbers
|
|
5223
|
+
* per item), and the sparse objects `names` and `matrices`.
|
|
5224
|
+
* - `getItem(key)`, which returns the node's own content in the form
|
|
5225
|
+
* of {@link Item#importJSON}, without children.
|
|
5226
|
+
* - `getAncestorKeys(key)`, which returns the keys from the top level
|
|
5227
|
+
* down to the node's parent.
|
|
5228
|
+
*/
|
|
5229
|
+
source: any
|
|
5230
|
+
|
|
5231
|
+
/**
|
|
5232
|
+
* Specifies whether the project logs the changes of its items, to be
|
|
5233
|
+
* retrieved through {@link #takeChanges}. This allows hosts that keep
|
|
5234
|
+
* their own document to update only what has changed.
|
|
5235
|
+
*/
|
|
5236
|
+
trackChanges: boolean
|
|
5237
|
+
|
|
5238
|
+
/**
|
|
5239
|
+
* The scope that this project belongs to.
|
|
5240
|
+
*/
|
|
5241
|
+
readonly scope: PaperScope
|
|
5242
|
+
|
|
4972
5243
|
/**
|
|
4973
5244
|
* The reference to the project's view.
|
|
4974
5245
|
*/
|
|
@@ -5022,6 +5293,39 @@ declare namespace paper {
|
|
|
5022
5293
|
*/
|
|
5023
5294
|
constructor(element: HTMLCanvasElement | string | SizeLike)
|
|
5024
5295
|
|
|
5296
|
+
/**
|
|
5297
|
+
* Returns the item of the host's node with the given key, loading only
|
|
5298
|
+
* the children of its ancestors.
|
|
5299
|
+
*
|
|
5300
|
+
* @param key - the key of the host's node
|
|
5301
|
+
*
|
|
5302
|
+
* @return the item, or `null` if the source has no such node
|
|
5303
|
+
*/
|
|
5304
|
+
getItemByKey(key: number): Item
|
|
5305
|
+
|
|
5306
|
+
/**
|
|
5307
|
+
* Updates the items of changed host nodes, given in the column format
|
|
5308
|
+
* of the source's `getChildren()`, with two more flags: 16 when the
|
|
5309
|
+
* node's own content changed, so the item loads it again on next
|
|
5310
|
+
* access, and 32 when its list of children changed, so it loads them
|
|
5311
|
+
* again right away if it had loaded them, keeping the items of nodes
|
|
5312
|
+
* that remain. Nodes without items are skipped.
|
|
5313
|
+
*
|
|
5314
|
+
* @param columns - the records of the changed nodes
|
|
5315
|
+
*/
|
|
5316
|
+
invalidate(columns: object): void
|
|
5317
|
+
|
|
5318
|
+
/**
|
|
5319
|
+
* Returns the changes logged since tracking was activated or since the
|
|
5320
|
+
* last call, and clears the log. Each item is listed once, with the
|
|
5321
|
+
* {@link ChangeFlag} values of all its changes combined. Removed items are
|
|
5322
|
+
* listed with the `ChangeFlag.INSERTION` flag.
|
|
5323
|
+
*
|
|
5324
|
+
* @return the changes as `{ item, flags }` objects, or `null`
|
|
5325
|
+
* if {link #trackChanges} is off
|
|
5326
|
+
*/
|
|
5327
|
+
takeChanges(): object[]
|
|
5328
|
+
|
|
5025
5329
|
/**
|
|
5026
5330
|
* Activates this project, so all newly created items will be placed
|
|
5027
5331
|
* in it.
|
|
@@ -5079,11 +5383,13 @@ declare namespace paper {
|
|
|
5079
5383
|
* Performs a hit-test on the items contained within the project at the
|
|
5080
5384
|
* location of the specified point.
|
|
5081
5385
|
*
|
|
5082
|
-
* The options object allows you to control the specifics of the hit-test
|
|
5083
|
-
*
|
|
5386
|
+
* The options object allows you to control the specifics of the hit-test.
|
|
5387
|
+
* Without options, `fill`, `stroke` and `segments` are hit-tested. As soon
|
|
5388
|
+
* as an options object is passed, only the hit-tests that it sets to `true`
|
|
5389
|
+
* are performed. It may contain a combination of the following values:
|
|
5084
5390
|
*
|
|
5085
5391
|
* @option [options.tolerance={@link PaperScope#settings}.hitTolerance]
|
|
5086
|
-
* {Number} the tolerance of the hit-test
|
|
5392
|
+
* {Number} the tolerance of the hit-test, in project coordinates
|
|
5087
5393
|
* @option options.class {Function} only hit-test against a specific item
|
|
5088
5394
|
* class, or any of its sub-classes, by providing the constructor
|
|
5089
5395
|
* function against which an `instanceof` check is performed:
|
|
@@ -5092,11 +5398,11 @@ declare namespace paper {
|
|
|
5092
5398
|
* @option options.match {Function} a match function to be called for each
|
|
5093
5399
|
* found hit result: Return `true` to return the result, `false` to keep
|
|
5094
5400
|
* searching
|
|
5095
|
-
* @option
|
|
5096
|
-
* @option
|
|
5097
|
-
*
|
|
5098
|
-
* @option
|
|
5099
|
-
*
|
|
5401
|
+
* @option options.fill {Boolean} hit-test the fill of items
|
|
5402
|
+
* @option options.stroke {Boolean} hit-test the stroke of path items,
|
|
5403
|
+
* taking into account the setting of stroke color and width
|
|
5404
|
+
* @option options.segments {Boolean} hit-test for {@link Segment#point} of
|
|
5405
|
+
* {@link Path} items
|
|
5100
5406
|
* @option options.curves {Boolean} hit-test the curves of path items,
|
|
5101
5407
|
* without taking the stroke color or width into account
|
|
5102
5408
|
* @option options.handles {Boolean} hit-test for the handles ({@link
|
|
@@ -5109,7 +5415,7 @@ declare namespace paper {
|
|
|
5109
5415
|
* the bounding rectangle of items ({@link Item#bounds})
|
|
5110
5416
|
* @option options.bounds {Boolean} hit-test the corners and side-centers of
|
|
5111
5417
|
* the bounding rectangle of items ({@link Item#bounds})
|
|
5112
|
-
* @option options.guides {Boolean} hit-test items that have {@link
|
|
5418
|
+
* @option options.guides {Boolean} only hit-test items that have {@link
|
|
5113
5419
|
* Item#guide} set to `true`
|
|
5114
5420
|
* @option options.selected {Boolean} only hit selected items
|
|
5115
5421
|
*
|
|
@@ -5170,7 +5476,9 @@ declare namespace paper {
|
|
|
5170
5476
|
*
|
|
5171
5477
|
* @param options - the criteria to match against
|
|
5172
5478
|
*
|
|
5173
|
-
* @return the list of matching items contained in the project
|
|
5479
|
+
* @return the list of matching items contained in the project, in
|
|
5480
|
+
* their stacking order from bottom to top, with each item listed
|
|
5481
|
+
* before its own descendants
|
|
5174
5482
|
*/
|
|
5175
5483
|
getItems(options: object | Function): Item[]
|
|
5176
5484
|
|
|
@@ -5239,6 +5547,12 @@ declare namespace paper {
|
|
|
5239
5547
|
* @option [options.embedImages=true] {Boolean} whether raster images should
|
|
5240
5548
|
* be embedded as base64 data inlined in the xlink:href attribute, or
|
|
5241
5549
|
* kept as a link to their external URL.
|
|
5550
|
+
* @option [options.reuseImages=false] {Boolean} whether raster images with
|
|
5551
|
+
* the same content should only be exported once into the `<defs>`
|
|
5552
|
+
* element, and placed through `<use>` elements referencing it
|
|
5553
|
+
* @option [options.idPrefix=''] {String} a prefix for the ids generated
|
|
5554
|
+
* for definitions such as gradients, clip paths and symbols, to keep
|
|
5555
|
+
* them unique when several exported SVGs are placed in one document
|
|
5242
5556
|
* @option [options.reduceAttributes=true] {Boolean} wether to only include
|
|
5243
5557
|
* style attributes in the SVG output that differ from their parents,
|
|
5244
5558
|
* or to always include them (much faster but leading to redundancies).
|
|
@@ -5256,8 +5570,15 @@ declare namespace paper {
|
|
|
5256
5570
|
* Note that the project is not cleared first. You can call
|
|
5257
5571
|
* {@link Project#clear} to do so.
|
|
5258
5572
|
*
|
|
5573
|
+
* `<symbol>` elements are imported as {@link SymbolDefinition} items, and
|
|
5574
|
+
* the `<use>` elements that place them as {@link SymbolItem} items. The
|
|
5575
|
+
* styles that `<use>` elements inherit don't reach the symbols' content.
|
|
5576
|
+
*
|
|
5259
5577
|
* @option [options.expandShapes=false] {Boolean} whether imported shape
|
|
5260
5578
|
* items should be expanded to path items
|
|
5579
|
+
* @option [options.crossOrigin] {String} the {@link Raster#crossOrigin}
|
|
5580
|
+
* value of the rasters created for `<image>` elements, to load their
|
|
5581
|
+
* images with CORS
|
|
5261
5582
|
* @option options.onLoad {Function} the callback function to call once the
|
|
5262
5583
|
* SVG content is loaded from the given URL receiving two arguments: the
|
|
5263
5584
|
* converted `item` and the original `svg` data as a string. Only
|
|
@@ -5353,15 +5674,16 @@ declare namespace paper {
|
|
|
5353
5674
|
context: CanvasRenderingContext2D
|
|
5354
5675
|
|
|
5355
5676
|
/**
|
|
5356
|
-
* The source of the raster, which can be set using a
|
|
5357
|
-
*
|
|
5358
|
-
*
|
|
5359
|
-
*
|
|
5360
|
-
* a
|
|
5677
|
+
* The source of the raster, which can be set using a string describing the
|
|
5678
|
+
* URL to load the image from, or a data url. Reading this property will
|
|
5679
|
+
* return the url of the source image or a data-url.
|
|
5680
|
+
* To set the raster to a DOM Image or a Canvas, use {@link #image} or
|
|
5681
|
+
* {@link #canvas} instead. The ID of a DOM Image or Canvas element is only
|
|
5682
|
+
* accepted by the constructor.
|
|
5361
5683
|
* Note that for consistency, a {@link #onLoad} event will be triggered on
|
|
5362
5684
|
* the raster even if the image has already finished loading before.
|
|
5363
5685
|
*/
|
|
5364
|
-
source:
|
|
5686
|
+
source: string
|
|
5365
5687
|
|
|
5366
5688
|
/**
|
|
5367
5689
|
* The crossOrigin value to be used when loading the image resource, in
|
|
@@ -5459,8 +5781,21 @@ declare namespace paper {
|
|
|
5459
5781
|
|
|
5460
5782
|
/**
|
|
5461
5783
|
* Returns a Base 64 encoded `data:` URL representation of the raster.
|
|
5784
|
+
* If the raster shows an image that was loaded from a `data:` URL, that
|
|
5785
|
+
* URL is returned unchanged. Otherwise, the arguments are passed on to
|
|
5786
|
+
* `HTMLCanvasElement#toDataURL()` of the raster's {@link #canvas}.
|
|
5787
|
+
* In web-workers, where the canvas is an `OffscreenCanvas`, this is not
|
|
5788
|
+
* supported, and neither are {@link #source} and exporting the raster to
|
|
5789
|
+
* JSON, which rely on it. Use the canvas' asynchronous `convertToBlob()`
|
|
5790
|
+
* there instead.
|
|
5791
|
+
*
|
|
5792
|
+
* @param type - the image format to encode
|
|
5793
|
+
* @param quality - the image quality between `0` and `1`, for
|
|
5794
|
+
* formats that use lossy compression, such as `'image/jpeg'`
|
|
5795
|
+
*
|
|
5796
|
+
* @return the `data:` URL of the raster
|
|
5462
5797
|
*/
|
|
5463
|
-
toDataURL(): string
|
|
5798
|
+
toDataURL(type?: string, quality?: number): string
|
|
5464
5799
|
|
|
5465
5800
|
/**
|
|
5466
5801
|
* Draws an image on the raster.
|
|
@@ -5526,8 +5861,16 @@ declare namespace paper {
|
|
|
5526
5861
|
|
|
5527
5862
|
createImageData(size: SizeLike): ImageData
|
|
5528
5863
|
|
|
5529
|
-
|
|
5530
|
-
|
|
5864
|
+
/**
|
|
5865
|
+
* Returns the image data of the pixels within the specified rectangle, or
|
|
5866
|
+
* of the whole raster if no rectangle or an empty one is passed.
|
|
5867
|
+
*
|
|
5868
|
+
* @param rect - the area of the raster to get the image data
|
|
5869
|
+
* of, in pixel coordinates
|
|
5870
|
+
*
|
|
5871
|
+
* @return the image data of the specified area
|
|
5872
|
+
*/
|
|
5873
|
+
getImageData(rect?: RectangleLike): ImageData
|
|
5531
5874
|
|
|
5532
5875
|
|
|
5533
5876
|
putImageData(data: ImageData, point: PointLike): void
|
|
@@ -5564,7 +5907,8 @@ declare namespace paper {
|
|
|
5564
5907
|
height: number
|
|
5565
5908
|
|
|
5566
5909
|
/**
|
|
5567
|
-
* The top-left point of the rectangle
|
|
5910
|
+
* The top-left point of the rectangle. Setting it moves the whole
|
|
5911
|
+
* rectangle, unlike {@link #topLeft}.
|
|
5568
5912
|
*/
|
|
5569
5913
|
point: Point
|
|
5570
5914
|
|
|
@@ -5598,47 +5942,59 @@ declare namespace paper {
|
|
|
5598
5942
|
bottom: number
|
|
5599
5943
|
|
|
5600
5944
|
/**
|
|
5601
|
-
* The center point of the rectangle.
|
|
5945
|
+
* The center point of the rectangle. Setting it moves the whole rectangle.
|
|
5602
5946
|
*/
|
|
5603
5947
|
center: Point
|
|
5604
5948
|
|
|
5605
5949
|
/**
|
|
5606
|
-
* The top-left point of the rectangle.
|
|
5950
|
+
* The top-left point of the rectangle. Note that this doesn't move the
|
|
5951
|
+
* whole rectangle; the bottom-right corner stays where it was.
|
|
5607
5952
|
*/
|
|
5608
5953
|
topLeft: Point
|
|
5609
5954
|
|
|
5610
5955
|
/**
|
|
5611
|
-
* The top-right point of the rectangle.
|
|
5956
|
+
* The top-right point of the rectangle. Note that this doesn't move the
|
|
5957
|
+
* whole rectangle; the bottom-left corner stays where it was.
|
|
5612
5958
|
*/
|
|
5613
5959
|
topRight: Point
|
|
5614
5960
|
|
|
5615
5961
|
/**
|
|
5616
|
-
* The bottom-left point of the rectangle.
|
|
5962
|
+
* The bottom-left point of the rectangle. Note that this doesn't move the
|
|
5963
|
+
* whole rectangle; the top-right corner stays where it was.
|
|
5617
5964
|
*/
|
|
5618
5965
|
bottomLeft: Point
|
|
5619
5966
|
|
|
5620
5967
|
/**
|
|
5621
|
-
* The bottom-right point of the rectangle.
|
|
5968
|
+
* The bottom-right point of the rectangle. Note that this doesn't move the
|
|
5969
|
+
* whole rectangle; the top-left corner stays where it was.
|
|
5622
5970
|
*/
|
|
5623
5971
|
bottomRight: Point
|
|
5624
5972
|
|
|
5625
5973
|
/**
|
|
5626
|
-
* The left-center point of the rectangle.
|
|
5974
|
+
* The left-center point of the rectangle. Setting it moves the left hand
|
|
5975
|
+
* side while the right hand side stays where it was, and moves the whole
|
|
5976
|
+
* rectangle vertically.
|
|
5627
5977
|
*/
|
|
5628
5978
|
leftCenter: Point
|
|
5629
5979
|
|
|
5630
5980
|
/**
|
|
5631
|
-
* The top-center point of the rectangle.
|
|
5981
|
+
* The top-center point of the rectangle. Setting it moves the top while
|
|
5982
|
+
* the bottom stays where it was, and moves the whole rectangle
|
|
5983
|
+
* horizontally.
|
|
5632
5984
|
*/
|
|
5633
5985
|
topCenter: Point
|
|
5634
5986
|
|
|
5635
5987
|
/**
|
|
5636
|
-
* The right-center point of the rectangle.
|
|
5988
|
+
* The right-center point of the rectangle. Setting it moves the right
|
|
5989
|
+
* hand side while the left hand side stays where it was, and moves the
|
|
5990
|
+
* whole rectangle vertically.
|
|
5637
5991
|
*/
|
|
5638
5992
|
rightCenter: Point
|
|
5639
5993
|
|
|
5640
5994
|
/**
|
|
5641
|
-
* The bottom-center point of the rectangle.
|
|
5995
|
+
* The bottom-center point of the rectangle. Setting it moves the bottom
|
|
5996
|
+
* while the top stays where it was, and moves the whole rectangle
|
|
5997
|
+
* horizontally.
|
|
5642
5998
|
*/
|
|
5643
5999
|
bottomCenter: Point
|
|
5644
6000
|
|
|
@@ -5652,6 +6008,11 @@ declare namespace paper {
|
|
|
5652
6008
|
*
|
|
5653
6009
|
* Paper.js draws the bounds of items with selected bounds on top of
|
|
5654
6010
|
* your project. This is very useful when debugging.
|
|
6011
|
+
*
|
|
6012
|
+
* This property is only available on the rectangle returned by
|
|
6013
|
+
* {@link Item#bounds}, and the selection always shows these bounds.
|
|
6014
|
+
* Rectangles returned by other getters such as {@link
|
|
6015
|
+
* Item#strokeBounds} don't have it.
|
|
5655
6016
|
*/
|
|
5656
6017
|
selected: boolean
|
|
5657
6018
|
|
|
@@ -6353,6 +6714,15 @@ declare namespace paper {
|
|
|
6353
6714
|
*/
|
|
6354
6715
|
modulo(size: SizeLike): Size
|
|
6355
6716
|
|
|
6717
|
+
/**
|
|
6718
|
+
* Returns a new size with both dimensions negated.
|
|
6719
|
+
* PaperScript uses it for the unary minus operator.
|
|
6720
|
+
* The object itself is not modified!
|
|
6721
|
+
*
|
|
6722
|
+
* @return the negation of the size as a new size
|
|
6723
|
+
*/
|
|
6724
|
+
negate(): Size
|
|
6725
|
+
|
|
6356
6726
|
/**
|
|
6357
6727
|
* Checks if this size has both the width and height set to 0.
|
|
6358
6728
|
*
|
|
@@ -6428,6 +6798,9 @@ declare namespace paper {
|
|
|
6428
6798
|
* All properties of Style are also reflected directly in {@link Item},
|
|
6429
6799
|
* i.e.: {@link Item#fillColor}.
|
|
6430
6800
|
*
|
|
6801
|
+
* Styles set on a {@link Group} or {@link Layer} are applied to the children
|
|
6802
|
+
* that it contains at that moment. Items added to it later do not receive them.
|
|
6803
|
+
*
|
|
6431
6804
|
* To set multiple style properties in one go, you can pass an object to
|
|
6432
6805
|
* {@link Item#style}. This is a convenient way to define a style once and
|
|
6433
6806
|
* apply it to a series of items:
|
|
@@ -6463,7 +6836,9 @@ declare namespace paper {
|
|
|
6463
6836
|
/**
|
|
6464
6837
|
* Specifies whether the stroke is to be drawn taking the current affine
|
|
6465
6838
|
* transformation into account (the default behavior), or whether it should
|
|
6466
|
-
* appear as a non-scaling stroke.
|
|
6839
|
+
* appear as a non-scaling stroke. On text, non-scaling strokes are exact for
|
|
6840
|
+
* uniform scaling only, as the glyphs are always stroked through the
|
|
6841
|
+
* transformation.
|
|
6467
6842
|
*/
|
|
6468
6843
|
strokeScaling: boolean
|
|
6469
6844
|
|
|
@@ -6539,6 +6914,13 @@ declare namespace paper {
|
|
|
6539
6914
|
*/
|
|
6540
6915
|
leading: number | string
|
|
6541
6916
|
|
|
6917
|
+
/**
|
|
6918
|
+
* The tracking of text content: the space added after each character, in
|
|
6919
|
+
* thousandths of an em, as in Adobe Illustrator and InDesign. A tracking of
|
|
6920
|
+
* 100 adds a tenth of the font size.
|
|
6921
|
+
*/
|
|
6922
|
+
tracking: number
|
|
6923
|
+
|
|
6542
6924
|
/**
|
|
6543
6925
|
* The justification of text paragraphs.
|
|
6544
6926
|
*/
|
|
@@ -6604,7 +6986,9 @@ declare namespace paper {
|
|
|
6604
6986
|
|
|
6605
6987
|
/**
|
|
6606
6988
|
* A symbol item represents an instance of a symbol which has been
|
|
6607
|
-
* placed in a Paper.js project.
|
|
6989
|
+
* placed in a Paper.js project. All instances share the symbol's definition,
|
|
6990
|
+
* which they draw as it is: styles set on a symbol item don't reach the items
|
|
6991
|
+
* of the definition, unlike `<use>` elements in SVG.
|
|
6608
6992
|
*/
|
|
6609
6993
|
class SymbolItem extends Item {
|
|
6610
6994
|
/**
|
|
@@ -6658,6 +7042,13 @@ declare namespace paper {
|
|
|
6658
7042
|
*/
|
|
6659
7043
|
leading: number | string
|
|
6660
7044
|
|
|
7045
|
+
/**
|
|
7046
|
+
* The tracking of text content: the space added after each character, in
|
|
7047
|
+
* thousandths of an em, as in Adobe Illustrator and InDesign. A tracking of
|
|
7048
|
+
* 100 adds a tenth of the font size.
|
|
7049
|
+
*/
|
|
7050
|
+
tracking: number
|
|
7051
|
+
|
|
6661
7052
|
/**
|
|
6662
7053
|
* The justification of text paragraphs.
|
|
6663
7054
|
*/
|
|
@@ -6678,6 +7069,11 @@ declare namespace paper {
|
|
|
6678
7069
|
* {@link #onKeyUp}).
|
|
6679
7070
|
*/
|
|
6680
7071
|
class Tool {
|
|
7072
|
+
/**
|
|
7073
|
+
* The scope that this tool belongs to.
|
|
7074
|
+
*/
|
|
7075
|
+
readonly scope: PaperScope
|
|
7076
|
+
|
|
6681
7077
|
/**
|
|
6682
7078
|
* The minimum distance the mouse has to drag before firing the onMouseDrag
|
|
6683
7079
|
* event, since the last onMouseDrag event.
|
|
@@ -6690,6 +7086,15 @@ declare namespace paper {
|
|
|
6690
7086
|
*/
|
|
6691
7087
|
maxDistance: number
|
|
6692
7088
|
|
|
7089
|
+
/**
|
|
7090
|
+
* The interval in milliseconds at which the onMouseDrag event fires again
|
|
7091
|
+
* while the mouse button is held, also when the mouse doesn't move. The
|
|
7092
|
+
* repeated events are at the last point, with a zero
|
|
7093
|
+
* {@link ToolEvent#delta}. `null`, the default, or anything up to 0 turns
|
|
7094
|
+
* it off.
|
|
7095
|
+
*/
|
|
7096
|
+
eventInterval: number
|
|
7097
|
+
|
|
6693
7098
|
|
|
6694
7099
|
fixedDistance: number
|
|
6695
7100
|
|
|
@@ -6711,6 +7116,9 @@ declare namespace paper {
|
|
|
6711
7116
|
* The function to be called the mouse moves within the project view. The
|
|
6712
7117
|
* function receives a {@link ToolEvent} object which contains information
|
|
6713
7118
|
* about the tool event.
|
|
7119
|
+
*
|
|
7120
|
+
* While the mouse button is held down, the tool calls {@link #onMouseDrag}
|
|
7121
|
+
* instead, if it defines one, and `onMouseMove` only otherwise.
|
|
6714
7122
|
*/
|
|
6715
7123
|
onMouseMove: Function | null
|
|
6716
7124
|
|
|
@@ -6743,6 +7151,19 @@ declare namespace paper {
|
|
|
6743
7151
|
*/
|
|
6744
7152
|
onKeyUp: Function | null
|
|
6745
7153
|
|
|
7154
|
+
/**
|
|
7155
|
+
* The function to be called when the tool is activated through
|
|
7156
|
+
* {@link #activate}. The function receives the previously active tool,
|
|
7157
|
+
* which is the tool itself when it was already active.
|
|
7158
|
+
*/
|
|
7159
|
+
onActivate: Function | null
|
|
7160
|
+
|
|
7161
|
+
/**
|
|
7162
|
+
* The function to be called when another tool is activated through
|
|
7163
|
+
* {@link #activate}, while this one is active.
|
|
7164
|
+
*/
|
|
7165
|
+
onDeactivate: Function | null
|
|
7166
|
+
|
|
6746
7167
|
|
|
6747
7168
|
/**
|
|
6748
7169
|
* Activates this tool, meaning {@link PaperScope#tool} will
|
|
@@ -6838,6 +7259,11 @@ declare namespace paper {
|
|
|
6838
7259
|
*/
|
|
6839
7260
|
type: string
|
|
6840
7261
|
|
|
7262
|
+
/**
|
|
7263
|
+
* The tool that fired the event.
|
|
7264
|
+
*/
|
|
7265
|
+
tool: Tool
|
|
7266
|
+
|
|
6841
7267
|
/**
|
|
6842
7268
|
* The position of the mouse in project coordinates when the event was
|
|
6843
7269
|
* fired.
|
|
@@ -6953,6 +7379,15 @@ declare namespace paper {
|
|
|
6953
7379
|
* view, find the currently visible bounds in project coordinates, or the
|
|
6954
7380
|
* center, both useful for constructing artwork that should appear centered on
|
|
6955
7381
|
* screen.
|
|
7382
|
+
*
|
|
7383
|
+
* If the canvas element has a `resize` or `data-paper-resize` attribute, the
|
|
7384
|
+
* view adjusts its size to the size of the element whenever the window is
|
|
7385
|
+
* resized. The element itself needs to be sized through CSS, e.g. with
|
|
7386
|
+
* `html, body { height: 100%; }` and `canvas[resize] { width: 100%; height:
|
|
7387
|
+
* 100%; }` for a canvas that fills the window. Without such CSS, the view does
|
|
7388
|
+
* not follow the window, and on HiDPI screens it grows with each resize.
|
|
7389
|
+
* Without the attribute, the view sets the element's CSS width and height to
|
|
7390
|
+
* its own size, see {@link #viewSize}.
|
|
6956
7391
|
*/
|
|
6957
7392
|
class View {
|
|
6958
7393
|
/**
|
|
@@ -6969,6 +7404,16 @@ declare namespace paper {
|
|
|
6969
7404
|
*/
|
|
6970
7405
|
readonly element: HTMLCanvasElement
|
|
6971
7406
|
|
|
7407
|
+
/**
|
|
7408
|
+
* The project that this view displays.
|
|
7409
|
+
*/
|
|
7410
|
+
readonly project: Project
|
|
7411
|
+
|
|
7412
|
+
/**
|
|
7413
|
+
* The scope that this view belongs to.
|
|
7414
|
+
*/
|
|
7415
|
+
readonly scope: PaperScope
|
|
7416
|
+
|
|
6972
7417
|
/**
|
|
6973
7418
|
* The ratio between physical pixels and device-independent pixels (DIPs)
|
|
6974
7419
|
* of the underlying canvas / device.
|
|
@@ -7007,6 +7452,7 @@ declare namespace paper {
|
|
|
7007
7452
|
|
|
7008
7453
|
/**
|
|
7009
7454
|
* The view's zoom factor by which the project coordinates are magnified.
|
|
7455
|
+
* Setting it to a value that isn't a positive number has no effect.
|
|
7010
7456
|
*
|
|
7011
7457
|
* @see #scaling
|
|
7012
7458
|
*/
|
|
@@ -7147,6 +7593,28 @@ declare namespace paper {
|
|
|
7147
7593
|
*/
|
|
7148
7594
|
onMouseLeave: Function | null
|
|
7149
7595
|
|
|
7596
|
+
/**
|
|
7597
|
+
* The function to be called when the user presses a key on the keyboard.
|
|
7598
|
+
* The function receives a {@link KeyEvent} object which contains
|
|
7599
|
+
* information about the keyboard event.
|
|
7600
|
+
*
|
|
7601
|
+
* If the function returns `false`, the keyboard event will be prevented
|
|
7602
|
+
* from bubbling up. This can be used for example to stop the window from
|
|
7603
|
+
* scrolling, when you need the user to interact with arrow keys.
|
|
7604
|
+
*/
|
|
7605
|
+
onKeyDown: Function | null
|
|
7606
|
+
|
|
7607
|
+
/**
|
|
7608
|
+
* The function to be called when the user releases a key on the keyboard.
|
|
7609
|
+
* The function receives a {@link KeyEvent} object which contains
|
|
7610
|
+
* information about the keyboard event.
|
|
7611
|
+
*
|
|
7612
|
+
* If the function returns `false`, the keyboard event will be prevented
|
|
7613
|
+
* from bubbling up. This can be used for example to stop the window from
|
|
7614
|
+
* scrolling, when you need the user to interact with arrow keys.
|
|
7615
|
+
*/
|
|
7616
|
+
onKeyUp: Function | null
|
|
7617
|
+
|
|
7150
7618
|
|
|
7151
7619
|
/**
|
|
7152
7620
|
* Removes this view from the project and frees the associated element.
|
|
@@ -7155,12 +7623,16 @@ declare namespace paper {
|
|
|
7155
7623
|
|
|
7156
7624
|
/**
|
|
7157
7625
|
* Updates the view if there are changes. Note that when using built-in
|
|
7158
|
-
* event
|
|
7626
|
+
* event handlers for interaction, animation and load events, this method is
|
|
7159
7627
|
* invoked for you automatically at the end.
|
|
7160
7628
|
*
|
|
7629
|
+
* @param force - whether to redraw the view even if nothing
|
|
7630
|
+
* has changed, e.g. after a web font used by text items has finished
|
|
7631
|
+
* loading
|
|
7632
|
+
*
|
|
7161
7633
|
* @return true if the view was updated
|
|
7162
7634
|
*/
|
|
7163
|
-
update(): boolean
|
|
7635
|
+
update(force?: boolean): boolean
|
|
7164
7636
|
|
|
7165
7637
|
/**
|
|
7166
7638
|
* Requests an update of the view if there are changes through the browser's
|
|
@@ -7281,6 +7753,19 @@ declare namespace paper {
|
|
|
7281
7753
|
*/
|
|
7282
7754
|
transform(matrix: Matrix): void
|
|
7283
7755
|
|
|
7756
|
+
/**
|
|
7757
|
+
* Transform the view so that the specified rectangle is centered in it
|
|
7758
|
+
* and fitted to it as described by `fit`, keeping the view's rotation and
|
|
7759
|
+
* mirroring.
|
|
7760
|
+
*
|
|
7761
|
+
* @param rectangle - the rectangle to fit, in project
|
|
7762
|
+
* coordinates
|
|
7763
|
+
* @param fit - how to fit the rectangle, as in CSS's
|
|
7764
|
+
* `object-fit`: `'contain'` shows all of it, and `'cover'` fills the
|
|
7765
|
+
* whole view with it, cropping the parts that don't fit
|
|
7766
|
+
*/
|
|
7767
|
+
fitBounds(rectangle: RectangleLike, fit?: string): void
|
|
7768
|
+
|
|
7284
7769
|
/**
|
|
7285
7770
|
* Converts the passed point from project coordinate space to view
|
|
7286
7771
|
* coordinate space, which is measured in browser pixels in relation to the
|
|
@@ -7383,6 +7868,49 @@ declare namespace paper {
|
|
|
7383
7868
|
*/
|
|
7384
7869
|
responds(type: string): boolean
|
|
7385
7870
|
|
|
7871
|
+
/**
|
|
7872
|
+
* Handles a mouse event that the host provides, for hosts without a
|
|
7873
|
+
* DOM, such as workers, or with their own event source. It runs the
|
|
7874
|
+
* same handling as the DOM's mouse events: the active tool's handlers,
|
|
7875
|
+
* with {@link Tool#minDistance} and the like, then those of the items
|
|
7876
|
+
* under the point and of the view, including the events that Paper.js
|
|
7877
|
+
* derives itself: `'mousedrag'`, `'click'`, `'doubleclick'`,
|
|
7878
|
+
* `'mouseenter'` and `'mouseleave'`.
|
|
7879
|
+
*
|
|
7880
|
+
* @option [options.modifiers] {Object} the state of the modifier keys,
|
|
7881
|
+
* see {@link Key#modifiers}
|
|
7882
|
+
* @option [options.button=0] {Number} the mouse button
|
|
7883
|
+
* @option [options.timeStamp=Date.now()] {Number} the time stamp
|
|
7884
|
+
*
|
|
7885
|
+
* @param type - the type of the event: {@values 'mousedown',
|
|
7886
|
+
* 'mousemove', 'mouseup'}
|
|
7887
|
+
* @param point - the location of the mouse in project coordinates
|
|
7888
|
+
* @param options - the details of the event
|
|
7889
|
+
*
|
|
7890
|
+
* @return true if a handler prevented the event's default
|
|
7891
|
+
*/
|
|
7892
|
+
dispatchMouseEvent(type: string, point: PointLike, options?: object): boolean
|
|
7893
|
+
|
|
7894
|
+
/**
|
|
7895
|
+
* Handles a key event that the host provides, for hosts without a DOM,
|
|
7896
|
+
* such as workers, or with their own event source. It updates
|
|
7897
|
+
* {@link Key#modifiers} and {@link Key#isDown}, and calls the
|
|
7898
|
+
* view's and the active tool's handlers, as the DOM's key events do.
|
|
7899
|
+
*
|
|
7900
|
+
* @option [options.character] {String} the character that the key
|
|
7901
|
+
* produces. By default, keydown takes the key itself if it is a
|
|
7902
|
+
* single character, and keyup the character of its keydown
|
|
7903
|
+
* @option [options.modifiers] {Object} the state of the modifier keys,
|
|
7904
|
+
* see {@link Key#modifiers}
|
|
7905
|
+
* @option [options.timeStamp=Date.now()] {Number} the time stamp
|
|
7906
|
+
*
|
|
7907
|
+
* @param type - the type of the event: {@values 'keydown',
|
|
7908
|
+
* 'keyup'}
|
|
7909
|
+
* @param key - the key, as in {@link KeyEvent#key}
|
|
7910
|
+
* @param options - the details of the event
|
|
7911
|
+
*/
|
|
7912
|
+
dispatchKeyEvent(type: string, key: string, options?: object): void
|
|
7913
|
+
|
|
7386
7914
|
}
|
|
7387
7915
|
}
|
|
7388
7916
|
|