paper 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +158 -0
  2. package/README.md +24 -16
  3. package/dist/docs/assets/js/paper.js +4811 -808
  4. package/dist/docs/classes/AreaText.html +771 -243
  5. package/dist/docs/classes/ChangeFlag.html +1 -1
  6. package/dist/docs/classes/Color.html +218 -21
  7. package/dist/docs/classes/CompoundPath.html +1174 -274
  8. package/dist/docs/classes/Curve.html +2 -2
  9. package/dist/docs/classes/CurveLocation.html +1 -1
  10. package/dist/docs/classes/DrawEvent.html +69 -0
  11. package/dist/docs/classes/Effect.html +434 -0
  12. package/dist/docs/classes/EffectInstance.html +304 -0
  13. package/dist/docs/classes/Event.html +1 -1
  14. package/dist/docs/classes/Gradient.html +1 -1
  15. package/dist/docs/classes/GradientStop.html +1 -1
  16. package/dist/docs/classes/Group.html +842 -243
  17. package/dist/docs/classes/HitResult.html +1 -1
  18. package/dist/docs/classes/HostItem.html +770 -242
  19. package/dist/docs/classes/Item.html +827 -242
  20. package/dist/docs/classes/Key.html +1 -1
  21. package/dist/docs/classes/KeyEvent.html +1 -1
  22. package/dist/docs/classes/Layer.html +784 -185
  23. package/dist/docs/classes/Matrix.html +1 -1
  24. package/dist/docs/classes/MouseEvent.html +1 -1
  25. package/dist/docs/classes/PaperScope.html +1 -1
  26. package/dist/docs/classes/PaperScript.html +4 -2
  27. package/dist/docs/classes/Path.html +1366 -352
  28. package/dist/docs/classes/PathItem.html +1198 -298
  29. package/dist/docs/classes/PathText.html +772 -244
  30. package/dist/docs/classes/PatternDefinition.html +367 -0
  31. package/dist/docs/classes/Point.html +33 -5
  32. package/dist/docs/classes/PointText.html +771 -243
  33. package/dist/docs/classes/Project.html +251 -9
  34. package/dist/docs/classes/Raster.html +770 -242
  35. package/dist/docs/classes/Rectangle.html +50 -8
  36. package/dist/docs/classes/Segment.html +79 -2
  37. package/dist/docs/classes/Shape.html +770 -242
  38. package/dist/docs/classes/Size.html +31 -3
  39. package/dist/docs/classes/StrokeProfileStop.html +346 -0
  40. package/dist/docs/classes/Style.html +67 -6
  41. package/dist/docs/classes/SymbolDefinition.html +28 -2
  42. package/dist/docs/classes/SymbolItem.html +807 -242
  43. package/dist/docs/classes/TextItem.html +771 -243
  44. package/dist/docs/classes/TextRange.html +1 -1
  45. package/dist/docs/classes/TextStory.html +1 -1
  46. package/dist/docs/classes/Tool.html +2 -2
  47. package/dist/docs/classes/ToolEvent.html +1 -1
  48. package/dist/docs/classes/Tween.html +1 -1
  49. package/dist/docs/classes/View.html +2 -2
  50. package/dist/docs/classes/global.html +1 -1
  51. package/dist/docs/classes/index.html +2 -2
  52. package/dist/docs/index.html +1 -1
  53. package/dist/node/browser.js +15 -0
  54. package/dist/paper-core.js +4701 -728
  55. package/dist/paper-core.min.js +3 -3
  56. package/dist/paper-full.js +4811 -808
  57. package/dist/paper-full.min.js +3 -3
  58. package/dist/paper-hosted.js +5389 -892
  59. package/dist/paper.d.ts +1058 -69
  60. package/examples/Paperjs.org/LiveEffects.html +366 -0
  61. package/examples/Paperjs.org/Offsetting.html +379 -0
  62. package/examples/Paperjs.org/StrokeProfiles.html +706 -0
  63. package/examples/Scripts/Patterns.html +57 -0
  64. package/package.json +21 -11
package/dist/paper.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Paper.js v0.15.0 - The Swiss Army Knife of Vector Graphics Scripting.
2
+ * Paper.js v0.17.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: Wed Oct 21 15:44:40 2026 +0200
12
+ * Date: Tue Nov 3 20:27:46 2026 +0100
13
13
  *
14
14
  * This is an auto-generated type definition.
15
15
  */
@@ -60,6 +60,7 @@ declare namespace paper {
60
60
  destination: PointLike,
61
61
  highlight?: PointLike
62
62
  }
63
+ | { pattern: PatternDefinition, matrix?: Matrix }
63
64
  )
64
65
 
65
66
  type GradientStopLike = GradientStop | ColorLike | [ ColorLike, number ]
@@ -286,6 +287,25 @@ declare namespace paper {
286
287
  get highlight(): Point
287
288
  set highlight(value: PointLike)
288
289
 
290
+ /**
291
+ * The aspect of a radial gradient: its radius across the line from
292
+ * the origin to the destination, as a factor of its radius along it,
293
+ * which makes it an ellipse. Transforming a gradient color sets it, so
294
+ * that the gradient stretches, shears and rotates with its item.
295
+ */
296
+ aspect: number
297
+
298
+ /**
299
+ * The pattern whose tiles the color repeats.
300
+ */
301
+ pattern: PatternDefinition
302
+
303
+ /**
304
+ * The matrix that places the tiles of the pattern in the item's
305
+ * coordinates.
306
+ */
307
+ matrix: Matrix
308
+
289
309
 
290
310
  /**
291
311
  * Creates a RGB Color object.
@@ -327,11 +347,18 @@ declare namespace paper {
327
347
  /**
328
348
  * Creates a gradient Color object.
329
349
  */
330
- constructor(gradient: Gradient, origin: PointLike, destination: PointLike, highlight?: PointLike)
350
+ constructor(gradient: Gradient, origin: PointLike, destination: PointLike, highlight?: PointLike, aspect?: number)
331
351
 
332
352
  /**
333
- * Creates a HSB, HSL or gradient Color object from the properties of
334
- * the provided object:
353
+ * Creates a pattern Color object, which repeats the tiles of the
354
+ * pattern, placed by the matrix in the item's coordinates. As with
355
+ * gradient colors, the matrix is transformed along with the item.
356
+ */
357
+ constructor(pattern: PatternDefinition, matrix?: Matrix)
358
+
359
+ /**
360
+ * Creates a HSB, HSL, gradient or pattern Color object from the
361
+ * properties of the provided object:
335
362
  *
336
363
  * @option hsb.hue {Number} the hue of the color as a value in degrees
337
364
  * between `0` and `360`
@@ -358,6 +385,10 @@ declare namespace paper {
358
385
  * the gradient, as an alternative to providing a gradient object
359
386
  * @option gradient.radial {Boolean} controls whether the gradient is
360
387
  * radial, as an alternative to providing a gradient object
388
+ * @option pattern.pattern {PatternDefinition} the pattern whose tiles
389
+ * the color repeats
390
+ * @option pattern.matrix {Matrix} the matrix that places the tiles in
391
+ * the item's coordinates
361
392
  *
362
393
  * @param object - an object describing the components and
363
394
  * properties of the color
@@ -419,9 +450,13 @@ declare namespace paper {
419
450
  toCSS(hex: boolean): string
420
451
 
421
452
  /**
422
- * Transform the gradient color by the specified matrix.
453
+ * Transform the gradient or pattern color by the specified matrix.
454
+ * Radial gradients become ellipses, see {@link #aspect}, and the
455
+ * stripes of linear gradients keep running across them, also when the
456
+ * matrix scales unevenly or shears. Pattern colors transform their
457
+ * {@link #matrix}.
423
458
  *
424
- * @param matrix - the matrix to transform the gradient color by
459
+ * @param matrix - the matrix to transform the color by
425
460
  */
426
461
  transform(matrix: Matrix): void
427
462
 
@@ -886,7 +921,9 @@ declare namespace paper {
886
921
  clearHandles(): void
887
922
 
888
923
  /**
889
- * Checks if this curve has any curve handles set.
924
+ * Checks if this curve has any curve handles set. Handles of which both
925
+ * coordinates are 0 within a tolerance of 1e-12 count as not set, see
926
+ * {@link Point#isZero}.
890
927
  *
891
928
  * @see Curve#handle1
892
929
  * @see Curve#handle2
@@ -1432,6 +1469,175 @@ declare namespace paper {
1432
1469
 
1433
1470
  }
1434
1471
 
1472
+ /**
1473
+ * The DrawEvent object is received by the {@link Item}'s drawing
1474
+ * handlers {@link Item#onDraw} and {@link Item#onDrawSelection}, which
1475
+ * describe its fields.
1476
+ */
1477
+ class DrawEvent {
1478
+
1479
+ /**
1480
+ * Skips the item's default drawing, as returning `false` from the handler
1481
+ * does.
1482
+ */
1483
+ preventDefault(): void
1484
+
1485
+ }
1486
+
1487
+ /**
1488
+ * A live effect, which derives what is drawn from an item without
1489
+ * changing the item itself, as the effects in Illustrator do. Creating one
1490
+ * registers it under its type, replacing any effect registered there before,
1491
+ * and items use it by that type, see {@link Item#effects}, each through an
1492
+ * {@link EffectInstance} with its own parameters.
1493
+ */
1494
+ class Effect {
1495
+ /**
1496
+ * The type that the effect is registered under, and that items use it
1497
+ * by.
1498
+ */
1499
+ readonly type: string
1500
+
1501
+ /**
1502
+ * The label of the effect, for hosts to show to users.
1503
+ */
1504
+ readonly label: string
1505
+
1506
+ /**
1507
+ * The declared parameters of the effect by their names, as objects
1508
+ * that describe them for hosts to build their settings from, with the
1509
+ * default as their `value`, e.g.
1510
+ * `{ label: 'Amount', type: 'number', range: [0, 100], value: 10 }`.
1511
+ * The instances of the effect have them as properties.
1512
+ */
1513
+ readonly parameters: any
1514
+
1515
+ /**
1516
+ * The function that applies the effect, called with the instance as
1517
+ * `this`, and returning what the effect makes of the art that it gets,
1518
+ * which it doesn't change.
1519
+ *
1520
+ * @option event.art {Item} the item to apply the effect to, or what
1521
+ * the effect before it returned
1522
+ * @option event.item {Item} the item that the instance is part of
1523
+ */
1524
+ onApply: Function | null
1525
+
1526
+ /**
1527
+ * The function that hosts call when the user edits the parameters of
1528
+ * an instance, with the instance as `this`, to set its properties.
1529
+ * Paper.js itself doesn't call it.
1530
+ */
1531
+ onEditParameters: Function | null
1532
+
1533
+
1534
+ /**
1535
+ * Creates an effect and registers it under its type.
1536
+ *
1537
+ * @param props - the {@link #type} of the effect, its
1538
+ * {@link #label} and {@link #parameters}, and {@link #onApply}
1539
+ * and {@link #onEditParameters}
1540
+ */
1541
+ constructor(props: object)
1542
+
1543
+ /**
1544
+ * Removes the effect from the registered effects.
1545
+ *
1546
+ * @return true if the effect was registered
1547
+ */
1548
+ remove(): boolean
1549
+
1550
+ /**
1551
+ * Registers the effect under its type, replacing any effect
1552
+ * registered there before. Effects register themselves when they
1553
+ * are created.
1554
+ *
1555
+ * @return the effect
1556
+ */
1557
+ static add(effect: Effect): Effect
1558
+
1559
+ /**
1560
+ * Returns the effect registered under the type.
1561
+ *
1562
+ * @return the effect, or `null`
1563
+ */
1564
+ static get(type: string): Effect | null
1565
+
1566
+ /**
1567
+ * Returns all registered effects.
1568
+ *
1569
+ * @return the effects
1570
+ */
1571
+ static getAll(): Effect[]
1572
+
1573
+ /**
1574
+ * Removes the effect from the registered effects.
1575
+ *
1576
+ * @return true if the effect was registered
1577
+ */
1578
+ static remove(effect: Effect): boolean
1579
+
1580
+ }
1581
+
1582
+ /**
1583
+ * The use of an {@link Effect} on an item, see {@link Item#effects},
1584
+ * with its parameters. The parameters that the effect declares are also its
1585
+ * properties. Instances of effects that aren't registered keep their
1586
+ * parameters and leave what they get as it is, so that they still round-trip.
1587
+ */
1588
+ class EffectInstance {
1589
+ /**
1590
+ * The type of the effect that the instance uses, also when it isn't
1591
+ * registered.
1592
+ */
1593
+ readonly type: string
1594
+
1595
+ /**
1596
+ * The effect that the instance uses, registered under its {@link #type},
1597
+ * or `null` if there is none.
1598
+ */
1599
+ readonly effect: Effect | null
1600
+
1601
+ /**
1602
+ * Whether the effect applies. Effects that aren't visible are skipped.
1603
+ */
1604
+ visible: boolean
1605
+
1606
+ /**
1607
+ * The parameters of the instance. Changing them on the returned object
1608
+ * updates it, as setting them as its properties does. Parameters that it
1609
+ * doesn't have yet are added by setting them all, as are changes within
1610
+ * values such as arrays.
1611
+ */
1612
+ parameters: any
1613
+
1614
+ /**
1615
+ * The item that the instance is part of.
1616
+ */
1617
+ readonly item: Item | null
1618
+
1619
+ /**
1620
+ * The index of the instance in the {@link Item#effects} of its item.
1621
+ */
1622
+ readonly index: number | null
1623
+
1624
+
1625
+ /**
1626
+ * Removes the instance from its item.
1627
+ *
1628
+ * @return true if the instance was removed
1629
+ */
1630
+ remove(): boolean
1631
+
1632
+ /**
1633
+ * Checks whether the instance is equal to the supplied one.
1634
+ *
1635
+ * @return true if they are equal
1636
+ */
1637
+ equals(instance: EffectInstance): boolean
1638
+
1639
+ }
1640
+
1435
1641
  /**
1436
1642
  * The Event object is the base class for any of the other event types,
1437
1643
  * such as {@link MouseEvent}, {@link ToolEvent} and {@link KeyEvent}.
@@ -1570,10 +1776,43 @@ declare namespace paper {
1570
1776
  * like CSS's `isolation: isolate`. Without it, a compositing mode such as
1571
1777
  * `'destination-out'` affects everything drawn below the group, also in
1572
1778
  * other layers. Groups with an {@link Item#opacity} below 1 or a
1573
- * {@link Item#blendMode} are isolated anyway.
1779
+ * {@link Item#blendMode} are isolated anyway, and buffered groups always,
1780
+ * see {@link #buffered}.
1574
1781
  */
1575
1782
  isolated: boolean
1576
1783
 
1784
+ /**
1785
+ * Specifies whether the group is buffered: when a view draws it, it draws
1786
+ * its content into a canvas of its own, which it keeps, and only draws
1787
+ * into it again when something in the group changes, or the part of it
1788
+ * that the view shows does, e.g. after zooming or panning. Otherwise, the
1789
+ * view only composites the buffer, with the group's {@link Item#opacity}
1790
+ * and {@link Item#blendMode}. This pays off for large groups and layers
1791
+ * that rarely change, such as a complex background below animated items.
1792
+ *
1793
+ * It doesn't pay off when the buffer is drawn again on every frame: while
1794
+ * the view pans or zooms on every frame, while the group itself is moved
1795
+ * or transformed, or when an item inside it is animated. Put animated
1796
+ * items into another group or layer instead.
1797
+ *
1798
+ * The buffer costs memory: it covers the part of the group that the view
1799
+ * shows, at up to `width × height × 4 × pixelRatio²` bytes for a group
1800
+ * that fills the whole view.
1801
+ *
1802
+ * Buffered groups are always {@link #isolated}: the blend modes of their
1803
+ * children only apply within them, not to the items below them, also in
1804
+ * other layers.
1805
+ *
1806
+ * Hit-testing, SVG export, {@link Item#rasterize} and drawing into other
1807
+ * canvases than the view's don't use the buffer.
1808
+ *
1809
+ * A buffered group keeps one buffer, so inside a {@link SymbolDefinition}
1810
+ * that is placed several times, it draws into it again for each placement.
1811
+ * Changes to any symbol definition make all buffers stale, as do forced
1812
+ * updates through `view.update(true)`.
1813
+ */
1814
+ buffered: boolean
1815
+
1577
1816
 
1578
1817
  /**
1579
1818
  * Creates a new Group item and places it at the top of the active layer.
@@ -1682,6 +1921,36 @@ declare namespace paper {
1682
1921
  * that they inherit from Item.
1683
1922
  */
1684
1923
  class Item {
1924
+ /**
1925
+ * The live effects of the item, in the order in which they apply, as
1926
+ * the instances of the {@link Effect effects} that they use. They
1927
+ * derive what is drawn from the item without changing it: drawing
1928
+ * draws their output, and {@link #previewBounds} measures it, while
1929
+ * hit testing, {@link #bounds} and {@link #strokeBounds} stay with the
1930
+ * item itself. It is set to plain objects describing them, `{ type,
1931
+ * parameters, visible }`, with the `type` of the effect.
1932
+ * Changing the returned array directly isn't tracked, as with
1933
+ * {@link Path#segments}.
1934
+ *
1935
+ * Paper.js has these effects, and {@link Effect} creates more:
1936
+ *
1937
+ * - `offset`: offsets the paths, see {@link PathItem#offset}, with
1938
+ * the parameters `distance` (`0`), `join` (`'miter'`) and
1939
+ * `miterLimit` (`10`).
1940
+ * - `outline`: outlines the strokes of the paths as filled areas next
1941
+ * to their fills, see {@link PathItem#outline}, following their
1942
+ * {@link Path#strokeProfile}.
1943
+ */
1944
+ effects: EffectInstance[]
1945
+
1946
+ /**
1947
+ * The bounds of what the item looks like with its effects, in the
1948
+ * coordinate space of its parent: of their output with its strokes, or of
1949
+ * its children's with their effects, and its {@link #strokeBounds}
1950
+ * without them, as Illustrator's "Use Preview Bounds".
1951
+ */
1952
+ readonly previewBounds: Rectangle
1953
+
1685
1954
  /**
1686
1955
  * The key of the host's node that the item represents, in a project
1687
1956
  * backed by a host document, see {@link Project#host}. It can only be
@@ -2020,6 +2289,14 @@ declare namespace paper {
2020
2289
  */
2021
2290
  miterLimit: number
2022
2291
 
2292
+ /**
2293
+ * The order in which the fill and the stroke are painted, as in SVG's
2294
+ * `paint-order`, named after what is painted first: `'fill'` paints the
2295
+ * fill first, `'stroke'` paints the stroke first, so the fill covers its
2296
+ * inner half.
2297
+ */
2298
+ paintOrder: string
2299
+
2023
2300
  /**
2024
2301
  * The fill color of the item.
2025
2302
  */
@@ -2169,6 +2446,136 @@ declare namespace paper {
2169
2446
  */
2170
2447
  onMouseLeave: Function | null
2171
2448
 
2449
+ /**
2450
+ * The function to be called whenever the item is drawn: in views, in
2451
+ * {@link #rasterize}, and once for each placement of a symbol whose
2452
+ * definition contains it. It is called right before the item's default
2453
+ * drawing, and draws with the canvas API beneath it, or replaces it by
2454
+ * returning `false` or calling `event.preventDefault()`. The function
2455
+ * receives a {@link DrawEvent} object with these fields:
2456
+ *
2457
+ * @option event.item {Item} the item that is drawn
2458
+ * @option event.context {CanvasRenderingContext2D} the canvas context,
2459
+ * transformed into the item's coordinates
2460
+ * @option event.matrix {Matrix} the matrix from the item's coordinates to
2461
+ * the pixels of the view, without its pixel ratio, for drawing things
2462
+ * at a size in pixels
2463
+ * @option event.pixelRatio {Number} the device pixels per pixel: the
2464
+ * view's pixel ratio, or the resolution divided by 72 in
2465
+ * {@link #rasterize}
2466
+ * @option event.view {View} the view drawn into, or `null` in
2467
+ * {@link #rasterize}
2468
+ *
2469
+ * What the handler draws isn't part of the item's hit testing, its bounds
2470
+ * or its SVG export. In buffered groups, it is only called when the group
2471
+ * draws its buffer again, see {@link Group#buffered}.
2472
+ */
2473
+ onDraw: Function | null
2474
+
2475
+ /**
2476
+ * The function to be called when the selection of the selected item is
2477
+ * drawn, over all the content. It is called right before the item's
2478
+ * default selection drawing, and draws with the canvas API beneath it, or
2479
+ * replaces it by returning `false` or calling `event.preventDefault()`. The
2480
+ * function receives a {@link DrawEvent} object with these fields:
2481
+ *
2482
+ * @option event.item {Item} the selected item
2483
+ * @option event.context {CanvasRenderingContext2D} the canvas context, in
2484
+ * the pixels of the view, with the selection color as its `strokeStyle`
2485
+ * and `fillStyle`, and a `lineWidth` of 1
2486
+ * @option event.matrix {Matrix} the matrix from the item's coordinates to
2487
+ * the pixels of the view
2488
+ * @option event.size {Number} the size of the handles, see
2489
+ * {@link PaperScope#settings}
2490
+ * @option event.color {Color} the selection color, see
2491
+ * {@link #selectedColor}
2492
+ * @option event.view {View} the view drawn into
2493
+ *
2494
+ * What the handler draws isn't part of the item's hit testing, its bounds
2495
+ * or its SVG export.
2496
+ */
2497
+ onDrawSelection: Function | null
2498
+
2499
+ /**
2500
+ * The function to be called whenever any item of the class or of its
2501
+ * subclasses is drawn, as {@link #onDraw} is for a single item, e.g.
2502
+ * `Path.onDraw` for all paths, including the ones created later. The
2503
+ * item's own handlers are called first, then the ones of its class and of
2504
+ * the classes it inherits from, up to `Item`, with `this` set to the item.
2505
+ * `Path.on('draw', handler)` and `Path.off('draw', handler)` attach and
2506
+ * detach them too. Only the drawing events can be handled for classes of
2507
+ * items. Classes are shared by all {@link PaperScope} objects, and so are
2508
+ * their handlers.
2509
+ */
2510
+ static onDraw: Function | null
2511
+
2512
+ /**
2513
+ * The function to be called when the selection of any selected item of the
2514
+ * class or of its subclasses is drawn, as {@link #onDrawSelection} is for
2515
+ * a single item, e.g. `Path.onDrawSelection` for all paths, see
2516
+ * {@link Item.onDraw}.
2517
+ */
2518
+ static onDrawSelection: Function | null
2519
+
2520
+
2521
+ /**
2522
+ * Adds an effect at the end of the item's effects.
2523
+ *
2524
+ * @param effect - the plain object describing the effect
2525
+ *
2526
+ * @return the added instance
2527
+ */
2528
+ addEffect(effect: object): EffectInstance
2529
+
2530
+ /**
2531
+ * Inserts an effect into the item's effects at the given index.
2532
+ *
2533
+ * @param index - the index at which to insert the effect
2534
+ * @param effect - the plain object describing the effect
2535
+ *
2536
+ * @return the inserted instance
2537
+ */
2538
+ insertEffect(index: number, effect: object): EffectInstance
2539
+
2540
+ /**
2541
+ * Inserts effects into the item's effects at the given index.
2542
+ *
2543
+ * @param index - the index at which to insert the effects
2544
+ * @param effects - the plain objects describing the effects
2545
+ *
2546
+ * @return the inserted instances
2547
+ */
2548
+ insertEffects(index: number, effects: object[]): EffectInstance[]
2549
+
2550
+ /**
2551
+ * Removes the effect at the given index from the item's effects.
2552
+ *
2553
+ * @param index - the index of the effect to remove
2554
+ *
2555
+ * @return the removed instance, or `null`
2556
+ */
2557
+ removeEffect(index: number): EffectInstance
2558
+
2559
+ /**
2560
+ * Removes the effects from the start index to the end index from the
2561
+ * item's effects, or all of them.
2562
+ *
2563
+ * @param start - the index of the first effect to remove
2564
+ * @param end - the index after the last one
2565
+ *
2566
+ * @return the removed instances
2567
+ */
2568
+ removeEffects(start?: number, end?: number): EffectInstance[]
2569
+
2570
+ /**
2571
+ * Returns what the item's visible effects make of it, in the item's own
2572
+ * coordinates, outside of the scene graph, or `null` if it has none. It
2573
+ * is kept until the item, its content, its effects or the registered
2574
+ * effects change, so changing it isn't tracked.
2575
+ *
2576
+ * @return the output of the effects
2577
+ */
2578
+ getEffectOutput(): Item | null
2172
2579
 
2173
2580
  /**
2174
2581
  * Sets the properties of the passed object literal on this item to the
@@ -2477,15 +2884,17 @@ declare namespace paper {
2477
2884
  importJSON(json: string): Item
2478
2885
 
2479
2886
  /**
2480
- * Exports the item with its content and child items as an SVG DOM.
2887
+ * Exports the item with its content and child items as an SVG DOM. With
2888
+ * `options.bounds` or `options.matrix`, the item is wrapped in an `<svg>`
2889
+ * element sized to the bounds, as {@link Project#exportSVG} does.
2481
2890
  *
2482
- * @option [options.bounds='view'] {String|Rectangle} the bounds of the area
2483
- * to export, either as a string ({@values 'view', content'}), or a
2891
+ * @option [options.bounds] {String|Rectangle} the bounds of the area to
2892
+ * export, either as a string ({@values 'view', content'}), or a
2484
2893
  * {@link Rectangle} object: `'view'` uses the view bounds,
2485
- * `'content'` uses the stroke bounds of all content
2486
- * @option [options.matrix=paper.view.matrix] {Matrix} the matrix with which
2487
- * to transform the exported content: If `options.bounds` is set to
2488
- * `'view'`, `paper.view.matrix` is used, for all other settings of
2894
+ * `'content'` uses the stroke bounds of the item
2895
+ * @option [options.matrix] {Matrix} the matrix with which to transform the
2896
+ * exported content: If `options.bounds` is set to `'view'`,
2897
+ * `paper.view.matrix` is used, for all other settings of
2489
2898
  * `options.bounds` the identity matrix is used.
2490
2899
  * @option [options.asString=false] {Boolean} whether a SVG node or a
2491
2900
  * `String` is to be returned
@@ -2506,13 +2915,19 @@ declare namespace paper {
2506
2915
  * @option [options.reduceAttributes=true] {Boolean} wether to only include
2507
2916
  * style attributes in the SVG output that differ from their parents,
2508
2917
  * or to always include them (much faster but leading to redundancies).
2918
+ * @option [options.processNode] {Function} the function to process the
2919
+ * SVG node made for each exported item, receiving an object with the
2920
+ * `item` and its `node`: It can change the node, e.g. to add attributes
2921
+ * that Paper.js doesn't export, or return a node to replace it with. It
2922
+ * is called before the item's name, style, visibility and data are set
2923
+ * on the node, which replace attributes of the same names.
2509
2924
  *
2510
2925
  * @param options - the export options
2511
2926
  *
2512
2927
  * @return the item converted to an SVG node or a
2513
2928
  * `String` depending on `option.asString` value
2514
2929
  */
2515
- exportSVG(options?: { bounds?: string | RectangleLike, matrix?: Matrix, asString?: boolean, precision?: number, matchShapes?: boolean, embedImages?: boolean, reuseImages?: boolean, idPrefix?: string, reduceAttributes?: boolean }): SVGElement | string
2930
+ exportSVG(options?: { bounds?: string | RectangleLike, matrix?: Matrix, asString?: boolean, precision?: number, matchShapes?: boolean, embedImages?: boolean, reuseImages?: boolean, idPrefix?: string, reduceAttributes?: boolean, processNode?: Function }): SVGElement | string
2516
2931
 
2517
2932
  /**
2518
2933
  * Converts the provided SVG content into Paper.js items and adds them to
@@ -2523,6 +2938,11 @@ declare namespace paper {
2523
2938
  * the `<use>` elements that place them as {@link SymbolItem} items. The
2524
2939
  * styles that `<use>` elements inherit don't reach the symbols' content.
2525
2940
  *
2941
+ * The layers in SVG content that Paper.js exported come back as
2942
+ * {@link Layer} items inside the imported group. To make the layers of a
2943
+ * project's SVG the layers of a project again, add them to it with
2944
+ * `item.children.slice().forEach(project.addLayer, project)`.
2945
+ *
2526
2946
  * URLs are fetched as they are, so validate URLs that come from untrusted
2527
2947
  * sources first, especially on servers, where they could reach internal
2528
2948
  * addresses.
@@ -2544,6 +2964,13 @@ declare namespace paper {
2544
2964
  * @option [options.applyMatrix={@link PaperScope#settings}.applyMatrix]
2545
2965
  * {Boolean} whether the imported items should have their transformation
2546
2966
  * matrices applied to their contents or not
2967
+ * @option [options.processItem] {Function} the function to process the
2968
+ * item made for each imported SVG element, receiving an object with
2969
+ * the `item` and its `node`: It can read attributes that Paper.js
2970
+ * doesn't import, or return an item to replace it with. It is called
2971
+ * after the element's attributes and data are applied to the item, so
2972
+ * it can extend `item.data`. A replacement item doesn't receive them:
2973
+ * copy them over from `item` as needed.
2547
2974
  *
2548
2975
  * @param svg - the SVG content to import, either as a SVG
2549
2976
  * DOM node, a string containing SVG content, or a string describing the
@@ -2553,7 +2980,7 @@ declare namespace paper {
2553
2980
  * @return the newly created Paper.js item containing the converted
2554
2981
  * SVG content
2555
2982
  */
2556
- importSVG(svg: SVGElement | string, options?: { expandShapes?: boolean, crossOrigin?: string, onLoad?: Function, onError?: Function, insert?: boolean, applyMatrix?: boolean }): Item
2983
+ importSVG(svg: SVGElement | string, options?: { expandShapes?: boolean, crossOrigin?: string, onLoad?: Function, onError?: Function, insert?: boolean, applyMatrix?: boolean, processItem?: Function }): Item
2557
2984
 
2558
2985
  /**
2559
2986
  * Imports the provided external SVG file, converts it into Paper.js items
@@ -3077,7 +3504,7 @@ declare namespace paper {
3077
3504
  *
3078
3505
  * @param type - the type of event: {@values 'frame', mousedown',
3079
3506
  * 'mouseup', 'mousedrag', 'click', 'doubleclick', 'mousemove',
3080
- * 'mouseenter', 'mouseleave'}
3507
+ * 'mouseenter', 'mouseleave', 'draw', 'drawselection'}
3081
3508
  * @param function - the function to be called when the event
3082
3509
  * occurs, receiving a {@link MouseEvent} or {@link Event} object as its
3083
3510
  * sole argument
@@ -3091,7 +3518,7 @@ declare namespace paper {
3091
3518
  *
3092
3519
  * @param object - an object containing one or more of the following
3093
3520
  * properties: {@values frame, mousedown, mouseup, mousedrag, click,
3094
- * doubleclick, mousemove, mouseenter, mouseleave}
3521
+ * doubleclick, mousemove, mouseenter, mouseleave, draw, drawselection}
3095
3522
  *
3096
3523
  * @return this item itself, so calls can be chained
3097
3524
  */
@@ -3102,7 +3529,7 @@ declare namespace paper {
3102
3529
  *
3103
3530
  * @param type - the type of event: {@values 'frame', mousedown',
3104
3531
  * 'mouseup', 'mousedrag', 'click', 'doubleclick', 'mousemove',
3105
- * 'mouseenter', 'mouseleave'}
3532
+ * 'mouseenter', 'mouseleave', 'draw', 'drawselection'}
3106
3533
  * @param function - the function to be detached
3107
3534
  *
3108
3535
  * @return this item itself, so calls can be chained
@@ -3114,7 +3541,7 @@ declare namespace paper {
3114
3541
  *
3115
3542
  * @param object - an object containing one or more of the following
3116
3543
  * properties: {@values frame, mousedown, mouseup, mousedrag, click,
3117
- * doubleclick, mousemove, mouseenter, mouseleave}
3544
+ * doubleclick, mousemove, mouseenter, mouseleave, draw, drawselection}
3118
3545
  *
3119
3546
  * @return this item itself, so calls can be chained
3120
3547
  */
@@ -3125,7 +3552,7 @@ declare namespace paper {
3125
3552
  *
3126
3553
  * @param type - the type of event: {@values 'frame', mousedown',
3127
3554
  * 'mouseup', 'mousedrag', 'click', 'doubleclick', 'mousemove',
3128
- * 'mouseenter', 'mouseleave'}
3555
+ * 'mouseenter', 'mouseleave', 'draw', 'drawselection'}
3129
3556
  * @param event - an object literal containing properties describing
3130
3557
  * the event
3131
3558
  *
@@ -3138,7 +3565,7 @@ declare namespace paper {
3138
3565
  *
3139
3566
  * @param type - the type of event: {@values 'frame', mousedown',
3140
3567
  * 'mouseup', 'mousedrag', 'click', 'doubleclick', 'mousemove',
3141
- * 'mouseenter', 'mouseleave'}
3568
+ * 'mouseenter', 'mouseleave', 'draw', 'drawselection'}
3142
3569
  *
3143
3570
  * @return true if the item has one or more event handlers of
3144
3571
  * the specified type
@@ -3901,6 +4328,9 @@ declare namespace paper {
3901
4328
  CompoundPath: typeof CompoundPath
3902
4329
  Curve: typeof Curve
3903
4330
  CurveLocation: typeof CurveLocation
4331
+ DrawEvent: typeof DrawEvent
4332
+ Effect: typeof Effect
4333
+ EffectInstance: typeof EffectInstance
3904
4334
  Event: typeof Event
3905
4335
  Gradient: typeof Gradient
3906
4336
  GradientStop: typeof GradientStop
@@ -3918,6 +4348,7 @@ declare namespace paper {
3918
4348
  Path: typeof Path
3919
4349
  PathItem: typeof PathItem
3920
4350
  PathText: typeof PathText
4351
+ PatternDefinition: typeof PatternDefinition
3921
4352
  Point: typeof Point
3922
4353
  PointText: typeof PointText
3923
4354
  Project: typeof Project
@@ -3926,6 +4357,7 @@ declare namespace paper {
3926
4357
  Segment: typeof Segment
3927
4358
  Shape: typeof Shape
3928
4359
  Size: typeof Size
4360
+ StrokeProfileStop: typeof StrokeProfileStop
3929
4361
  Style: typeof Style
3930
4362
  SymbolDefinition: typeof SymbolDefinition
3931
4363
  SymbolItem: typeof SymbolItem
@@ -4051,18 +4483,25 @@ declare namespace paper {
4051
4483
  * @option options.handlers {String[]} the names of further global
4052
4484
  * handlers to export next to `onFrame`, `onResize` and the tool's
4053
4485
  * handlers, for hosts that call them themselves
4486
+ * @option options.evaluate {Function} the evaluator for hosts that
4487
+ * evaluate code their own way: called with the source of a function
4488
+ * expression and `options.url`, and returning the function, e.g. by
4489
+ * evaluating the source as a script of that url
4054
4490
  * @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`
4491
+ * statements, called with the specifier as written, the `options.url`
4492
+ * of the importing script, and the import attributes as an object,
4493
+ * e.g. `{ type: 'paperscript' }` for `import x from 'm' with { type:
4494
+ * 'paperscript' }`, or `undefined` without them, and returning the
4495
+ * module's exports, e.g. the result of executing it. Modules with ES
4496
+ * `export` statements have their default export as `default` and are
4497
+ * marked with `__esModule`, so `import x` receives the default export,
4498
+ * and for CommonJS-style exports the whole exports. `import * as x`
4061
4499
  * receives all exports, and for CommonJS-style exports, these as
4062
4500
  * `default` too. Dynamic `import(specifier)` resolves to that
4063
4501
  * 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`
4502
+ * `import(specifier, options)` passes on `options.with` as the
4503
+ * attributes. The loader runs each module once and handles cycles.
4504
+ * Parsing `import` requires a current Acorn as `self.acorn`
4066
4505
  *
4067
4506
  * Code with top-level `await` runs as an async function. `execute()` then
4068
4507
  * returns a Promise of the exports, and installs the global handlers once
@@ -4075,7 +4514,7 @@ declare namespace paper {
4075
4514
  * @return the exports defined in the executed code, or
4076
4515
  * with top-level `await`, a Promise of them
4077
4516
  */
4078
- static execute(code: string, scope: PaperScope, options?: { url?: string, source?: string, handlers?: string[], load?: Function }): object | Promise<any>
4517
+ static execute(code: string, scope: PaperScope, options?: { url?: string, source?: string, handlers?: string[], evaluate?: Function, load?: Function }): object | Promise<any>
4079
4518
 
4080
4519
  /**
4081
4520
  * Loads, compiles and executes PaperScript code in the HTML document. Note
@@ -4102,7 +4541,40 @@ declare namespace paper {
4102
4541
  */
4103
4542
  class Path extends PathItem {
4104
4543
  /**
4105
- * The segments contained within the path.
4544
+ * The stroke profile of the path: the stops along it that set the pen
4545
+ * that draws its stroke, an ellipse with a width, as a factor of its
4546
+ * {@link Style#strokeWidth}, an aspect and an angle, see
4547
+ * {@link StrokeProfileStop}. The stops are sorted by their offsets.
4548
+ * Between the stops that set a value, it changes along the path,
4549
+ * easing into and out of smooth stops and in straight lines from the
4550
+ * others, see {@link StrokeProfileStop#smooth}, and beyond the ends
4551
+ * of open paths, it stays as at the first and last of them. Two stops
4552
+ * at the same offset make a step. The stops stay between the same
4553
+ * segments when they move. Without a stroke profile, the stroke is
4554
+ * drawn with a round pen of the stroke width all along.
4555
+ *
4556
+ * It is a property of the path, not of its style, as it is tied to
4557
+ * its segments. It can be set to stops or plain objects describing
4558
+ * them, `{ offset, width, aspect, angle, smooth }`, and JSON stores
4559
+ * them with the indices that tie them to the segments instead of
4560
+ * their offsets, `{ index, width, aspect, angle, smooth }`. Changing
4561
+ * the returned array directly isn't tracked, as with
4562
+ * {@link #segments}.
4563
+ *
4564
+ * The path draws its stroke as the area that the pens sweep, filled
4565
+ * with the stroke color, as {@link PathItem#outline} returns it,
4566
+ * and {@link Item#strokeBounds} and hit-testing measure that area.
4567
+ * The children of compound paths are drawn with the stroke of their
4568
+ * parent, without their profiles. With {@link Style#strokeScaling}
4569
+ * off, the profile scales with the view. {@link PathItem#offset},
4570
+ * the boolean operations, {@link PathItem#interpolate} and SVG
4571
+ * export return paths without the profile.
4572
+ */
4573
+ strokeProfile: StrokeProfileStop[] | null
4574
+
4575
+ /**
4576
+ * The segments contained within the path. Segments that define a
4577
+ * {@link Segment#name} can also be accessed by name.
4106
4578
  */
4107
4579
  segments: Segment[]
4108
4580
 
@@ -4184,6 +4656,23 @@ declare namespace paper {
4184
4656
  */
4185
4657
  constructor(object: object)
4186
4658
 
4659
+ /**
4660
+ * Returns the pen of the {@link #strokeProfile} at the given offset
4661
+ * along the path, as a stop that isn't on the path, with all its
4662
+ * values: its width as a factor of the {@link Style#strokeWidth}, its
4663
+ * aspect and its angle, `1`, `1` and `0` where no stop sets them.
4664
+ * Where the profile has a step, it returns the values after it. Adding
4665
+ * the stop to the profile keeps the values at the offset, and where
4666
+ * they change in straight lines, also around it if the stop isn't
4667
+ * smooth. As a smooth stop, the values ease into it and out of it.
4668
+ *
4669
+ * @param offset - the offset on the path, where `0` is at the
4670
+ * beginning of the path and {@link Path#length} at the end
4671
+ *
4672
+ * @return the pen at the offset
4673
+ */
4674
+ getStrokeProfileAt(offset: number): StrokeProfileStop
4675
+
4187
4676
  /**
4188
4677
  * Adds one or more segments to the end of the {@link #segments} array of
4189
4678
  * this path.
@@ -4264,7 +4753,9 @@ declare namespace paper {
4264
4753
  removeSegments(from: number, to?: number): Segment[]
4265
4754
 
4266
4755
  /**
4267
- * Checks if any of the curves in the path have curve handles set.
4756
+ * Checks if any of the curves in the path have curve handles set. Handles
4757
+ * of which both coordinates are 0 within a tolerance of 1e-12 count as not
4758
+ * set, see {@link Point#isZero}.
4268
4759
  *
4269
4760
  * @see Segment#hasHandles()
4270
4761
  * @see Curve#hasHandles()
@@ -4830,6 +5321,82 @@ declare namespace paper {
4830
5321
  */
4831
5322
  reorient(nonZero?: boolean, clockwise?: boolean): PathItem
4832
5323
 
5324
+ /**
5325
+ * Offsets the path item by the given distance and returns the result
5326
+ * as a new path item. Closed paths and compound paths grow by positive
5327
+ * distances and shrink by negative ones, open paths are offset along
5328
+ * their normals for positive distances, and against them for negative
5329
+ * ones. As with the boolean operations, the path item's matrix is
5330
+ * applied first.
5331
+ *
5332
+ * @option [options.join='miter'] {String} the shape of the corners
5333
+ * that the offset adds where the path turns away from it:
5334
+ * {@values 'miter', 'round', 'bevel'}
5335
+ * @option [options.miterLimit=10] {Number} the limit of miter corners,
5336
+ * see {@link Style#miterLimit}
5337
+ * @option [options.insert=true] {Boolean} whether the resulting item
5338
+ * should be inserted back into the scene graph, above this path
5339
+ *
5340
+ * @param distance - the distance to offset the path item by
5341
+ * @param options - the offset options
5342
+ *
5343
+ * @return the resulting path item
5344
+ */
5345
+ offset(distance: number, options?: { join?: string, miterLimit?: number, insert?: boolean }): PathItem
5346
+
5347
+ /**
5348
+ * Outlines the stroke of the path item, and returns the area that it
5349
+ * covers as a new path item, filled with the stroke's color. As with
5350
+ * the boolean operations, the path item's matrix is applied first.
5351
+ * Dashed strokes are outlined as their dashes, each with the stroke's
5352
+ * caps, as the canvas draws them, see {@link #dash}.
5353
+ *
5354
+ * Paths with a {@link Path#strokeProfile} are outlined as the area
5355
+ * that its pens sweep. Their round joins and caps are the pens
5356
+ * themselves, and their other joins and caps connect the points where
5357
+ * the pens touch the sides of the stroke. Steps in the profile end
5358
+ * the parts of the stroke straight across, as butt caps do.
5359
+ *
5360
+ * @option [options.width=this.strokeWidth] {Number} the width of the
5361
+ * stroke
5362
+ * @option [options.join=this.strokeJoin] {String} the shape of the
5363
+ * stroke's corners: {@values 'miter', 'round', 'bevel'}
5364
+ * @option [options.cap=this.strokeCap] {String} the shape of the
5365
+ * stroke's ends: {@values 'round', 'square', 'butt'}
5366
+ * @option [options.miterLimit=this.miterLimit] {Number} the limit of
5367
+ * miter corners, see {@link Style#miterLimit}
5368
+ * @option [options.insert=true] {Boolean} whether the resulting item
5369
+ * should be inserted back into the scene graph, above this path
5370
+ *
5371
+ * @param options - the outline options
5372
+ *
5373
+ * @return the resulting path item
5374
+ */
5375
+ outline(options?: { width?: number, join?: string, cap?: string, miterLimit?: number, insert?: boolean }): PathItem
5376
+
5377
+ /**
5378
+ * Cuts the stroke of the path item into its dashes, as the canvas draws
5379
+ * them with the {@link Style#dashArray} and {@link Style#dashOffset}
5380
+ * of the path item or those of the options, and returns them as a new
5381
+ * group of open paths with the path item's style, without its dash
5382
+ * pattern. The pattern starts over on each path of a compound path,
5383
+ * and the dashes keep the parts of the paths' stroke profiles. As with
5384
+ * the boolean operations, the path item's matrix is applied first.
5385
+ *
5386
+ * @option [options.dashArray=this.dashArray] {Number[]} the lengths of
5387
+ * the dashes and the gaps between them
5388
+ * @option [options.dashOffset=this.dashOffset] {Number} the offset
5389
+ * into the pattern at which the dashes start
5390
+ * @option [options.insert=true] {Boolean} whether the resulting group
5391
+ * should be inserted back into the scene graph, above this path
5392
+ * item
5393
+ *
5394
+ * @param options - the dash options
5395
+ *
5396
+ * @return the dashes, as a new group of paths
5397
+ */
5398
+ dash(options?: { dashArray?: number[], dashOffset?: number, insert?: boolean }): Group
5399
+
4833
5400
  /**
4834
5401
  * Creates a path item from the given SVG path-data, determining if the
4835
5402
  * data describes a plain path or a compound-path with multiple
@@ -5033,13 +5600,29 @@ declare namespace paper {
5033
5600
  * This method can be used to process and simplify the point data received
5034
5601
  * from a mouse or touch device.
5035
5602
  *
5036
- * @param tolerance - the allowed maximum error when fitting
5037
- * the curves through the segment points
5603
+ * With `options.from` and `options.to`, only the segments in that range
5604
+ * are replaced. The fitted curves join the curves outside of the range
5605
+ * tangentially where these have handles.
5606
+ *
5607
+ * @option [options.tolerance=2.5] {Number} the allowed maximum error when
5608
+ * fitting the curves through the segment points
5609
+ * @option options.from {Number|Segment|Curve} the segment or curve at which
5610
+ * to start simplifying, if not the full path shall be simplified
5611
+ * (inclusive). This can either be a segment index, or a segment or
5612
+ * curve object that is part of the path. If the passed number is
5613
+ * negative, the index is wrapped around the end of the path.
5614
+ * @option options.to {Number|Segment|Curve} the segment or curve up to
5615
+ * which to simplify (inclusive). This can either be a segment index,
5616
+ * or a segment or curve object that is part of the path. If the passed
5617
+ * number is negative, the index is wrapped around the end of the path.
5618
+ *
5619
+ * @param options - the simplification options, or the
5620
+ * tolerance as a number
5038
5621
  *
5039
5622
  * @return true if the method was capable of fitting curves
5040
5623
  * through the path's segment points
5041
5624
  */
5042
- simplify(tolerance?: number): boolean
5625
+ simplify(options?: object | number): boolean
5043
5626
 
5044
5627
  /**
5045
5628
  * Interpolates between the two specified path items and uses the result
@@ -5124,6 +5707,35 @@ declare namespace paper {
5124
5707
  */
5125
5708
  arcTo(to: PointLike, clockwise?: boolean): void
5126
5709
 
5710
+ /**
5711
+ * Adds an arc that sweeps the specified angle around the specified
5712
+ * `center` point, from the position of the last segment in the path, by
5713
+ * adding one or more segments to the path. Positive angles draw the arc in
5714
+ * clockwise direction, negative ones in anticlockwise direction.
5715
+ *
5716
+ * @param center - the center of the arc
5717
+ * @param angle - the angle in degrees that the arc sweeps over
5718
+ */
5719
+ arcAround(center: PointLike, angle: number): void
5720
+
5721
+ /**
5722
+ * Adds an arc from the position of the last segment in the path to the
5723
+ * specified point, by adding one or more segments to the path. The arc
5724
+ * continues in the direction in which the path ends, without a corner.
5725
+ *
5726
+ * @param to - the point where the arc should end
5727
+ */
5728
+ arcTowards(to: PointLike): void
5729
+
5730
+ /**
5731
+ * Adds an arc from the position of the last segment in the path to the
5732
+ * specified point, by adding one or more segments to the path. The arc
5733
+ * continues in the direction in which the path ends, without a corner.
5734
+ *
5735
+ * @param to - the point where the arc should end
5736
+ */
5737
+ arcTowards(x: number, y: number): void
5738
+
5127
5739
  /**
5128
5740
  * Adds a curve from the last segment in the path through the specified
5129
5741
  * `through` point, to the specified destination point by adding one segment
@@ -5280,7 +5892,10 @@ declare namespace paper {
5280
5892
  * {@link #textPath}, each letter turned to the path's direction where it
5281
5893
  * sits. On a compound path, the text runs along one of its paths after the
5282
5894
  * other. What doesn't fit between {@link #startOffset} and
5283
- * {@link #endOffset} flows on into the next linked text item.
5895
+ * {@link #endOffset} flows on into the next linked text item. When its
5896
+ * first paragraph runs right to left, its letters follow each other
5897
+ * backwards along the path. Each letter is drawn on its own, so scripts
5898
+ * that join their letters, as Arabic, lose their joined forms.
5284
5899
  */
5285
5900
  class PathText extends TextItem {
5286
5901
  /**
@@ -5323,6 +5938,71 @@ declare namespace paper {
5323
5938
 
5324
5939
  }
5325
5940
 
5941
+ /**
5942
+ * A pattern definition repeats an item as the tile of pattern colors,
5943
+ * which fill and stroke items with it, see {@link Color#pattern}: a
5944
+ * {@link Raster} for image patterns, or any other item for vector patterns. As
5945
+ * with symbol definitions, the item is removed from the scene graph, and all
5946
+ * pattern colors that use the pattern share it, so they change along with it.
5947
+ */
5948
+ class PatternDefinition {
5949
+ /**
5950
+ * The project that this pattern belongs to.
5951
+ */
5952
+ readonly project: Project
5953
+
5954
+ /**
5955
+ * The name of the pattern.
5956
+ */
5957
+ name: string
5958
+
5959
+ /**
5960
+ * The item that the pattern repeats. Unlike the items of symbols, it isn't
5961
+ * moved to 0, 0, so the tiles are at its own coordinates.
5962
+ */
5963
+ item: Item
5964
+
5965
+ /**
5966
+ * The rectangle that is repeated, in the coordinates of the pattern's
5967
+ * item.
5968
+ */
5969
+ get tile(): Rectangle
5970
+ set tile(value: RectangleLike)
5971
+
5972
+ /**
5973
+ * The gap between the tiles, horizontally and vertically.
5974
+ */
5975
+ get spacing(): Size
5976
+ set spacing(value: SizeLike)
5977
+
5978
+
5979
+ /**
5980
+ * Creates a pattern definition.
5981
+ *
5982
+ * @option [options.tile] {Rectangle} the rectangle that is repeated,
5983
+ * the bounds of the item by default
5984
+ * @option [options.spacing=0] {Size} the gap between the tiles
5985
+ * @option [options.name] {String} the name of the pattern
5986
+ *
5987
+ * @param item - the item to repeat, which is removed from the scene
5988
+ * graph and becomes the pattern's tile content
5989
+ */
5990
+ constructor(item: Item, options?: { tile?: RectangleLike, spacing?: SizeLike, name?: string })
5991
+
5992
+ /**
5993
+ * Returns a copy of the pattern, with a copy of its item and its name.
5994
+ */
5995
+ clone(): PatternDefinition
5996
+
5997
+ /**
5998
+ * Checks whether the pattern is equal to the supplied pattern.
5999
+ *
6000
+ * @return true if they are equal
6001
+ */
6002
+ equals(pattern: PatternDefinition): boolean
6003
+
6004
+ }
6005
+
5326
6006
  /**
5327
6007
  * The Point object represents a point in the two dimensional space
5328
6008
  * of the Paper.js project. It is also used to represent two dimensional
@@ -5342,6 +6022,12 @@ declare namespace paper {
5342
6022
  */
5343
6023
  y: number
5344
6024
 
6025
+ /**
6026
+ * The point's coordinates as an array, `[x, y]`, as
6027
+ * {@link Matrix#values} gives those of a matrix.
6028
+ */
6029
+ readonly values: number[]
6030
+
5345
6031
  /**
5346
6032
  * The length of the vector that is represented by this point's coordinates.
5347
6033
  * Each point can be interpreted as a vector that points from the origin (`x
@@ -5732,7 +6418,8 @@ declare namespace paper {
5732
6418
 
5733
6419
  /**
5734
6420
  * Checks if the vector represented by this point is collinear (parallel) to
5735
- * another vector.
6421
+ * another vector, within a tolerance of 1e-8 for the sine of the angle
6422
+ * between them.
5736
6423
  *
5737
6424
  * @param point - the vector to check against
5738
6425
  *
@@ -5742,7 +6429,8 @@ declare namespace paper {
5742
6429
 
5743
6430
  /**
5744
6431
  * Checks if the vector represented by this point is collinear (parallel) to
5745
- * another vector.
6432
+ * another vector, within a tolerance of 1e-8 for the sine of the angle
6433
+ * between them.
5746
6434
  *
5747
6435
  * @param point - the vector to check against
5748
6436
  *
@@ -5752,7 +6440,8 @@ declare namespace paper {
5752
6440
 
5753
6441
  /**
5754
6442
  * Checks if the vector represented by this point is orthogonal
5755
- * (perpendicular) to another vector.
6443
+ * (perpendicular) to another vector, within a tolerance of 1e-8 for the
6444
+ * cosine of the angle between them.
5756
6445
  *
5757
6446
  * @param point - the vector to check against
5758
6447
  *
@@ -5762,7 +6451,8 @@ declare namespace paper {
5762
6451
 
5763
6452
  /**
5764
6453
  * Checks if the vector represented by this point is orthogonal
5765
- * (perpendicular) to another vector.
6454
+ * (perpendicular) to another vector, within a tolerance of 1e-8 for the
6455
+ * cosine of the angle between them.
5766
6456
  *
5767
6457
  * @param point - the vector to check against
5768
6458
  *
@@ -5771,9 +6461,11 @@ declare namespace paper {
5771
6461
  isOrthogonal(x: number, y: number): boolean
5772
6462
 
5773
6463
  /**
5774
- * Checks if this point has both the x and y coordinate set to 0.
6464
+ * Checks if this point has both the x and y coordinate set to 0, within
6465
+ * a tolerance of 1e-12, unlike {@link #equals}, which compares
6466
+ * exactly.
5775
6467
  *
5776
- * @return true if both x and y are 0
6468
+ * @return true if both x and y are 0, within the tolerance
5777
6469
  */
5778
6470
  isZero(): boolean
5779
6471
 
@@ -5956,24 +6648,44 @@ declare namespace paper {
5956
6648
  * {@link PaperScope#projects} variable.
5957
6649
  */
5958
6650
  class Project {
6651
+ /**
6652
+ * The style new text items take in a hosted project, in place of
6653
+ * {@link #currentStyle}, when the host sets one: for hosts whose new
6654
+ * text has defaults of its own, such as a black fill without a stroke
6655
+ * whatever new paths take. Paths keep taking the current style.
6656
+ */
6657
+ currentTextStyle: Style
6658
+
5959
6659
  /**
5960
6660
  * The host document that the project's items come from. Setting it
5961
6661
  * creates the project's layers from the host's records. All items
5962
6662
  * are created as shells that load their content and children from the
5963
- * host on first access.
6663
+ * host on first access. The host draws its items, so setting it also
6664
+ * turns off {@link View#autoUpdate}, which would draw them all and
6665
+ * load them in full.
5964
6666
  *
5965
6667
  * The host provides:
5966
6668
  * - `getChildren(key)`, which returns the records of the children of
5967
6669
  * the node with the given key, or of the top level for `null`, as
5968
6670
  * columns: `keys`, `types` (indices into `typeNames`), `typeNames`,
5969
6671
  * `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`.
6672
+ * clipMask: 64, guide: 128, empty: 256), optionally `boxes`
6673
+ * (bounds, strokeBounds and roughBounds in the item's coordinates, 12
6674
+ * numbers per item), and the sparse objects `names` and `matrices`.
6675
+ * - `getBounds(key)`, for hosts that don't send `boxes`, which returns
6676
+ * the node's 12 numbers, or `null` for an empty node. Items ask for
6677
+ * them when their bounds are needed, and again after the host sent
6678
+ * their record again.
5973
6679
  * - `getItem(key)`, which returns the node's own content in the form
5974
6680
  * of {@link Item#importJSON}, without children. Linked text
5975
6681
  * gives `linked`, the keys of its story's text items in order, and
5976
- * leaves out its story.
6682
+ * leaves out its story. Rasters give their `size` without a `source`
6683
+ * and `crossOrigin`.
6684
+ * - `getImage(key)`, for rasters, which returns the node's pixels as a
6685
+ * canvas with a 2D context, of the size that `getItem()` gives.
6686
+ * Rasters load them on first access to their pixels, and Paper.js
6687
+ * never loads them by itself, except to draw them. Rasters whose
6688
+ * pixels the host fails to give draw nothing.
5977
6689
  * - `getStory(key)`, for linked text, which returns its story with the
5978
6690
  * key of any of its text items: `content` or `runs`, `paragraphs`,
5979
6691
  * and the character and paragraph styles, as
@@ -5995,6 +6707,53 @@ declare namespace paper {
5995
6707
  * `content`, as for a hyphen, all in the item's coordinates. `key`
5996
6708
  * is null for text that the host doesn't know yet. Without it,
5997
6709
  * Paper.js lays out text itself.
6710
+ * - `getDefinition(key)`, for the pattern and symbol definitions that
6711
+ * the host shares between its items, which the JSON of its items
6712
+ * refers to as `['@key']`, as in `fillColor: ['pattern',
6713
+ * ['@pattern/Dots'], matrix]` or `definition: ['@symbol/Star']`.
6714
+ * It returns the definition in the form of
6715
+ * {@link Item#exportJSON}, with its whole item:
6716
+ * `['PatternDefinition', item, { tile, spacing }]` or
6717
+ * `['SymbolDefinition', item]`, always: for a key that it has no
6718
+ * definition of, an empty one of the type, as
6719
+ * `['SymbolDefinition', ['Group', {}]]`. Each definition loads
6720
+ * once, and the JSON of the items that use it, as
6721
+ * {@link Item#exportJSON} writes it, refers to it by its
6722
+ * key again. Definitions that scripts create have no key, and are
6723
+ * written out whole, until the host sets their `key`, which it can
6724
+ * only set once. {@link Project#takeChanges} lists those that the
6725
+ * changed items use first, nested ones first, as
6726
+ * `{ definition, flags }` with the `ChangeFlag.INSERTION` flag,
6727
+ * followed by the changes of the host's definitions. Renaming those
6728
+ * isn't supported.
6729
+ * - `getDefinitionKeys(type)`, which returns the keys of all the
6730
+ * host's definitions of the type, `'SymbolDefinition'` or
6731
+ * `'PatternDefinition'`, for {@link #symbolDefinitions} and
6732
+ * {@link #patternDefinitions}.
6733
+ *
6734
+ * Items that move into a project with another host load in full from
6735
+ * their own host first, and drop their keys, so they are new items
6736
+ * there. They bring copies without keys of the symbol and pattern
6737
+ * definitions of their host along, shared by the items of one
6738
+ * insertion or copy, so the new host takes them as new ones too.
6739
+ * Linked text brings a copy of its story along, which flows on through
6740
+ * the items that stay. Host items can't enter the project of another
6741
+ * host.
6742
+ *
6743
+ * The host draws the items, and the selection. To show what scripts
6744
+ * draw in {@link Item#onDraw} and {@link Item#onDrawSelection}, it
6745
+ * calls `project.draw(ctx, matrix, pixelRatio)`, which in a hosted
6746
+ * project only calls these handlers, with the context, the view's
6747
+ * matrix and pixel ratio that the host gives, for the visible items
6748
+ * that have them, and for the selected ones. Handlers of classes,
6749
+ * such as `Path.onDraw`, load all items once. The host asks
6750
+ * {@link #hasDrawHandlers} whether it needs to call it.
6751
+ *
6752
+ * {@link Project#takeChanges} marks the changes of the items whose
6753
+ * children changed in order other than by new items inserted and
6754
+ * items removed, which the other changes don't tell, with
6755
+ * `reordered: true`: the host reads their children whole, and can
6756
+ * place the others' new items by their indices.
5998
6757
  */
5999
6758
  host: any
6000
6759
 
@@ -6005,6 +6764,37 @@ declare namespace paper {
6005
6764
  */
6006
6765
  trackChanges: boolean
6007
6766
 
6767
+ /**
6768
+ * The function to be called when the project is activated through
6769
+ * {@link #activate}. The function receives the previously active
6770
+ * project, which is the project itself when it was already active.
6771
+ */
6772
+ onActivate: Function | null
6773
+
6774
+ /**
6775
+ * The function to be called when another project is activated through
6776
+ * {@link #activate} while this one is active, or when this one is
6777
+ * removed while active.
6778
+ */
6779
+ onDeactivate: Function | null
6780
+
6781
+ /**
6782
+ * The function to be called when any project is activated, as
6783
+ * {@link #onActivate} is for a single project, including the projects
6784
+ * that activate themselves when they are created, with `this` set to the
6785
+ * project. `Project.on('activate', handler)` and
6786
+ * `Project.off('activate', handler)` attach and detach them too. Classes
6787
+ * are shared by all {@link PaperScope} objects, and so are their handlers.
6788
+ */
6789
+ static onActivate: Function | null
6790
+
6791
+ /**
6792
+ * The function to be called when any project is deactivated, as
6793
+ * {@link #onDeactivate} is for a single project, see
6794
+ * {@link Project.onActivate}.
6795
+ */
6796
+ static onDeactivate: Function | null
6797
+
6008
6798
  /**
6009
6799
  * The scope that this project belongs to.
6010
6800
  */
@@ -6055,6 +6845,12 @@ declare namespace paper {
6055
6845
  */
6056
6846
  readonly symbols: SymbolDefinition[]
6057
6847
 
6848
+ /**
6849
+ * The pattern definitions that the fill and stroke colors of the items in
6850
+ * the project use.
6851
+ */
6852
+ readonly patternDefinitions: PatternDefinition[]
6853
+
6058
6854
  /**
6059
6855
  * The selected items contained within the project.
6060
6856
  */
@@ -6085,13 +6881,29 @@ declare namespace paper {
6085
6881
  */
6086
6882
  getItemByKey(key: number): Item
6087
6883
 
6884
+ /**
6885
+ * Checks whether any item of the project or class has draw handlers,
6886
+ * {@link Item#onDraw} or, for the selected items,
6887
+ * {@link Item#onDrawSelection}, for hosts that draw the items
6888
+ * themselves, see {@link #host}.
6889
+ *
6890
+ * @return true if drawing the project calls any handlers
6891
+ */
6892
+ hasDrawHandlers(): boolean
6893
+
6088
6894
  /**
6089
6895
  * Updates the items of changed host nodes, given in the column format
6090
6896
  * of the host's `getChildren()`, with two more flags: 16 when the
6091
6897
  * node's own content changed, so the item loads it again on next
6092
6898
  * access, and 32 when its list of children changed, so it loads them
6093
6899
  * again right away if it had loaded them, keeping the items of nodes
6094
- * that remain. Nodes without items are skipped.
6900
+ * that remain. Nodes without items are skipped. `definitions` lists
6901
+ * the keys of changed definitions of the host's `getDefinition()`,
6902
+ * which load again right away into the same objects, so the colors
6903
+ * and symbol items that use them change along. A definition that the
6904
+ * host no longer has, for which `getDefinition()` may return `null`
6905
+ * here, is emptied and draws nothing. The columns may hold only
6906
+ * definitions.
6095
6907
  *
6096
6908
  * @param columns - the records of the changed nodes
6097
6909
  */
@@ -6101,10 +6913,14 @@ declare namespace paper {
6101
6913
  * Returns the changes logged since tracking was activated or since the
6102
6914
  * last call, and clears the log. Each item is listed once, with the
6103
6915
  * {@link ChangeFlag} values of all its changes combined. Removed items are
6104
- * listed with the `ChangeFlag.INSERTION` flag.
6916
+ * listed with the `ChangeFlag.INSERTION` flag, and items that moved to
6917
+ * another project are left out, as that one lists them. Symbol and pattern
6918
+ * definitions whose item, tile, spacing or name changed are listed too,
6919
+ * as `{ definition, flags }`.
6105
6920
  *
6106
- * @return the changes as `{ item, flags }` objects, or `null`
6107
- * if {link #trackChanges} is off
6921
+ * @return the changes as `{ item, flags }` and
6922
+ * `{ definition, flags }` objects, or `null` if {link #trackChanges}
6923
+ * is off
6108
6924
  */
6109
6925
  takeChanges(): object[]
6110
6926
 
@@ -6346,13 +7162,19 @@ declare namespace paper {
6346
7162
  * @option [options.reduceAttributes=true] {Boolean} wether to only include
6347
7163
  * style attributes in the SVG output that differ from their parents,
6348
7164
  * or to always include them (much faster but leading to redundancies).
7165
+ * @option [options.processNode] {Function} the function to process the
7166
+ * SVG node made for each exported item, receiving an object with the
7167
+ * `item` and its `node`: It can change the node, e.g. to add attributes
7168
+ * that Paper.js doesn't export, or return a node to replace it with. It
7169
+ * is called before the item's name, style, visibility and data are set
7170
+ * on the node, which replace attributes of the same names.
6349
7171
  *
6350
7172
  * @param options - the export options
6351
7173
  *
6352
7174
  * @return the project converted to an SVG node or a
6353
7175
  * `String` depending on `option.asString` value
6354
7176
  */
6355
- exportSVG(options?: { bounds?: string | RectangleLike, matrix?: Matrix, asString?: boolean, precision?: number, matchShapes?: boolean, embedImages?: boolean, reuseImages?: boolean, idPrefix?: string, reduceAttributes?: boolean }): SVGElement | string
7177
+ exportSVG(options?: { bounds?: string | RectangleLike, matrix?: Matrix, asString?: boolean, precision?: number, matchShapes?: boolean, embedImages?: boolean, reuseImages?: boolean, idPrefix?: string, reduceAttributes?: boolean, processNode?: Function }): SVGElement | string
6356
7178
 
6357
7179
  /**
6358
7180
  * Converts the provided SVG content into Paper.js items and adds them to
@@ -6364,6 +7186,11 @@ declare namespace paper {
6364
7186
  * the `<use>` elements that place them as {@link SymbolItem} items. The
6365
7187
  * styles that `<use>` elements inherit don't reach the symbols' content.
6366
7188
  *
7189
+ * The layers in SVG content that Paper.js exported come back as
7190
+ * {@link Layer} items inside the imported group. To make the layers of a
7191
+ * project's SVG the layers of a project again, add them to it with
7192
+ * `item.children.slice().forEach(project.addLayer, project)`.
7193
+ *
6367
7194
  * URLs are fetched as they are, so validate URLs that come from untrusted
6368
7195
  * sources first, especially on servers, where they could reach internal
6369
7196
  * addresses.
@@ -6385,6 +7212,13 @@ declare namespace paper {
6385
7212
  * @option [options.applyMatrix={@link PaperScope#settings}.applyMatrix]
6386
7213
  * {Boolean} whether the imported items should have their transformation
6387
7214
  * matrices applied to their contents or not
7215
+ * @option [options.processItem] {Function} the function to process the
7216
+ * item made for each imported SVG element, receiving an object with
7217
+ * the `item` and its `node`: It can read attributes that Paper.js
7218
+ * doesn't import, or return an item to replace it with. It is called
7219
+ * after the element's attributes and data are applied to the item, so
7220
+ * it can extend `item.data`. A replacement item doesn't receive them:
7221
+ * copy them over from `item` as needed.
6388
7222
  *
6389
7223
  * @param svg - the SVG content to import, either as a SVG
6390
7224
  * DOM node, a string containing SVG content, or a string describing the
@@ -6394,7 +7228,7 @@ declare namespace paper {
6394
7228
  * @return the newly created Paper.js item containing the converted
6395
7229
  * SVG content
6396
7230
  */
6397
- importSVG(svg: SVGElement | string, options?: { expandShapes?: boolean, crossOrigin?: string, onLoad?: Function, onError?: Function, insert?: boolean, applyMatrix?: boolean }): Item
7231
+ importSVG(svg: SVGElement | string, options?: { expandShapes?: boolean, crossOrigin?: string, onLoad?: Function, onError?: Function, insert?: boolean, applyMatrix?: boolean, processItem?: Function }): Item
6398
7232
 
6399
7233
  /**
6400
7234
  * Imports the provided external SVG file, converts it into Paper.js items
@@ -6709,6 +7543,13 @@ declare namespace paper {
6709
7543
  */
6710
7544
  height: number
6711
7545
 
7546
+ /**
7547
+ * The rectangle's position and size as an array,
7548
+ * `[x, y, width, height]`, as {@link Matrix#values} gives those of a
7549
+ * matrix.
7550
+ */
7551
+ readonly values: number[]
7552
+
6712
7553
  /**
6713
7554
  * The top-left point of the rectangle. Setting it moves the whole
6714
7555
  * rectangle, unlike {@link #topLeft}.
@@ -7027,20 +7868,26 @@ declare namespace paper {
7027
7868
  expand(hor: number, ver: number): Rectangle
7028
7869
 
7029
7870
  /**
7030
- * Returns a new rectangle scaled by the specified amount from its center.
7871
+ * Returns a new rectangle scaled by the specified factor from its center,
7872
+ * or from the given center point.
7873
+ *
7874
+ * @param scale - the scale factor
7031
7875
  *
7032
7876
  * @return the scaled rectangle
7033
7877
  */
7034
- scale(amount: number): Rectangle
7878
+ scale(scale: number, center?: PointLike): Rectangle
7035
7879
 
7036
7880
  /**
7037
7881
  * Returns a new rectangle scaled in horizontal direction by the specified
7038
- * `hor` amount and in vertical direction by the specified `ver` amount
7039
- * from its center.
7882
+ * `hor` factor and in vertical direction by the specified `ver` factor
7883
+ * from its center, or from the given center point.
7884
+ *
7885
+ * @param hor - the horizontal scale factor
7886
+ * @param ver - the vertical scale factor
7040
7887
  *
7041
7888
  * @return the scaled rectangle
7042
7889
  */
7043
- scale(hor: number, ver: number): Rectangle
7890
+ scale(hor: number, ver: number, center?: PointLike): Rectangle
7044
7891
 
7045
7892
  }
7046
7893
 
@@ -7055,6 +7902,27 @@ declare namespace paper {
7055
7902
  * objects that are connected by this segment.
7056
7903
  */
7057
7904
  class Segment {
7905
+ /**
7906
+ * The name of the segment. If the segment has a name, it can be accessed
7907
+ * by name through its path's segments list. If several segments share a
7908
+ * name, the first one is found.
7909
+ *
7910
+ * The name is stored in JSON, and in SVG in the `data-paper-segments`
7911
+ * attribute of the path, see {@link Segment#data}.
7912
+ */
7913
+ name: string | null
7914
+
7915
+ /**
7916
+ * A plain javascript object which can be used to store arbitrary data on
7917
+ * the segment.
7918
+ *
7919
+ * The data is stored in JSON, and in SVG in the `data-paper-segments`
7920
+ * attribute of the path, keyed by the index of the segment. Paper.js drops
7921
+ * it on import if the indices don't fit the path anymore, as happens when
7922
+ * another editor removes segments.
7923
+ */
7924
+ data: any
7925
+
7058
7926
  /**
7059
7927
  * The anchor point of the segment.
7060
7928
  */
@@ -7139,7 +8007,9 @@ declare namespace paper {
7139
8007
  constructor(object: object)
7140
8008
 
7141
8009
  /**
7142
- * Checks if the segment has any curve handles set.
8010
+ * Checks if the segment has any curve handles set. Handles of which both
8011
+ * coordinates are 0 within a tolerance of 1e-12 count as not set, see
8012
+ * {@link Point#isZero}.
7143
8013
  *
7144
8014
  * @see Segment#handleIn
7145
8015
  * @see Segment#handleOut
@@ -7413,6 +8283,12 @@ declare namespace paper {
7413
8283
  */
7414
8284
  height: number
7415
8285
 
8286
+ /**
8287
+ * The size's dimensions as an array, `[width, height]`, as
8288
+ * {@link Matrix#values} gives those of a matrix.
8289
+ */
8290
+ readonly values: number[]
8291
+
7416
8292
 
7417
8293
  /**
7418
8294
  * Creates a Size object with the given width and height values.
@@ -7627,9 +8503,12 @@ declare namespace paper {
7627
8503
  negate(): Size
7628
8504
 
7629
8505
  /**
7630
- * Checks if this size has both the width and height set to 0.
8506
+ * Checks if this size has both the width and height set to 0, within a
8507
+ * tolerance of 1e-12, unlike {@link #equals}, which compares
8508
+ * exactly.
7631
8509
  *
7632
- * @return true if both width and height are 0
8510
+ * @return true if both width and height are 0, within the
8511
+ * tolerance
7633
8512
  */
7634
8513
  isZero(): boolean
7635
8514
 
@@ -7693,6 +8572,85 @@ declare namespace paper {
7693
8572
 
7694
8573
  }
7695
8574
 
8575
+ /**
8576
+ * A stop of the stroke profile of a path, see
8577
+ * {@link Path#strokeProfile}: the pen that draws its stroke at an offset along
8578
+ * the path, an ellipse with a width, an aspect and an angle. Between the
8579
+ * stops, each of them changes along the path, easing into and out of smooth
8580
+ * stops and in straight lines from the others, see {@link #smooth}. A stop can set
8581
+ * only some of them, and leave the others to the stops around it.
8582
+ */
8583
+ class StrokeProfileStop {
8584
+ /**
8585
+ * The path whose stroke profile the stop is part of.
8586
+ */
8587
+ readonly path: Path | null
8588
+
8589
+ /**
8590
+ * The offset of the stop along its path, as in
8591
+ * {@link Path#getPointAt}. Unlike the offset of gradient stops, it
8592
+ * is a length, not a fraction. The stop stays between the same segments
8593
+ * when they move, so its offset changes with the lengths of the curves
8594
+ * before it.
8595
+ */
8596
+ offset: number
8597
+
8598
+ /**
8599
+ * The width of the pen at the stop, as a factor of the path's
8600
+ * {@link Style#strokeWidth}: `1` for the stroke width, `2` for twice
8601
+ * as wide. Stops without a width leave it to the stops around them, and
8602
+ * without any, it is `1`.
8603
+ */
8604
+ width: number | null
8605
+
8606
+ /**
8607
+ * The aspect of the pen at the stop: its height as a factor of its width,
8608
+ * `1` for a round pen, less for a flat nib. Stops without an aspect leave
8609
+ * it to the stops around them, and without any, it is `1`.
8610
+ */
8611
+ aspect: number | null
8612
+
8613
+ /**
8614
+ * The angle of the pen at the stop, in degrees, in the path's coordinates.
8615
+ * Angles aren't wrapped: from `0` at one stop to `720` at the next, the
8616
+ * pen turns twice. Stops without an angle leave it to the stops around
8617
+ * them, and without any, it is `0`.
8618
+ */
8619
+ angle: number | null
8620
+
8621
+ /**
8622
+ * Whether the values ease into and out of the stop: they arrive at it and
8623
+ * leave it flat, and between two smooth stops, a value follows a cubic
8624
+ * from one to the other, without overshooting them. As the slopes don't
8625
+ * depend on other stops, changing a stop only changes the values up to the
8626
+ * stops on either side of it. Without smoothing, the values change in
8627
+ * straight lines to the stops on either side.
8628
+ */
8629
+ smooth: boolean
8630
+
8631
+
8632
+ /**
8633
+ * Creates a stroke profile stop.
8634
+ *
8635
+ * @param object - the properties of the stop, its `offset`,
8636
+ * `width`, `aspect`, `angle` and `smooth`
8637
+ */
8638
+ constructor(object?: object)
8639
+
8640
+ /**
8641
+ * @return a copy of the stop, without a path
8642
+ */
8643
+ clone(): StrokeProfileStop
8644
+
8645
+ /**
8646
+ * Checks whether the stop is equal to the supplied one.
8647
+ *
8648
+ * @return true if they are equal
8649
+ */
8650
+ equals(stop: StrokeProfileStop): boolean
8651
+
8652
+ }
8653
+
7696
8654
  /**
7697
8655
  * Style is used for changing the visual styles of items
7698
8656
  * contained within a Paper.js project and is returned by
@@ -7773,6 +8731,14 @@ declare namespace paper {
7773
8731
  */
7774
8732
  miterLimit: number
7775
8733
 
8734
+ /**
8735
+ * The order in which the fill and the stroke are painted, as in SVG's
8736
+ * `paint-order`, named after what is painted first: `'fill'` paints the
8737
+ * fill first, `'stroke'` paints the stroke first, so the fill covers its
8738
+ * inner half.
8739
+ */
8740
+ paintOrder: string
8741
+
7776
8742
  /**
7777
8743
  * The fill color.
7778
8744
  */
@@ -7997,7 +8963,10 @@ declare namespace paper {
7997
8963
 
7998
8964
  /**
7999
8965
  * The direction the paragraph's lines run in, which `'start'` and `'end'`
8000
- * follow; `null` for left to right.
8966
+ * follow, and from which side their pieces are placed; `null` for left to
8967
+ * right. Lines that mix directions across styles aren't reordered by the
8968
+ * Unicode bidirectional algorithm: their pieces follow the paragraph's
8969
+ * direction, and canvas orders only the letters within each piece.
8001
8970
  */
8002
8971
  direction: string
8003
8972
 
@@ -8024,6 +8993,11 @@ declare namespace paper {
8024
8993
  */
8025
8994
  readonly project: Project
8026
8995
 
8996
+ /**
8997
+ * The name of the symbol.
8998
+ */
8999
+ name: string
9000
+
8027
9001
  /**
8028
9002
  * The item used as the symbol's definition.
8029
9003
  */
@@ -8051,7 +9025,7 @@ declare namespace paper {
8051
9025
  place(position?: PointLike): SymbolItem
8052
9026
 
8053
9027
  /**
8054
- * Returns a copy of the symbol.
9028
+ * Returns a copy of the symbol, with a copy of its item and its name.
8055
9029
  */
8056
9030
  clone(): SymbolDefinition
8057
9031
 
@@ -8091,6 +9065,17 @@ declare namespace paper {
8091
9065
  */
8092
9066
  constructor(definition: SymbolDefinition | Item, point?: PointLike)
8093
9067
 
9068
+ /**
9069
+ * Replaces the symbol item with a copy of its definition's item, which
9070
+ * keeps the symbol item's appearance: its matrix is applied to the copy,
9071
+ * its opacity, visibility, blend mode and other attributes are combined
9072
+ * with the copy's, and its name, data and selection are passed on.
9073
+ *
9074
+ * @return the copy of the definition's item, or `null` if the
9075
+ * symbol item has no parent
9076
+ */
9077
+ embed(): Item
9078
+
8094
9079
  }
8095
9080
 
8096
9081
  /**
@@ -8328,7 +9313,10 @@ declare namespace paper {
8328
9313
 
8329
9314
  /**
8330
9315
  * The direction the paragraph's lines run in, which `'start'` and `'end'`
8331
- * follow; `null` for left to right.
9316
+ * follow, and from which side their pieces are placed; `null` for left to
9317
+ * right. Lines that mix directions across styles aren't reordered by the
9318
+ * Unicode bidirectional algorithm: their pieces follow the paragraph's
9319
+ * direction, and canvas orders only the letters within each piece.
8332
9320
  */
8333
9321
  direction: string
8334
9322
 
@@ -8633,7 +9621,8 @@ declare namespace paper {
8633
9621
 
8634
9622
  /**
8635
9623
  * The function to be called when another tool is activated through
8636
- * {@link #activate}, while this one is active.
9624
+ * {@link #activate} while this one is active, or when this one is
9625
+ * removed while active.
8637
9626
  */
8638
9627
  onDeactivate: Function | null
8639
9628
 
@@ -9135,7 +10124,7 @@ declare namespace paper {
9135
10124
  *
9136
10125
  * @param force - whether to redraw the view even if nothing
9137
10126
  * has changed, e.g. after a web font used by text items has finished
9138
- * loading
10127
+ * loading, also in buffered groups, see {@link Group#buffered}
9139
10128
  *
9140
10129
  * @return true if the view was updated
9141
10130
  */