@pixerate/editor 0.125.0 → 0.127.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 (124) hide show
  1. package/dist/animation/index.d.cts +2 -3
  2. package/dist/animation/index.d.ts +2 -3
  3. package/dist/animation-editor/index.cjs +71 -73
  4. package/dist/animation-editor/index.cjs.map +1 -1
  5. package/dist/animation-editor/index.d.cts +6 -8
  6. package/dist/animation-editor/index.d.ts +6 -8
  7. package/dist/animation-editor/index.js +11 -13
  8. package/dist/animation-editor/index.js.map +1 -1
  9. package/dist/{bezier-CBzKKDjl.d.cts → bezier-DBz0IgEt.d.cts} +22 -2
  10. package/dist/{bezier-CWv6LQal.d.ts → bezier-DWI5MEkI.d.ts} +22 -2
  11. package/dist/{brushstrokeRender-LRV7GXGD.js → brushstrokeRender-7RUITO42.js} +3 -3
  12. package/dist/{brushstrokeRender-EELTV7U4.cjs → brushstrokeRender-OW6ENCZG.cjs} +7 -7
  13. package/dist/{brushstrokeRender-EELTV7U4.cjs.map → brushstrokeRender-OW6ENCZG.cjs.map} +1 -1
  14. package/dist/canvas/index.cjs +423 -37
  15. package/dist/canvas/index.cjs.map +1 -1
  16. package/dist/canvas/index.d.cts +189 -11
  17. package/dist/canvas/index.d.ts +189 -11
  18. package/dist/canvas/index.js +395 -9
  19. package/dist/canvas/index.js.map +1 -1
  20. package/dist/{chunk-7LQO6OHH.cjs → chunk-33SO3QWP.cjs} +4 -4
  21. package/dist/{chunk-7LQO6OHH.cjs.map → chunk-33SO3QWP.cjs.map} +1 -1
  22. package/dist/{chunk-MPQAO33O.js → chunk-A6KHMKI4.js} +3 -3
  23. package/dist/{chunk-V5YGPRCZ.cjs → chunk-BEGEWQHD.cjs} +41 -41
  24. package/dist/{chunk-V5YGPRCZ.cjs.map → chunk-BEGEWQHD.cjs.map} +1 -1
  25. package/dist/{chunk-N3FVUOZD.cjs → chunk-BJTCSLF6.cjs} +7 -7
  26. package/dist/{chunk-N3FVUOZD.cjs.map → chunk-BJTCSLF6.cjs.map} +1 -1
  27. package/dist/{chunk-WUDPFWAN.js → chunk-F7Q2NE2Y.js} +3 -3
  28. package/dist/{chunk-G6WXWS4Y.js → chunk-FICSDDDF.js} +2 -2
  29. package/dist/{chunk-GUZ47CJM.cjs → chunk-IZ4WRXZA.cjs} +1 -1
  30. package/dist/{chunk-GUZ47CJM.cjs.map → chunk-IZ4WRXZA.cjs.map} +1 -1
  31. package/dist/{chunk-QDJKUBWE.cjs → chunk-JODTP4DP.cjs} +176 -5
  32. package/dist/chunk-JODTP4DP.cjs.map +1 -0
  33. package/dist/{chunk-GLWZXQ4Q.js → chunk-KHNZ6MOU.js} +1 -1
  34. package/dist/chunk-KHNZ6MOU.js.map +1 -0
  35. package/dist/{chunk-GCJWMEYW.cjs → chunk-KSJLDRHK.cjs} +46 -46
  36. package/dist/{chunk-GCJWMEYW.cjs.map → chunk-KSJLDRHK.cjs.map} +1 -1
  37. package/dist/{chunk-QQKTOA4U.cjs → chunk-ORE334I6.cjs} +132 -132
  38. package/dist/{chunk-QQKTOA4U.cjs.map → chunk-ORE334I6.cjs.map} +1 -1
  39. package/dist/{chunk-X6KTSFAE.js → chunk-Q4NBEVV5.js} +2 -2
  40. package/dist/{chunk-XZWOLXWA.js → chunk-QFSTQHZY.js} +174 -3
  41. package/dist/chunk-QFSTQHZY.js.map +1 -0
  42. package/dist/{chunk-FPRIUR4T.js → chunk-ROZFX4QI.js} +3 -3
  43. package/dist/{chunk-UXFI3CDZ.cjs → chunk-SFCPGMCT.cjs} +8 -8
  44. package/dist/{chunk-UXFI3CDZ.cjs.map → chunk-SFCPGMCT.cjs.map} +1 -1
  45. package/dist/{chunk-J67OLQUQ.js → chunk-UABQTYQF.js} +3 -3
  46. package/dist/{chunk-O5RVCDEC.cjs → chunk-XLUYXUBD.cjs} +88 -88
  47. package/dist/{chunk-O5RVCDEC.cjs.map → chunk-XLUYXUBD.cjs.map} +1 -1
  48. package/dist/{chunk-FG274FYT.js → chunk-YGJIER2R.js} +2 -2
  49. package/dist/effects/index.cjs +32 -34
  50. package/dist/effects/index.cjs.map +1 -1
  51. package/dist/effects/index.d.cts +6 -38
  52. package/dist/effects/index.d.ts +6 -38
  53. package/dist/effects/index.js +3 -5
  54. package/dist/effects/index.js.map +1 -1
  55. package/dist/evaluate-BbCeF6pt.d.ts +114 -0
  56. package/dist/evaluate-BsxYieLN.d.cts +114 -0
  57. package/dist/{export-DVl4fWy5.d.cts → export-Cbr9IqpJ.d.cts} +1 -1
  58. package/dist/{export-Bp7ji2r4.d.cts → export-CcldobdN.d.cts} +3 -3
  59. package/dist/{export-C1s4eolZ.d.ts → export-ClPKUB-v.d.ts} +1 -1
  60. package/dist/{export-DAyPY94f.d.ts → export-PGhOpDmz.d.ts} +3 -3
  61. package/dist/{helpers-i95Ob6Vi.d.cts → helpers-C5aAd44p.d.cts} +67 -4
  62. package/dist/{helpers-BBLlekuM.d.ts → helpers-CPWcK504.d.ts} +67 -4
  63. package/dist/image-editor/index.cjs +619 -621
  64. package/dist/image-editor/index.cjs.map +1 -1
  65. package/dist/image-editor/index.d.cts +9 -11
  66. package/dist/image-editor/index.d.ts +9 -11
  67. package/dist/image-editor/index.js +6 -8
  68. package/dist/image-editor/index.js.map +1 -1
  69. package/dist/{opentype-14PDI5D2.d.ts → opentype-01rMIuQR.d.ts} +1 -1
  70. package/dist/{opentype-D80AVmMu.d.cts → opentype-BgqvmGT-.d.cts} +1 -1
  71. package/dist/paint-editor/index.cjs +737 -117
  72. package/dist/paint-editor/index.cjs.map +1 -1
  73. package/dist/paint-editor/index.d.cts +248 -13
  74. package/dist/paint-editor/index.d.ts +248 -13
  75. package/dist/paint-editor/index.js +635 -15
  76. package/dist/paint-editor/index.js.map +1 -1
  77. package/dist/{pathfinder-DjISxkUv.d.ts → pathfinder-D-h0Imus.d.ts} +1 -1
  78. package/dist/{pathfinder-C0UoFypx.d.cts → pathfinder-DgG0Z9Lr.d.cts} +1 -1
  79. package/dist/{player-cGLrngL_.d.ts → player-BK2kKbfd.d.ts} +1 -1
  80. package/dist/{player-CBtEoU2x.d.cts → player-CmbY3218.d.cts} +1 -1
  81. package/dist/pool-C7GtrL34.d.cts +34 -0
  82. package/dist/pool-CTrtciaN.d.ts +34 -0
  83. package/dist/{svg-DJKriJ4A.d.ts → svg-BRLwcibA.d.ts} +2 -3
  84. package/dist/{svg-BkRL-fZJ.d.cts → svg-DLBBPQP9.d.cts} +2 -3
  85. package/dist/{tools-CM8Oe8F3.d.ts → tools-AugT22z3.d.ts} +1 -1
  86. package/dist/{tools-DZCv2kX1.d.cts → tools-BpCmUNxb.d.cts} +1 -1
  87. package/dist/vector/index.cjs +923 -925
  88. package/dist/vector/index.cjs.map +1 -1
  89. package/dist/vector/index.d.cts +10 -12
  90. package/dist/vector/index.d.ts +10 -12
  91. package/dist/vector/index.js +11 -13
  92. package/dist/vector/index.js.map +1 -1
  93. package/dist/video-editor/index.cjs +269 -271
  94. package/dist/video-editor/index.cjs.map +1 -1
  95. package/dist/video-editor/index.d.cts +6 -8
  96. package/dist/video-editor/index.d.ts +6 -8
  97. package/dist/video-editor/index.js +3 -5
  98. package/dist/video-editor/index.js.map +1 -1
  99. package/dist/{warp-CH9MM435.d.cts → warp-C13L_GRn.d.cts} +1 -1
  100. package/dist/{warp-k_PdtXOG.d.ts → warp-q8FK5HHi.d.ts} +1 -1
  101. package/package.json +1 -1
  102. package/skills/pixerate-canvas/SKILL.md +19 -0
  103. package/skills/pixerate-paint-editor/SKILL.md +40 -1
  104. package/dist/behavior-Ymbld6jL.d.cts +0 -60
  105. package/dist/behavior-Ymbld6jL.d.ts +0 -60
  106. package/dist/chunk-GLWZXQ4Q.js.map +0 -1
  107. package/dist/chunk-IOXKXQNW.cjs +0 -178
  108. package/dist/chunk-IOXKXQNW.cjs.map +0 -1
  109. package/dist/chunk-QDJKUBWE.cjs.map +0 -1
  110. package/dist/chunk-TGKT5QAB.js +0 -178
  111. package/dist/chunk-TGKT5QAB.js.map +0 -1
  112. package/dist/chunk-XZWOLXWA.js.map +0 -1
  113. package/dist/evaluate-2S3vSPLy.d.cts +0 -55
  114. package/dist/evaluate-CfmT6xA3.d.ts +0 -55
  115. package/dist/gradient-KDfCvhuj.d.cts +0 -66
  116. package/dist/gradient-KDfCvhuj.d.ts +0 -66
  117. /package/dist/{brushstrokeRender-LRV7GXGD.js.map → brushstrokeRender-7RUITO42.js.map} +0 -0
  118. /package/dist/{chunk-MPQAO33O.js.map → chunk-A6KHMKI4.js.map} +0 -0
  119. /package/dist/{chunk-WUDPFWAN.js.map → chunk-F7Q2NE2Y.js.map} +0 -0
  120. /package/dist/{chunk-G6WXWS4Y.js.map → chunk-FICSDDDF.js.map} +0 -0
  121. /package/dist/{chunk-X6KTSFAE.js.map → chunk-Q4NBEVV5.js.map} +0 -0
  122. /package/dist/{chunk-FPRIUR4T.js.map → chunk-ROZFX4QI.js.map} +0 -0
  123. /package/dist/{chunk-J67OLQUQ.js.map → chunk-UABQTYQF.js.map} +0 -0
  124. /package/dist/{chunk-FG274FYT.js.map → chunk-YGJIER2R.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { P as Point, d as CanvasBrushstroke } from './brushTypes-IG7ZZjIN.cjs';
2
- import { C as CanvasGradientDef, S as SvgGradientDef } from './gradient-KDfCvhuj.cjs';
2
+ import { C as CanvasGradientDef, S as SvgGradientDef } from './helpers-C5aAd44p.cjs';
3
3
 
4
4
  /**
5
5
  * Polygon boolean operations (union, intersection, difference, xor and divide) on
@@ -110,7 +110,27 @@ declare function dividePolygons(operands: PolygonInput[], options?: PolygonBoole
110
110
  */
111
111
 
112
112
  /** Paint shared by every shape kind. Colours are any CSS colour, preset name, or gradient definition. */
113
+ /**
114
+ * A provider effect (see `@pixerate/editor/effects`) drawn on a shape: `fill` paints the shape's
115
+ * inside with the effect (clipped to its outline), `overlay` draws it over the node's box. Kept,
116
+ * and not drawn, without an effects provider.
117
+ */
118
+ interface CanvasShapeEffect {
119
+ /** The provider's effect id. */
120
+ effect: string;
121
+ provider?: string;
122
+ name?: string;
123
+ /** Control values (over the effect's defaults). */
124
+ values: Record<string, number | string | boolean | readonly number[]>;
125
+ mode: 'fill' | 'overlay';
126
+ /** 0–1 (default 1). */
127
+ opacity?: number;
128
+ /** Animated effects play while true (default true); false holds the first frame. */
129
+ playing?: boolean;
130
+ }
113
131
  interface ShapePaint {
132
+ /** A provider effect drawn on the shape (see `CanvasShapeEffect`). */
133
+ effect?: CanvasShapeEffect;
114
134
  fill?: string | CanvasGradientDef;
115
135
  stroke?: string | CanvasGradientDef;
116
136
  strokeWidth?: number;
@@ -486,4 +506,4 @@ declare function pointInBezierPath(input: BezierPathInput, point: Point, fillRul
486
506
  /** Distance from `point` to the path outline (closing lines of closed subpaths included). */
487
507
  declare function distanceToBezierPath(input: BezierPathInput | readonly BezierContour[], point: Point): number;
488
508
 
489
- export { pathToContours as $, type AffineMatrix as A, type BezierPath as B, bezierPathPointAtLength as C, bezierPathSignedArea as D, type EllipseShape as E, type FlattenOptions as F, type GetShapeRenderDataOptions as G, bezierPathToSvg as H, closeContour as I, contourSignedArea as J, contoursToPath as K, countPathSegments as L, type MultiPolygon as M, distanceToBezierPath as N, dividePolygons as O, type PolygonBooleanOperation as P, flattenSvgPath as Q, type RectShape as R, type ShapeDescription as S, formatNumber as T, getShapeRenderData as U, getShapeSvg as V, intersectPolygons as W, isShapeDescription as X, multiPolygonArea as Y, multiPolygonBounds as Z, parseSvgPath as _, type BezierPathInput as a, pointInBezierPath as a0, pointInMultiPolygon as a1, pointInRings as a2, polygonArea as a3, polygonBoolean as a4, polygonToSvgPath as a5, ringSignedArea as a6, segmentBounds as a7, segmentCurvature as a8, segmentDerivative as a9, segmentExtrema as aa, segmentLength as ab, segmentNearest as ac, segmentParamAtLength as ad, segmentPoint as ae, segmentTangent as af, shapeToPolygon as ag, simplifyRing as ah, splitSegment as ai, subSegment as aj, subtractPolygons as ak, toBezierPath as al, transformBezierPath as am, trimSegments as an, unionPolygons as ao, windingNumber as ap, xorPolygons as aq, type PolygonFillRule as b, type BezierSegment as c, type BezierContour as d, type PolygonRing as e, type ShapeSize as f, type PathShape as g, type BezierCommand as h, type BezierPathToSvgOptions as i, type PathCommand as j, type PathPointAtLength as k, type PolygonBooleanOptions as l, type PolygonInput as m, type PolygonOperand as n, type PolygonPiece as o, type PolygonToPathOptions as p, type PolygonWithHoles as q, type RegularPolygonShape as r, SHAPE_KINDS as s, type ShapeKind as t, type ShapePaint as u, type ShapeRenderData as v, type StarShape as w, arcToCubics as x, bezierPathBounds as y, bezierPathLength as z };
509
+ export { parseSvgPath as $, type AffineMatrix as A, type BezierPath as B, type CanvasShapeEffect as C, bezierPathPointAtLength as D, type EllipseShape as E, type FlattenOptions as F, type GetShapeRenderDataOptions as G, bezierPathSignedArea as H, bezierPathToSvg as I, closeContour as J, contourSignedArea as K, contoursToPath as L, type MultiPolygon as M, countPathSegments as N, distanceToBezierPath as O, type PolygonBooleanOperation as P, dividePolygons as Q, type RectShape as R, type ShapeDescription as S, flattenSvgPath as T, formatNumber as U, getShapeRenderData as V, getShapeSvg as W, intersectPolygons as X, isShapeDescription as Y, multiPolygonArea as Z, multiPolygonBounds as _, type BezierPathInput as a, pathToContours as a0, pointInBezierPath as a1, pointInMultiPolygon as a2, pointInRings as a3, polygonArea as a4, polygonBoolean as a5, polygonToSvgPath as a6, ringSignedArea as a7, segmentBounds as a8, segmentCurvature as a9, segmentDerivative as aa, segmentExtrema as ab, segmentLength as ac, segmentNearest as ad, segmentParamAtLength as ae, segmentPoint as af, segmentTangent as ag, shapeToPolygon as ah, simplifyRing as ai, splitSegment as aj, subSegment as ak, subtractPolygons as al, toBezierPath as am, transformBezierPath as an, trimSegments as ao, unionPolygons as ap, windingNumber as aq, xorPolygons as ar, type PolygonFillRule as b, type BezierSegment as c, type BezierContour as d, type PolygonRing as e, type ShapeSize as f, type PathShape as g, type BezierCommand as h, type BezierPathToSvgOptions as i, type PathCommand as j, type PathPointAtLength as k, type PolygonBooleanOptions as l, type PolygonInput as m, type PolygonOperand as n, type PolygonPiece as o, type PolygonToPathOptions as p, type PolygonWithHoles as q, type RegularPolygonShape as r, SHAPE_KINDS as s, type ShapeKind as t, type ShapePaint as u, type ShapeRenderData as v, type StarShape as w, arcToCubics as x, bezierPathBounds as y, bezierPathLength as z };
@@ -1,5 +1,5 @@
1
1
  import { P as Point, d as CanvasBrushstroke } from './brushTypes-IG7ZZjIN.js';
2
- import { C as CanvasGradientDef, S as SvgGradientDef } from './gradient-KDfCvhuj.js';
2
+ import { C as CanvasGradientDef, S as SvgGradientDef } from './helpers-CPWcK504.js';
3
3
 
4
4
  /**
5
5
  * Polygon boolean operations (union, intersection, difference, xor and divide) on
@@ -110,7 +110,27 @@ declare function dividePolygons(operands: PolygonInput[], options?: PolygonBoole
110
110
  */
111
111
 
112
112
  /** Paint shared by every shape kind. Colours are any CSS colour, preset name, or gradient definition. */
113
+ /**
114
+ * A provider effect (see `@pixerate/editor/effects`) drawn on a shape: `fill` paints the shape's
115
+ * inside with the effect (clipped to its outline), `overlay` draws it over the node's box. Kept,
116
+ * and not drawn, without an effects provider.
117
+ */
118
+ interface CanvasShapeEffect {
119
+ /** The provider's effect id. */
120
+ effect: string;
121
+ provider?: string;
122
+ name?: string;
123
+ /** Control values (over the effect's defaults). */
124
+ values: Record<string, number | string | boolean | readonly number[]>;
125
+ mode: 'fill' | 'overlay';
126
+ /** 0–1 (default 1). */
127
+ opacity?: number;
128
+ /** Animated effects play while true (default true); false holds the first frame. */
129
+ playing?: boolean;
130
+ }
113
131
  interface ShapePaint {
132
+ /** A provider effect drawn on the shape (see `CanvasShapeEffect`). */
133
+ effect?: CanvasShapeEffect;
114
134
  fill?: string | CanvasGradientDef;
115
135
  stroke?: string | CanvasGradientDef;
116
136
  strokeWidth?: number;
@@ -486,4 +506,4 @@ declare function pointInBezierPath(input: BezierPathInput, point: Point, fillRul
486
506
  /** Distance from `point` to the path outline (closing lines of closed subpaths included). */
487
507
  declare function distanceToBezierPath(input: BezierPathInput | readonly BezierContour[], point: Point): number;
488
508
 
489
- export { pathToContours as $, type AffineMatrix as A, type BezierPath as B, bezierPathPointAtLength as C, bezierPathSignedArea as D, type EllipseShape as E, type FlattenOptions as F, type GetShapeRenderDataOptions as G, bezierPathToSvg as H, closeContour as I, contourSignedArea as J, contoursToPath as K, countPathSegments as L, type MultiPolygon as M, distanceToBezierPath as N, dividePolygons as O, type PolygonBooleanOperation as P, flattenSvgPath as Q, type RectShape as R, type ShapeDescription as S, formatNumber as T, getShapeRenderData as U, getShapeSvg as V, intersectPolygons as W, isShapeDescription as X, multiPolygonArea as Y, multiPolygonBounds as Z, parseSvgPath as _, type BezierPathInput as a, pointInBezierPath as a0, pointInMultiPolygon as a1, pointInRings as a2, polygonArea as a3, polygonBoolean as a4, polygonToSvgPath as a5, ringSignedArea as a6, segmentBounds as a7, segmentCurvature as a8, segmentDerivative as a9, segmentExtrema as aa, segmentLength as ab, segmentNearest as ac, segmentParamAtLength as ad, segmentPoint as ae, segmentTangent as af, shapeToPolygon as ag, simplifyRing as ah, splitSegment as ai, subSegment as aj, subtractPolygons as ak, toBezierPath as al, transformBezierPath as am, trimSegments as an, unionPolygons as ao, windingNumber as ap, xorPolygons as aq, type PolygonFillRule as b, type BezierSegment as c, type BezierContour as d, type PolygonRing as e, type ShapeSize as f, type PathShape as g, type BezierCommand as h, type BezierPathToSvgOptions as i, type PathCommand as j, type PathPointAtLength as k, type PolygonBooleanOptions as l, type PolygonInput as m, type PolygonOperand as n, type PolygonPiece as o, type PolygonToPathOptions as p, type PolygonWithHoles as q, type RegularPolygonShape as r, SHAPE_KINDS as s, type ShapeKind as t, type ShapePaint as u, type ShapeRenderData as v, type StarShape as w, arcToCubics as x, bezierPathBounds as y, bezierPathLength as z };
509
+ export { parseSvgPath as $, type AffineMatrix as A, type BezierPath as B, type CanvasShapeEffect as C, bezierPathPointAtLength as D, type EllipseShape as E, type FlattenOptions as F, type GetShapeRenderDataOptions as G, bezierPathSignedArea as H, bezierPathToSvg as I, closeContour as J, contourSignedArea as K, contoursToPath as L, type MultiPolygon as M, countPathSegments as N, distanceToBezierPath as O, type PolygonBooleanOperation as P, dividePolygons as Q, type RectShape as R, type ShapeDescription as S, flattenSvgPath as T, formatNumber as U, getShapeRenderData as V, getShapeSvg as W, intersectPolygons as X, isShapeDescription as Y, multiPolygonArea as Z, multiPolygonBounds as _, type BezierPathInput as a, pathToContours as a0, pointInBezierPath as a1, pointInMultiPolygon as a2, pointInRings as a3, polygonArea as a4, polygonBoolean as a5, polygonToSvgPath as a6, ringSignedArea as a7, segmentBounds as a8, segmentCurvature as a9, segmentDerivative as aa, segmentExtrema as ab, segmentLength as ac, segmentNearest as ad, segmentParamAtLength as ae, segmentPoint as af, segmentTangent as ag, shapeToPolygon as ah, simplifyRing as ai, splitSegment as aj, subSegment as ak, subtractPolygons as al, toBezierPath as am, transformBezierPath as an, trimSegments as ao, unionPolygons as ap, windingNumber as aq, xorPolygons as ar, type PolygonFillRule as b, type BezierSegment as c, type BezierContour as d, type PolygonRing as e, type ShapeSize as f, type PathShape as g, type BezierCommand as h, type BezierPathToSvgOptions as i, type PathCommand as j, type PathPointAtLength as k, type PolygonBooleanOptions as l, type PolygonInput as m, type PolygonOperand as n, type PolygonPiece as o, type PolygonToPathOptions as p, type PolygonWithHoles as q, type RegularPolygonShape as r, SHAPE_KINDS as s, type ShapeKind as t, type ShapePaint as u, type ShapeRenderData as v, type StarShape as w, arcToCubics as x, bezierPathBounds as y, bezierPathLength as z };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-UYQUPUR6.js";
4
4
  import {
5
5
  pathDataToPolyline
6
- } from "./chunk-J67OLQUQ.js";
6
+ } from "./chunk-UABQTYQF.js";
7
7
  import {
8
8
  parseCssColor
9
9
  } from "./chunk-CTTF4KYV.js";
@@ -21,7 +21,7 @@ import {
21
21
  formatNumber,
22
22
  getShapeSvg,
23
23
  resolveCanvasGradient
24
- } from "./chunk-GLWZXQ4Q.js";
24
+ } from "./chunk-KHNZ6MOU.js";
25
25
 
26
26
  // src/canvas/brushstrokeRender.ts
27
27
  var DRY = BUILTIN_BRUSHES.filter((b) => isBrushstrokeBrush(b));
@@ -88,4 +88,4 @@ export {
88
88
  renderShapeBrushstrokeNow,
89
89
  resolveCanvasBrush
90
90
  };
91
- //# sourceMappingURL=brushstrokeRender-LRV7GXGD.js.map
91
+ //# sourceMappingURL=brushstrokeRender-7RUITO42.js.map
@@ -3,7 +3,7 @@
3
3
  var _chunkW4LNKTHTcjs = require('./chunk-W4LNKTHT.cjs');
4
4
 
5
5
 
6
- var _chunk7LQO6OHHcjs = require('./chunk-7LQO6OHH.cjs');
6
+ var _chunk33SO3QWPcjs = require('./chunk-33SO3QWP.cjs');
7
7
 
8
8
 
9
9
  var _chunk2YQONY6Gcjs = require('./chunk-2YQONY6G.cjs');
@@ -21,7 +21,7 @@ require('./chunk-643B2HKC.cjs');
21
21
 
22
22
 
23
23
 
24
- var _chunkGUZ47CJMcjs = require('./chunk-GUZ47CJM.cjs');
24
+ var _chunkIZ4WRXZAcjs = require('./chunk-IZ4WRXZA.cjs');
25
25
 
26
26
  // src/canvas/brushstrokeRender.ts
27
27
  var DRY = _chunkW4LNKTHTcjs.BUILTIN_BRUSHES.filter((b) => _chunkZ6OUCS2Kcjs.isBrushstrokeBrush.call(void 0, b));
@@ -45,7 +45,7 @@ function resolveCanvasBrush(brush, width) {
45
45
  return { size, ...brush };
46
46
  }
47
47
  function strokeColor(shape) {
48
- const gradient = _chunkGUZ47CJMcjs.resolveCanvasGradient.call(void 0, _nullishCoalesce(shape.strokeGradient, () => ( shape.stroke)));
48
+ const gradient = _chunkIZ4WRXZAcjs.resolveCanvasGradient.call(void 0, _nullishCoalesce(shape.strokeGradient, () => ( shape.stroke)));
49
49
  const css = gradient ? _nullishCoalesce(_optionalChain([gradient, 'access', _ => _.stops, 'access', _2 => _2[0], 'optionalAccess', _3 => _3.color]), () => ( "#000")) : typeof shape.stroke === "string" && shape.stroke !== "none" ? shape.stroke : "#000";
50
50
  const parsed = _nullishCoalesce(_chunk2YQONY6Gcjs.parseCssColor.call(void 0, css), () => ( { hex: "#000000", alpha: 1 }));
51
51
  const n = parseInt(parsed.hex.slice(1), 16);
@@ -55,7 +55,7 @@ var cache = new (0, _chunkZ6OUCS2Kcjs.BrushstrokeCache)(128);
55
55
  var urls = /* @__PURE__ */ new WeakMap();
56
56
  function renderShapeBrushstrokeNow(shape, scale) {
57
57
  const brush = resolveCanvasBrush(shape.brush.brush, _nullishCoalesce(shape.strokeWidth, () => ( 3)));
58
- const points = _chunk7LQO6OHHcjs.pathDataToPolyline.call(void 0, shape.d);
58
+ const points = _chunk33SO3QWPcjs.pathDataToPolyline.call(void 0, shape.d);
59
59
  if (!points.length) return null;
60
60
  const { pressure, tiltX, tiltY } = shape.brush;
61
61
  const input = {
@@ -75,9 +75,9 @@ function renderShapeBrushstrokeNow(shape, scale) {
75
75
  }
76
76
  var escapeAttr = (s) => s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
77
77
  function brushedShapeSvgNow(shape, size, scale) {
78
- const f = (n) => _chunkGUZ47CJMcjs.formatNumber.call(void 0, n, 3);
78
+ const f = (n) => _chunkIZ4WRXZAcjs.formatNumber.call(void 0, n, 3);
79
79
  const image = renderShapeBrushstrokeNow(shape, scale);
80
- const svg = _chunkGUZ47CJMcjs.getShapeSvg.call(void 0, shape, size);
80
+ const svg = _chunkIZ4WRXZAcjs.getShapeSvg.call(void 0, shape, size);
81
81
  const body = image ? `<image href="${escapeAttr(image.href)}" x="${f(image.x)}" y="${f(image.y)}" width="${f(image.width)}" height="${f(image.height)}" preserveAspectRatio="none"${shape.opacity !== void 0 ? ` opacity="${f(shape.opacity)}"` : ""}/>` : "";
82
82
  const content = svg.transform && body ? `<g transform="${svg.transform}">${body}</g>` : body;
83
83
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${f(size.width)}" height="${f(size.height)}" viewBox="0 0 ${f(size.width)} ${f(size.height)}">${content}</svg>`;
@@ -88,4 +88,4 @@ function brushedShapeSvgNow(shape, size, scale) {
88
88
 
89
89
 
90
90
  exports.brushedShapeSvgNow = brushedShapeSvgNow; exports.listCanvasBrushes = listCanvasBrushes; exports.renderShapeBrushstrokeNow = renderShapeBrushstrokeNow; exports.resolveCanvasBrush = resolveCanvasBrush;
91
- //# sourceMappingURL=brushstrokeRender-EELTV7U4.cjs.map
91
+ //# sourceMappingURL=brushstrokeRender-OW6ENCZG.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/brushstrokeRender-EELTV7U4.cjs","../src/canvas/brushstrokeRender.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACbA,IAAM,IAAA,EAAM,iCAAA,CAAgB,MAAA,CAAO,CAAC,CAAA,EAAA,GAAM,kDAAA,CAAoB,CAAC,CAAA;AAExD,SAAS,iBAAA,CAAA,EAAyC;AACxD,EAAA,OAAO,GAAA,CAAI,GAAA,CAAI,CAAC,CAAA,EAAA,GAAA,CAAO,EAAE,EAAA,EAAI,CAAA,CAAE,EAAA,EAAI,IAAA,EAAM,CAAA,CAAE,IAAA,EAAM,QAAA,EAAU,CAAA,CAAE,QAAA,EAAU,IAAA,EAAM,CAAA,CAAE,GAAA,CAAI,KAAK,CAAA,CAAE,CAAA;AAC3F;AAGO,SAAS,kBAAA,CAAmB,KAAA,EAAoB,KAAA,EAAiC;AACvF,EAAA,MAAM,KAAA,EAAO,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,MAAA,CAAO,QAAA,CAAS,KAAK,EAAA,EAAI,MAAA,EAAQ,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,KAAK,CAAA;AACpD,EAAA,MAAM,IAAA,EAAM,2CAAA,KAAY,EAAO,IAAI,CAAA;AACnC,EAAA,MAAM,KAAA,EAAO,MAAA,EACV,CAAA,aAAA,EAAgB,UAAA,CAAW,KAAA,CAAM,IAAI,CAAC,CAAA,KAAA,EAAQ,CAAA,CAAE,KAAA,CAAM,CAAC,CAAC,CAAA,KAAA,EAAQ,CAAA,CAAE,KAAA,CAAM,CAAC,CAAC,CAAA,SAAA,EAAY,CAAA,CAAE,KAAA,CAAM,KAAK,CAAC,CAAA,UAAA,EAAa,CAAA,CAAE,KAAA,CAAM,MAAM,CAAC,CAAA,4BAAA,EAA+B,KAAA,CAAM,QAAA,IAAY,KAAA,EAAA,EAAY,CAAA,UAAA,EAAa,CAAA,CAAE,KAAA,CAAM,OAAO,CAAC,CAAA,CAAA,EAAA,EAAM,EAAE,CAAA,EAAA,EAAA,EAClO,EAAA;AACH,EAAA,MAAM,QAAA,EAAU,GAAA,CAAI,UAAA,GAAa,KAAA,EAAO,CAAA,cAAA,EAAiB,GAAA,CAAI,SAAS,CAAA,EAAA,EAAK,IAAI,CAAA,IAAA,EAAA,EAAS,IAAA;AACxF,EAAA,OAAO,CAAA,+CAAA,EAAkD,CAAA,CAAE,IAAA,CAAK,KAAK,CAAC,CAAA,UAAA,EAAa,CAAA,CAAE,IAAA,CAAK,MAAM,CAAC,CAAA,eAAA,EAAkB,CAAA,CAAE,IAAA,CAAK,KAAK,CAAC,CAAA,CAAA,EAAI,CAAA,CAAE,IAAA,CAAK,MAAM,CAAC,CAAA,EAAA,EAAK,OAAO,CAAA,MAAA,CAAA;AAC/J;ADIA;AACE;AACA;AACA;AACA;AACF,+MAAC","file":"/home/runner/work/editor/editor/packages/core/dist/brushstrokeRender-EELTV7U4.cjs","sourcesContent":[null,"/**\n * The lazily loaded half of brushed freehand strokes (`./brushstroke.ts` imports it on first use):\n * the paint engine's dry brushstroke renderer, the paint presets and a CSS colour parser. Keep\n * every import of the paint engine in this file, so the canvas entry never reaches it statically.\n */\nimport { BrushstrokeCache, brushstrokeDataUrl, isBrushstrokeBrush, type BrushstrokeBrush, type BrushstrokeImage } from '../paint/brushstroke.js';\nimport { BUILTIN_BRUSHES } from '../paint-editor/brushes.js';\nimport { parseCssColor } from '../image-editor/layers/css-color.js';\nimport { resolveCanvasGradient } from './gradient.js';\nimport { formatNumber, getShapeSvg, type ShapeSize } from './shapeGeometry.js';\nimport { pathDataToPolyline, type BrushedPathShape, type CanvasBrush, type CanvasBrushPreset, type CanvasBrushstrokeImage } from './brushstroke.js';\n\nconst DRY = BUILTIN_BRUSHES.filter((b) => isBrushstrokeBrush(b));\n\nexport function listCanvasBrushes(): CanvasBrushPreset[] {\n\treturn DRY.map((b) => ({ id: b.id, name: b.name, category: b.category, size: b.tip.size }));\n}\n\n/** The paint engine brush for a canvas brush at stroke width `width`; throws with the usable ids. */\nexport function resolveCanvasBrush(brush: CanvasBrush, width: number): BrushstrokeBrush {\n\tconst size = Math.max(1, Number.isFinite(width) ? width : 1);\n\tif (typeof brush === 'string') {\n\t\tconst preset = BUILTIN_BRUSHES.find((b) => b.id === brush);\n\t\tconst ids = DRY.map((b) => b.id).join(', ');\n\t\tif (!preset) throw new Error(`Unknown brush '${brush}'. Use one of the dry paint presets (${ids}) or tip settings ({ hardness, spacing, flow, … }).`);\n\t\tif (!isBrushstrokeBrush(preset)) {\n\t\t\tthrow new Error(`Brush '${brush}' (${preset.name}) is not a dry brush: brushed canvas strokes use dry media only (wet paint needs an area to flow in; mixer, blender, smudge and eraser brushes need paint under them). Use one of: ${ids}.`);\n\t\t}\n\t\treturn { ...preset, tip: { ...preset.tip, size } };\n\t}\n\tif (!brush || typeof brush !== 'object' || Array.isArray(brush)) {\n\t\tthrow new Error('A brush is a dry paint preset id (see listCanvasBrushes / canvas.listBrushes) or an object of tip settings.');\n\t}\n\treturn { size, ...brush };\n}\n\n/** RGBA of a shape's stroke paint. Gradients use their first stop until gradient paint (`PaintSource`) reaches the brush engine. */\nfunction strokeColor(shape: BrushedPathShape): [number, number, number, number] {\n\tconst gradient = resolveCanvasGradient(shape.strokeGradient ?? shape.stroke);\n\tconst css = gradient ? (gradient.stops[0]?.color ?? '#000') : typeof shape.stroke === 'string' && shape.stroke !== 'none' ? shape.stroke : '#000';\n\tconst parsed = parseCssColor(css) ?? { hex: '#000000', alpha: 1 };\n\tconst n = parseInt(parsed.hex.slice(1), 16);\n\treturn [(n >> 16) & 255, (n >> 8) & 255, n & 255, Math.round(parsed.alpha * 255)];\n}\n\nconst cache = new BrushstrokeCache(128);\nconst urls = new WeakMap<BrushstrokeImage, string>();\n\nexport function renderShapeBrushstrokeNow(shape: BrushedPathShape, scale: number): CanvasBrushstrokeImage | null {\n\tconst brush = resolveCanvasBrush(shape.brush.brush, shape.strokeWidth ?? 3);\n\tconst points = pathDataToPolyline(shape.d);\n\tif (!points.length) return null;\n\tconst { pressure, tiltX, tiltY } = shape.brush;\n\tconst input = {\n\t\tpoints: points.map(([x, y]) => ({ x, y })),\n\t\t...(pressure?.length ? { pressure } : {}),\n\t\t...(tiltX?.length ? { tiltX } : {}),\n\t\t...(tiltY?.length ? { tiltY } : {})\n\t};\n\tconst stroke = cache.render(input, brush, { scale, color: strokeColor(shape) });\n\tif (!stroke.bounds) return null;\n\tlet href = urls.get(stroke);\n\tif (href === undefined) {\n\t\thref = brushstrokeDataUrl(stroke);\n\t\turls.set(stroke, href);\n\t}\n\treturn { href, ...stroke.bounds, scale: stroke.scale };\n}\n\nconst escapeAttr = (s: string) => s.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;');\n\nexport function brushedShapeSvgNow(shape: BrushedPathShape, size: ShapeSize, scale: number): string {\n\tconst f = (n: number) => formatNumber(n, 3);\n\tconst image = renderShapeBrushstrokeNow(shape, scale);\n\tconst svg = getShapeSvg(shape, size);\n\tconst body = image\n\t\t? `<image href=\"${escapeAttr(image.href)}\" x=\"${f(image.x)}\" y=\"${f(image.y)}\" width=\"${f(image.width)}\" height=\"${f(image.height)}\" preserveAspectRatio=\"none\"${shape.opacity !== undefined ? ` opacity=\"${f(shape.opacity)}\"` : ''}/>`\n\t\t: '';\n\tconst content = svg.transform && body ? `<g transform=\"${svg.transform}\">${body}</g>` : body;\n\treturn `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${f(size.width)}\" height=\"${f(size.height)}\" viewBox=\"0 0 ${f(size.width)} ${f(size.height)}\">${content}</svg>`;\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/brushstrokeRender-OW6ENCZG.cjs","../src/canvas/brushstrokeRender.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACbA,IAAM,IAAA,EAAM,iCAAA,CAAgB,MAAA,CAAO,CAAC,CAAA,EAAA,GAAM,kDAAA,CAAoB,CAAC,CAAA;AAExD,SAAS,iBAAA,CAAA,EAAyC;AACxD,EAAA,OAAO,GAAA,CAAI,GAAA,CAAI,CAAC,CAAA,EAAA,GAAA,CAAO,EAAE,EAAA,EAAI,CAAA,CAAE,EAAA,EAAI,IAAA,EAAM,CAAA,CAAE,IAAA,EAAM,QAAA,EAAU,CAAA,CAAE,QAAA,EAAU,IAAA,EAAM,CAAA,CAAE,GAAA,CAAI,KAAK,CAAA,CAAE,CAAA;AAC3F;AAGO,SAAS,kBAAA,CAAmB,KAAA,EAAoB,KAAA,EAAiC;AACvF,EAAA,MAAM,KAAA,EAAO,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,MAAA,CAAO,QAAA,CAAS,KAAK,EAAA,EAAI,MAAA,EAAQ,CAAC,CAAA;AAC3D,EAAA,GAAA,CAAI,OA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AM,2CAAA,KAAY,EAAO,IAAI,CAAA;AACnC,EAAA,MAAM,KAAA,EAAO,MAAA,EACV,CAAA,aAAA,EAAgB,UAAA,CAAW,KAAA,CAAM,IAAI,CAAC,CAAA,KAAA,EAAQ,CAAA,CAAE,KAAA,CAAM,CAAC,CAAC,CAAA,KAAA,EAAQ,CAAA,CAAE,KAAA,CAAM,CAAC,CAAC,CAAA,SAAA,EAAY,CAAA,CAAE,KAAA,CAAM,KAAK,CAAC,CAAA,UAAA,EAAa,CAAA,CAAE,KAAA,CAAM,MAAM,CAAC,CAAA,4BAAA,EAA+B,KAAA,CAAM,QAAA,IAAY,KAAA,EAAA,EAAY,CAAA,UAAA,EAAa,CAAA,CAAE,KAAA,CAAM,OAAO,CAAC,CAAA,CAAA,EAAA,EAAM,EAAE,CAAA,EAAA,EAAA,EAClO,EAAA;AACH,EAAA,MAAM,QAAA,EAAU,GAAA,CAAI,UAAA,GAAa,KAAA,EAAO,CAAA,cAAA,EAAiB,GAAA,CAAI,SAAS,CAAA,EAAA,EAAK,IAAI,CAAA,IAAA,EAAA,EAAS,IAAA;AACxF,EAAA,OAAO,CAAA,+CAAA,EAAkD,CAAA,CAAE,IAAA,CAAK,KAAK,CAAC,CAAA,UAAA,EAAa,CAAA,CAAE,IAAA,CAAK,MAAM,CAAC,CAAA,eAAA,EAAkB,CAAA,CAAE,IAAA,CAAK,KAAK,CAAC,CAAA,CAAA,EAAI,CAAA,CAAE,IAAA,CAAK,MAAM,CAAC,CAAA,EAAA,EAAK,OAAO,CAAA,MAAA,CAAA;AAC/J;ADIA;AACE;AACA;AACA;AACA;AACF,+MAAC","file":"/home/runner/work/editor/editor/packages/core/dist/brushstrokeRender-OW6ENCZG.cjs","sourcesContent":[null,"/**\n * The lazily loaded half of brushed freehand strokes (`./brushstroke.ts` imports it on first use):\n * the paint engine's dry brushstroke renderer, the paint presets and a CSS colour parser. Keep\n * every import of the paint engine in this file, so the canvas entry never reaches it statically.\n */\nimport { BrushstrokeCache, brushstrokeDataUrl, isBrushstrokeBrush, type BrushstrokeBrush, type BrushstrokeImage } from '../paint/brushstroke.js';\nimport { BUILTIN_BRUSHES } from '../paint-editor/brushes.js';\nimport { parseCssColor } from '../image-editor/layers/css-color.js';\nimport { resolveCanvasGradient } from './gradient.js';\nimport { formatNumber, getShapeSvg, type ShapeSize } from './shapeGeometry.js';\nimport { pathDataToPolyline, type BrushedPathShape, type CanvasBrush, type CanvasBrushPreset, type CanvasBrushstrokeImage } from './brushstroke.js';\n\nconst DRY = BUILTIN_BRUSHES.filter((b) => isBrushstrokeBrush(b));\n\nexport function listCanvasBrushes(): CanvasBrushPreset[] {\n\treturn DRY.map((b) => ({ id: b.id, name: b.name, category: b.category, size: b.tip.size }));\n}\n\n/** The paint engine brush for a canvas brush at stroke width `width`; throws with the usable ids. */\nexport function resolveCanvasBrush(brush: CanvasBrush, width: number): BrushstrokeBrush {\n\tconst size = Math.max(1, Number.isFinite(width) ? width : 1);\n\tif (typeof brush === 'string') {\n\t\tconst preset = BUILTIN_BRUSHES.find((b) => b.id === brush);\n\t\tconst ids = DRY.map((b) => b.id).join(', ');\n\t\tif (!preset) throw new Error(`Unknown brush '${brush}'. Use one of the dry paint presets (${ids}) or tip settings ({ hardness, spacing, flow, … }).`);\n\t\tif (!isBrushstrokeBrush(preset)) {\n\t\t\tthrow new Error(`Brush '${brush}' (${preset.name}) is not a dry brush: brushed canvas strokes use dry media only (wet paint needs an area to flow in; mixer, blender, smudge and eraser brushes need paint under them). Use one of: ${ids}.`);\n\t\t}\n\t\treturn { ...preset, tip: { ...preset.tip, size } };\n\t}\n\tif (!brush || typeof brush !== 'object' || Array.isArray(brush)) {\n\t\tthrow new Error('A brush is a dry paint preset id (see listCanvasBrushes / canvas.listBrushes) or an object of tip settings.');\n\t}\n\treturn { size, ...brush };\n}\n\n/** RGBA of a shape's stroke paint. Gradients use their first stop until gradient paint (`PaintSource`) reaches the brush engine. */\nfunction strokeColor(shape: BrushedPathShape): [number, number, number, number] {\n\tconst gradient = resolveCanvasGradient(shape.strokeGradient ?? shape.stroke);\n\tconst css = gradient ? (gradient.stops[0]?.color ?? '#000') : typeof shape.stroke === 'string' && shape.stroke !== 'none' ? shape.stroke : '#000';\n\tconst parsed = parseCssColor(css) ?? { hex: '#000000', alpha: 1 };\n\tconst n = parseInt(parsed.hex.slice(1), 16);\n\treturn [(n >> 16) & 255, (n >> 8) & 255, n & 255, Math.round(parsed.alpha * 255)];\n}\n\nconst cache = new BrushstrokeCache(128);\nconst urls = new WeakMap<BrushstrokeImage, string>();\n\nexport function renderShapeBrushstrokeNow(shape: BrushedPathShape, scale: number): CanvasBrushstrokeImage | null {\n\tconst brush = resolveCanvasBrush(shape.brush.brush, shape.strokeWidth ?? 3);\n\tconst points = pathDataToPolyline(shape.d);\n\tif (!points.length) return null;\n\tconst { pressure, tiltX, tiltY } = shape.brush;\n\tconst input = {\n\t\tpoints: points.map(([x, y]) => ({ x, y })),\n\t\t...(pressure?.length ? { pressure } : {}),\n\t\t...(tiltX?.length ? { tiltX } : {}),\n\t\t...(tiltY?.length ? { tiltY } : {})\n\t};\n\tconst stroke = cache.render(input, brush, { scale, color: strokeColor(shape) });\n\tif (!stroke.bounds) return null;\n\tlet href = urls.get(stroke);\n\tif (href === undefined) {\n\t\thref = brushstrokeDataUrl(stroke);\n\t\turls.set(stroke, href);\n\t}\n\treturn { href, ...stroke.bounds, scale: stroke.scale };\n}\n\nconst escapeAttr = (s: string) => s.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;');\n\nexport function brushedShapeSvgNow(shape: BrushedPathShape, size: ShapeSize, scale: number): string {\n\tconst f = (n: number) => formatNumber(n, 3);\n\tconst image = renderShapeBrushstrokeNow(shape, scale);\n\tconst svg = getShapeSvg(shape, size);\n\tconst body = image\n\t\t? `<image href=\"${escapeAttr(image.href)}\" x=\"${f(image.x)}\" y=\"${f(image.y)}\" width=\"${f(image.width)}\" height=\"${f(image.height)}\" preserveAspectRatio=\"none\"${shape.opacity !== undefined ? ` opacity=\"${f(shape.opacity)}\"` : ''}/>`\n\t\t: '';\n\tconst content = svg.transform && body ? `<g transform=\"${svg.transform}\">${body}</g>` : body;\n\treturn `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${f(size.width)}\" height=\"${f(size.height)}\" viewBox=\"0 0 ${f(size.width)} ${f(size.height)}\">${content}</svg>`;\n}\n"]}