paper 0.13.0 → 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.
Files changed (50) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +16 -13
  3. package/dist/docs/assets/js/paper.js +434 -128
  4. package/dist/docs/classes/ChangeFlag.html +384 -0
  5. package/dist/docs/classes/Color.html +1 -1
  6. package/dist/docs/classes/CompoundPath.html +58 -4
  7. package/dist/docs/classes/Curve.html +1 -1
  8. package/dist/docs/classes/CurveLocation.html +1 -1
  9. package/dist/docs/classes/Event.html +1 -1
  10. package/dist/docs/classes/Gradient.html +1 -1
  11. package/dist/docs/classes/GradientStop.html +1 -1
  12. package/dist/docs/classes/Group.html +89 -4
  13. package/dist/docs/classes/HitResult.html +3 -2
  14. package/dist/docs/classes/HostItem.html +6721 -0
  15. package/dist/docs/classes/Item.html +58 -4
  16. package/dist/docs/classes/Key.html +1 -1
  17. package/dist/docs/classes/KeyEvent.html +1 -1
  18. package/dist/docs/classes/Layer.html +89 -4
  19. package/dist/docs/classes/Matrix.html +1 -1
  20. package/dist/docs/classes/MouseEvent.html +1 -1
  21. package/dist/docs/classes/PaperScope.html +2 -1
  22. package/dist/docs/classes/PaperScript.html +2 -1
  23. package/dist/docs/classes/Path.html +59 -5
  24. package/dist/docs/classes/PathItem.html +58 -4
  25. package/dist/docs/classes/Point.html +1 -1
  26. package/dist/docs/classes/PointText.html +58 -4
  27. package/dist/docs/classes/Project.html +188 -1
  28. package/dist/docs/classes/Raster.html +58 -4
  29. package/dist/docs/classes/Rectangle.html +1 -1
  30. package/dist/docs/classes/Segment.html +1 -1
  31. package/dist/docs/classes/Shape.html +58 -4
  32. package/dist/docs/classes/Size.html +1 -1
  33. package/dist/docs/classes/Style.html +2 -2
  34. package/dist/docs/classes/SymbolDefinition.html +1 -1
  35. package/dist/docs/classes/SymbolItem.html +58 -4
  36. package/dist/docs/classes/TextItem.html +58 -4
  37. package/dist/docs/classes/Tool.html +126 -1
  38. package/dist/docs/classes/ToolEvent.html +1 -1
  39. package/dist/docs/classes/Tween.html +1 -1
  40. package/dist/docs/classes/View.html +144 -2
  41. package/dist/docs/classes/global.html +1 -1
  42. package/dist/docs/classes/index.html +2 -2
  43. package/dist/docs/index.html +1 -1
  44. package/dist/paper-core.js +425 -123
  45. package/dist/paper-core.min.js +3 -3
  46. package/dist/paper-full.js +434 -128
  47. package/dist/paper-full.min.js +3 -3
  48. package/dist/paper-sourced.js +18631 -0
  49. package/dist/paper.d.ts +284 -7
  50. package/package.json +6 -10
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.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: Mon Oct 19 15:31:53 2026 +0200
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
@@ -1274,6 +1347,16 @@ declare namespace paper {
1274
1347
  */
1275
1348
  clipped: boolean
1276
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
+
1277
1360
 
1278
1361
  /**
1279
1362
  * Creates a new Group item and places it at the top of the active layer.
@@ -1308,6 +1391,14 @@ declare namespace paper {
1308
1391
  /**
1309
1392
  * If the HitResult has a {@link HitResult#type} of `'bounds'`, this
1310
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.
1311
1402
  */
1312
1403
  name: string
1313
1404
 
@@ -1342,6 +1433,17 @@ declare namespace paper {
1342
1433
  point: Point
1343
1434
 
1344
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
+
1345
1447
  }
1346
1448
 
1347
1449
  /**
@@ -1353,6 +1455,14 @@ declare namespace paper {
1353
1455
  * that they inherit from Item.
1354
1456
  */
1355
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
+
1356
1466
  /**
1357
1467
  * The unique id of the item.
1358
1468
  */
@@ -1539,6 +1649,11 @@ declare namespace paper {
1539
1649
  */
1540
1650
  readonly view: View
1541
1651
 
1652
+ /**
1653
+ * The scope that this item belongs to, through its project.
1654
+ */
1655
+ readonly scope: PaperScope
1656
+
1542
1657
  /**
1543
1658
  * The layer that this item is contained within.
1544
1659
  */
@@ -1623,7 +1738,9 @@ declare namespace paper {
1623
1738
  /**
1624
1739
  * Specifies whether the stroke is to be drawn taking the current affine
1625
1740
  * transformation into account (the default behavior), or whether it should
1626
- * 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.
1627
1744
  */
1628
1745
  strokeScaling: boolean
1629
1746
 
@@ -2308,9 +2425,10 @@ declare namespace paper {
2308
2425
  isEmpty(recursively?: boolean): boolean
2309
2426
 
2310
2427
  /**
2311
- * 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}.
2312
2430
  *
2313
- * @return true if the item has a fill
2431
+ * @return true if the item has a visible fill
2314
2432
  */
2315
2433
  hasFill(): boolean
2316
2434
 
@@ -3307,6 +3425,12 @@ declare namespace paper {
3307
3425
  * when drawing selections
3308
3426
  * @option [settings.hitTolerance=0] {Number} the default tolerance for hit-
3309
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`
3310
3434
  */
3311
3435
  settings: any
3312
3436
 
@@ -3335,6 +3459,7 @@ declare namespace paper {
3335
3459
  */
3336
3460
  tools: Tool[]
3337
3461
 
3462
+ ChangeFlag: typeof ChangeFlag
3338
3463
  Color: typeof Color
3339
3464
  CompoundPath: typeof CompoundPath
3340
3465
  Curve: typeof Curve
@@ -3344,6 +3469,7 @@ declare namespace paper {
3344
3469
  GradientStop: typeof GradientStop
3345
3470
  Group: typeof Group
3346
3471
  HitResult: typeof HitResult
3472
+ HostItem: typeof HostItem
3347
3473
  Item: typeof Item
3348
3474
  Key: typeof Key
3349
3475
  KeyEvent: typeof KeyEvent
@@ -3482,6 +3608,9 @@ declare namespace paper {
3482
3608
  * generation
3483
3609
  * @option options.source {String} the source to be used for the source-
3484
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
3485
3614
  *
3486
3615
  * @param code - the PaperScript code
3487
3616
  * @param scope - the scope for which the code is executed
@@ -3996,7 +4125,10 @@ declare namespace paper {
3996
4125
 
3997
4126
  class RegularPolygon extends Path {
3998
4127
  /**
3999
- * 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.
4000
4132
  *
4001
4133
  * @param center - the center point of the polygon
4002
4134
  * @param sides - the number of sides of the polygon
@@ -5075,6 +5207,39 @@ declare namespace paper {
5075
5207
  * {@link PaperScope#projects} variable.
5076
5208
  */
5077
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
+
5078
5243
  /**
5079
5244
  * The reference to the project's view.
5080
5245
  */
@@ -5128,6 +5293,39 @@ declare namespace paper {
5128
5293
  */
5129
5294
  constructor(element: HTMLCanvasElement | string | SizeLike)
5130
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
+
5131
5329
  /**
5132
5330
  * Activates this project, so all newly created items will be placed
5133
5331
  * in it.
@@ -6638,7 +6836,9 @@ declare namespace paper {
6638
6836
  /**
6639
6837
  * Specifies whether the stroke is to be drawn taking the current affine
6640
6838
  * transformation into account (the default behavior), or whether it should
6641
- * 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.
6642
6842
  */
6643
6843
  strokeScaling: boolean
6644
6844
 
@@ -6869,6 +7069,11 @@ declare namespace paper {
6869
7069
  * {@link #onKeyUp}).
6870
7070
  */
6871
7071
  class Tool {
7072
+ /**
7073
+ * The scope that this tool belongs to.
7074
+ */
7075
+ readonly scope: PaperScope
7076
+
6872
7077
  /**
6873
7078
  * The minimum distance the mouse has to drag before firing the onMouseDrag
6874
7079
  * event, since the last onMouseDrag event.
@@ -6881,6 +7086,15 @@ declare namespace paper {
6881
7086
  */
6882
7087
  maxDistance: number
6883
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
+
6884
7098
 
6885
7099
  fixedDistance: number
6886
7100
 
@@ -6937,6 +7151,19 @@ declare namespace paper {
6937
7151
  */
6938
7152
  onKeyUp: Function | null
6939
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
+
6940
7167
 
6941
7168
  /**
6942
7169
  * Activates this tool, meaning {@link PaperScope#tool} will
@@ -7159,6 +7386,8 @@ declare namespace paper {
7159
7386
  * `html, body { height: 100%; }` and `canvas[resize] { width: 100%; height:
7160
7387
  * 100%; }` for a canvas that fills the window. Without such CSS, the view does
7161
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}.
7162
7391
  */
7163
7392
  class View {
7164
7393
  /**
@@ -7180,6 +7409,11 @@ declare namespace paper {
7180
7409
  */
7181
7410
  readonly project: Project
7182
7411
 
7412
+ /**
7413
+ * The scope that this view belongs to.
7414
+ */
7415
+ readonly scope: PaperScope
7416
+
7183
7417
  /**
7184
7418
  * The ratio between physical pixels and device-independent pixels (DIPs)
7185
7419
  * of the underlying canvas / device.
@@ -7634,6 +7868,49 @@ declare namespace paper {
7634
7868
  */
7635
7869
  responds(type: string): boolean
7636
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
+
7637
7914
  }
7638
7915
  }
7639
7916
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paper",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "The Swiss Army Knife of Vector Graphics Scripting",
5
5
  "license": "MIT",
6
6
  "homepage": "http://paperjs.org",
@@ -26,7 +26,9 @@
26
26
  "jshint": "gulp jshint",
27
27
  "test": "gulp test",
28
28
  "test:browser": "gulp test:browser",
29
- "test:node": "gulp test:node"
29
+ "test:chrome": "gulp test:chrome",
30
+ "test:node": "gulp test:node",
31
+ "prepare": "husky"
30
32
  },
31
33
  "files": [
32
34
  "AUTHORS.md",
@@ -42,12 +44,6 @@
42
44
  "engines": {
43
45
  "node": ">=8.0.0"
44
46
  },
45
- "husky": {
46
- "hooks": {
47
- "pre-commit": "yarn jshint --ensure-branch develop",
48
- "pre-push": "yarn test --ensure-branch develop"
49
- }
50
- },
51
47
  "browser": {
52
48
  "./dist/node/extend.js": false,
53
49
  "./dist/node/self.js": false,
@@ -78,14 +74,14 @@
78
74
  "gulp-webserver": "^0.9.1",
79
75
  "gulp-whitespace": "^0.1.0",
80
76
  "gulp-zip": "^5.1.0",
81
- "husky": "^4.3.8",
77
+ "husky": "^9.1.7",
82
78
  "jsdom": "^28.1.0",
83
79
  "jshint": "^2.13.6",
84
80
  "jshint-summary": "^0.4.0",
85
81
  "merge-stream": "^2.0.0",
86
82
  "minimist": "^1.2.8",
87
83
  "mustache": "^4.2.0",
88
- "prepro": "^2.4.0",
84
+ "prepro": "^2.5.0",
89
85
  "qunitjs": "^1.23.1",
90
86
  "require-dir": "^1.2.0",
91
87
  "resemblejs": "^3.2.5",