@pixerate/editor 0.136.0 → 0.137.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 (132) hide show
  1. package/dist/animation-editor/index.cjs +60 -55
  2. package/dist/animation-editor/index.cjs.map +1 -1
  3. package/dist/animation-editor/index.d.cts +4 -4
  4. package/dist/animation-editor/index.d.ts +4 -4
  5. package/dist/animation-editor/index.js +7 -2
  6. package/dist/animation-editor/index.js.map +1 -1
  7. package/dist/{bezier-CdccFsF8.d.cts → bezier-CZ2AhjID.d.cts} +1 -1
  8. package/dist/{bezier-DG9qNZQV.d.ts → bezier-Dywv3Bw8.d.ts} +1 -1
  9. package/dist/blending-D7jCmjO6.d.cts +1026 -0
  10. package/dist/blending-NgF3qo3d.d.ts +1026 -0
  11. package/dist/brushes-CnvZSYYU.d.cts +744 -0
  12. package/dist/brushes-DJmUbIgz.d.ts +744 -0
  13. package/dist/{brushstrokeRender-SII6MG4R.js → brushstrokeRender-2FAXA3XC.js} +13 -16
  14. package/dist/{brushstrokeRender-SII6MG4R.js.map → brushstrokeRender-2FAXA3XC.js.map} +1 -1
  15. package/dist/{brushstrokeRender-JNHVEUFG.cjs → brushstrokeRender-IMFY3FF6.cjs} +16 -19
  16. package/dist/brushstrokeRender-IMFY3FF6.cjs.map +1 -0
  17. package/dist/canvas/index.cjs +10 -10
  18. package/dist/canvas/index.cjs.map +1 -1
  19. package/dist/canvas/index.d.cts +7 -7
  20. package/dist/canvas/index.d.ts +7 -7
  21. package/dist/canvas/index.js +4 -4
  22. package/dist/{chunk-W4LNKTHT.cjs → chunk-2XS6LTUP.cjs} +63 -63
  23. package/dist/{chunk-W4LNKTHT.cjs.map → chunk-2XS6LTUP.cjs.map} +1 -1
  24. package/dist/{chunk-MAHQC3SK.js → chunk-3D77LOBM.js} +222 -135
  25. package/dist/chunk-3D77LOBM.js.map +1 -0
  26. package/dist/{chunk-BR7EKQUP.js → chunk-3G6J7UFV.js} +322 -2
  27. package/dist/chunk-3G6J7UFV.js.map +1 -0
  28. package/dist/{chunk-62XUO5LB.js → chunk-3X6IAJUQ.js} +2 -2
  29. package/dist/{chunk-EM3FMJWE.js → chunk-5FSRTP6E.js} +320 -3
  30. package/dist/chunk-5FSRTP6E.js.map +1 -0
  31. package/dist/{chunk-2R3UW57U.cjs → chunk-5OOIUXNJ.cjs} +333 -246
  32. package/dist/chunk-5OOIUXNJ.cjs.map +1 -0
  33. package/dist/{chunk-KZXLZCQ7.js → chunk-6S6362D2.js} +2 -2
  34. package/dist/{chunk-24ATT2PE.cjs → chunk-AEAAN4AD.cjs} +120 -120
  35. package/dist/{chunk-24ATT2PE.cjs.map → chunk-AEAAN4AD.cjs.map} +1 -1
  36. package/dist/{chunk-SVYE5HIM.js → chunk-EQQMGO42.js} +2 -2
  37. package/dist/{chunk-FHPVDTI2.cjs → chunk-F2Y4E4GU.cjs} +22 -22
  38. package/dist/{chunk-FHPVDTI2.cjs.map → chunk-F2Y4E4GU.cjs.map} +1 -1
  39. package/dist/{chunk-UYQUPUR6.js → chunk-HUO3TI4C.js} +3 -3
  40. package/dist/{chunk-DDSO4HS7.cjs → chunk-KEENUAFN.cjs} +2 -2
  41. package/dist/{chunk-DDSO4HS7.cjs.map → chunk-KEENUAFN.cjs.map} +1 -1
  42. package/dist/{chunk-2HC4DRF4.js → chunk-LLFHCSU2.js} +2 -2
  43. package/dist/{chunk-J5BA3BQ6.cjs → chunk-O7LUD7MH.cjs} +323 -3
  44. package/dist/chunk-O7LUD7MH.cjs.map +1 -0
  45. package/dist/{chunk-ILYFOJUN.js → chunk-OIBIRXRG.js} +3 -3
  46. package/dist/{chunk-B2CUCM7Y.cjs → chunk-PRSRYHQD.cjs} +36 -36
  47. package/dist/{chunk-B2CUCM7Y.cjs.map → chunk-PRSRYHQD.cjs.map} +1 -1
  48. package/dist/{chunk-6GFRKLLS.cjs → chunk-QBWEH3IM.cjs} +429 -112
  49. package/dist/chunk-QBWEH3IM.cjs.map +1 -0
  50. package/dist/{chunk-6QQR4LKE.js → chunk-SYT2TLQF.js} +35 -37
  51. package/dist/{chunk-6QQR4LKE.js.map → chunk-SYT2TLQF.js.map} +1 -1
  52. package/dist/{chunk-YT3JL7YM.cjs → chunk-TLCTTQFF.cjs} +53 -53
  53. package/dist/{chunk-YT3JL7YM.cjs.map → chunk-TLCTTQFF.cjs.map} +1 -1
  54. package/dist/{chunk-JLGNZMUV.cjs → chunk-XN2NBLV5.cjs} +313 -315
  55. package/dist/chunk-XN2NBLV5.cjs.map +1 -0
  56. package/dist/effects/index.d.cts +4 -4
  57. package/dist/effects/index.d.ts +4 -4
  58. package/dist/{export-Ds7zgGD8.d.ts → export-41rL6Cne.d.ts} +1 -1
  59. package/dist/{export-BOheWw2R.d.cts → export-CyJdfP_Z.d.cts} +5 -4
  60. package/dist/{export-CEYeRQXH.d.cts → export-D9mXp05Q.d.cts} +1 -1
  61. package/dist/{export-ByKKIA2S.d.ts → export-DwnZ_hvQ.d.ts} +5 -4
  62. package/dist/{helpers--ns3W2D7.d.ts → helpers-C-RgeyvH.d.ts} +18 -7
  63. package/dist/{helpers-BVkU4oUi.d.cts → helpers-v6GMazzg.d.cts} +18 -7
  64. package/dist/image-editor/index.cjs +984 -987
  65. package/dist/image-editor/index.cjs.map +1 -1
  66. package/dist/image-editor/index.d.cts +12 -11
  67. package/dist/image-editor/index.d.ts +12 -11
  68. package/dist/image-editor/index.js +92 -95
  69. package/dist/image-editor/index.js.map +1 -1
  70. package/dist/{opentype-yi-Kz4ND.d.cts → opentype-KR_jj6b_.d.cts} +1 -1
  71. package/dist/{opentype-DfoVYgmG.d.ts → opentype-a1KAW-qs.d.ts} +1 -1
  72. package/dist/paint/index.cjs +5 -8
  73. package/dist/paint/index.cjs.map +1 -1
  74. package/dist/paint/index.d.cts +4 -2
  75. package/dist/paint/index.d.ts +4 -2
  76. package/dist/paint/index.js +15 -18
  77. package/dist/paint-editor/index.cjs +403 -404
  78. package/dist/paint-editor/index.cjs.map +1 -1
  79. package/dist/paint-editor/index.d.cts +12 -748
  80. package/dist/paint-editor/index.d.ts +12 -748
  81. package/dist/paint-editor/index.js +77 -78
  82. package/dist/paint-editor/index.js.map +1 -1
  83. package/dist/{pathfinder-7JkMwYvC.d.cts → pathfinder-BHS4vQNm.d.cts} +1 -1
  84. package/dist/{pathfinder-GM3UWdBZ.d.ts → pathfinder-BVvTIBMo.d.ts} +1 -1
  85. package/dist/{pool-CkTxlLMC.d.ts → pool-CZQOrSXZ.d.ts} +1 -1
  86. package/dist/{pool-04qp8iW4.d.cts → pool-FjZZmZ80.d.cts} +1 -1
  87. package/dist/rand-8xbUb6ur.d.ts +1118 -0
  88. package/dist/rand-Cw9VLrVC.d.cts +1118 -0
  89. package/dist/raster/index.cjs +17 -19
  90. package/dist/raster/index.cjs.map +1 -1
  91. package/dist/raster/index.js +9 -11
  92. package/dist/raster/index.js.map +1 -1
  93. package/dist/{svg-rV6_HPmn.d.ts → svg-CSz3mzkw.d.ts} +2 -2
  94. package/dist/{svg-BDDKvWWY.d.cts → svg-DTb40ICU.d.cts} +2 -2
  95. package/dist/{tools-DPYerqeR.d.ts → tools-B0wXP5cF.d.ts} +1 -1
  96. package/dist/{tools-BAjSbTdY.d.cts → tools-Ca0kI1qo.d.cts} +1 -1
  97. package/dist/vector/index.cjs +1459 -1259
  98. package/dist/vector/index.cjs.map +1 -1
  99. package/dist/vector/index.d.cts +87 -11
  100. package/dist/vector/index.d.ts +87 -11
  101. package/dist/vector/index.js +213 -13
  102. package/dist/vector/index.js.map +1 -1
  103. package/dist/video-editor/index.d.cts +4 -4
  104. package/dist/video-editor/index.d.ts +4 -4
  105. package/dist/{warp-DQh9R7Ie.d.cts → warp-DTOp0lON.d.cts} +1 -1
  106. package/dist/{warp-XVL6SpSh.d.ts → warp-pd7hrH4T.d.ts} +1 -1
  107. package/package.json +1 -1
  108. package/skills/pixerate-vector/SKILL.md +8 -0
  109. package/dist/brushstrokeRender-JNHVEUFG.cjs.map +0 -1
  110. package/dist/chunk-2R3UW57U.cjs.map +0 -1
  111. package/dist/chunk-64PYNEHJ.js +0 -340
  112. package/dist/chunk-64PYNEHJ.js.map +0 -1
  113. package/dist/chunk-6GFRKLLS.cjs.map +0 -1
  114. package/dist/chunk-7QN76ESJ.js +0 -323
  115. package/dist/chunk-7QN76ESJ.js.map +0 -1
  116. package/dist/chunk-BR7EKQUP.js.map +0 -1
  117. package/dist/chunk-DCLJNVZS.cjs +0 -323
  118. package/dist/chunk-DCLJNVZS.cjs.map +0 -1
  119. package/dist/chunk-EM3FMJWE.js.map +0 -1
  120. package/dist/chunk-J5BA3BQ6.cjs.map +0 -1
  121. package/dist/chunk-JLGNZMUV.cjs.map +0 -1
  122. package/dist/chunk-MAHQC3SK.js.map +0 -1
  123. package/dist/chunk-Z6OUCS2K.cjs +0 -340
  124. package/dist/chunk-Z6OUCS2K.cjs.map +0 -1
  125. package/dist/rand-BszBST4s.d.ts +0 -2140
  126. package/dist/rand-DOH_aMvm.d.cts +0 -2140
  127. /package/dist/{chunk-62XUO5LB.js.map → chunk-3X6IAJUQ.js.map} +0 -0
  128. /package/dist/{chunk-KZXLZCQ7.js.map → chunk-6S6362D2.js.map} +0 -0
  129. /package/dist/{chunk-SVYE5HIM.js.map → chunk-EQQMGO42.js.map} +0 -0
  130. /package/dist/{chunk-UYQUPUR6.js.map → chunk-HUO3TI4C.js.map} +0 -0
  131. /package/dist/{chunk-2HC4DRF4.js.map → chunk-LLFHCSU2.js.map} +0 -0
  132. /package/dist/{chunk-ILYFOJUN.js.map → chunk-OIBIRXRG.js.map} +0 -0
@@ -17,13 +17,13 @@ import {
17
17
  rand01,
18
18
  rasterizeDab,
19
19
  readPaintSource
20
- } from "./chunk-EM3FMJWE.js";
20
+ } from "./chunk-5FSRTP6E.js";
21
21
  import {
22
22
  TILE,
23
23
  TiledSurface,
24
24
  finishTile,
25
25
  tileKey
26
- } from "./chunk-BR7EKQUP.js";
26
+ } from "./chunk-3G6J7UFV.js";
27
27
 
28
28
  // src/paint-editor/noise.ts
29
29
  function randSigned(seed, index, stream) {
@@ -2073,4 +2073,4 @@ export {
2073
2073
  brushToJSON,
2074
2074
  parseBrushLibrary
2075
2075
  };
2076
- //# sourceMappingURL=chunk-UYQUPUR6.js.map
2076
+ //# sourceMappingURL=chunk-HUO3TI4C.js.map
@@ -74,7 +74,7 @@ function profileAlongPolyline(points, values, count = 32) {
74
74
  var round3 = (v) => Math.round(v * 1e3) / 1e3;
75
75
  var loading = null;
76
76
  function loadCanvasBrushstrokeRenderer() {
77
- loading ??= Promise.resolve().then(() => _interopRequireWildcard(require("./brushstrokeRender-JNHVEUFG.cjs"))).catch((error) => {
77
+ loading ??= Promise.resolve().then(() => _interopRequireWildcard(require("./brushstrokeRender-IMFY3FF6.cjs"))).catch((error) => {
78
78
  loading = null;
79
79
  throw error;
80
80
  });
@@ -109,4 +109,4 @@ async function getBrushedShapeSvg(shape, size, options = {}) {
109
109
 
110
110
 
111
111
  exports.isBrushedShape = isBrushedShape; exports.pathDataToPolyline = pathDataToPolyline; exports.profileAlongPolyline = profileAlongPolyline; exports.loadCanvasBrushstrokeRenderer = loadCanvasBrushstrokeRenderer; exports.listCanvasBrushes = listCanvasBrushes; exports.validateCanvasBrush = validateCanvasBrush; exports.validateCanvasBrushPaint = validateCanvasBrushPaint; exports.renderShapeBrushstroke = renderShapeBrushstroke; exports.getBrushedShapeSvg = getBrushedShapeSvg;
112
- //# sourceMappingURL=chunk-DDSO4HS7.cjs.map
112
+ //# sourceMappingURL=chunk-KEENUAFN.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/chunk-DDSO4HS7.cjs","../src/canvas/brushstroke.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;AC4BO,SAAS,cAAA,CAAe,KAAA,EAAuE;AACrG,EAAA,OAAO,CAAC,CAAC,MAAA,GAAS,KAAA,CAAM,KAAA,IAAS,OAAA,GAAU,CAAC,C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AAA,EACP,CAAC,CAAA;AACD,EAAA,OAAO,OAAA;AACR;AAGA,MAAA,SAAsB,iBAAA,CAAA,EAAkD;AACvE,EAAA,OAAA,CAAQ,MAAM,6BAAA,CAA8B,CAAA,CAAA,CAAG,iBAAA,CAAkB,CAAA;AAClE;AAMA,MAAA,SAAsB,mBAAA,CAAoB,KAAA,EAAmC;AAC5E,EAAA,CAAC,MAAM,6BAAA,CAA8B,CAAA,CAAA,CAAG,kBAAA,CAAmB,KAAA,EAAO,CAAC,CAAA;AACpE;AAMA,MAAA,SAAsB,wBAAA,CAAyB,KAAA,EAAwC;AACtF,EAAA,CAAC,MAAM,6BAAA,CAA8B,CAAA,CAAA,CAAG,kBAAA,CAAmB,KAAK,CAAA;AACjE;AAWA,MAAA,SAAsB,sBAAA,CAAuB,KAAA,EAAyB,QAAA,EAAyC,CAAC,CAAA,EAA2C;AAC1J,EAAA,GAAA,CAAI,CAAC,cAAA,CAAe,KAAK,CAAA,EAAG,OAAO,IAAA;AACnC,EAAA,OAAA,CAAQ,MAAM,6BAAA,CAA8B,CAAA,CAAA,CAAG,yBAAA,CAA0B,KAAA,mBAAO,OAAA,CAAQ,KAAA,UAAS,GAAC,CAAA;AACnG;AAOA,MAAA,SAAsB,kBAAA,CAAmB,KAAA,EAAyB,IAAA,EAAiB,QAAA,EAAyC,CAAC,CAAA,EAA2B;AACvJ,EAAA,GAAA,CAAI,CAAC,cAAA,CAAe,KAAK,CAAA,EAAG,OAAO,IAAA;AACnC,EAAA,OAAA,CAAQ,MAAM,6BAAA,CAA8B,CAAA,CAAA,CAAG,kBAAA,CAAmB,KAAA,EAAO,IAAA,mBAAM,OAAA,CAAQ,KAAA,UAAS,GAAC,CAAA;AAClG;ADvFA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,8dAAC","file":"/home/runner/work/editor/editor/packages/core/dist/chunk-DDSO4HS7.cjs","sourcesContent":[null,"/**\n * Brushed freehand strokes: a path shape with a `brush` keeps its path (selection, editing, eraser\n * hit-testing, grouping and export work as for any path) and is drawn with the paint engine's\n * dry brushstroke renderer instead of an SVG stroke. The renderer, the paint presets and the colour\n * parser live in a separate chunk, loaded the first time a brushed stroke is drawn, so canvases\n * without brushes never load the paint engine.\n */\nimport { brushstrokeScaleBucket } from '../paint/brushstroke-scale.js';\nimport { parseSvgPath, type PathShape, type ShapeDescription, type ShapeSize } from './shapeGeometry.js';\nimport type { Point } from './types.js';\nimport type { CanvasBrush, CanvasBrushPaint, CanvasBrushPreset, CanvasBrushstroke } from './brushTypes.js';\n\nexport type { CanvasBrush, CanvasBrushPaint, CanvasBrushPaintMapping, CanvasBrushPaintStop, CanvasBrushPreset, CanvasBrushSettings, CanvasBrushstroke } from './brushTypes.js';\n\nexport { brushstrokeScaleBucket };\n\n/** A brushed stroke's image, placed in the path's coordinates (the shape's view box). */\nexport interface CanvasBrushstrokeImage {\n\t/** PNG data URL. */\n\thref: string;\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n\t/** Image pixels per path unit. */\n\tscale: number;\n}\n\n/** A path shape with a brush. */\nexport type BrushedPathShape = PathShape & { brush: CanvasBrushstroke };\n\n/** Whether a shape is a brushed stroke. */\nexport function isBrushedShape(shape: ShapeDescription | null | undefined): shape is BrushedPathShape {\n\treturn !!shape && shape.kind === 'path' && !!shape.brush && typeof shape.brush === 'object' && shape.brush.brush != null;\n}\n\n/**\n * The open polyline of a path's first subpath, in path coordinates: lines kept, curves sampled\n * every `step` units or so. Brushed strokes are drawn along it.\n */\nexport function pathDataToPolyline(d: string, step = 2): Point[] {\n\tconst out: Point[] = [];\n\tlet x = 0;\n\tlet y = 0;\n\tlet started = false;\n\tconst push = (px: number, py: number) => {\n\t\tconst last = out[out.length - 1];\n\t\tif (!last || last[0] !== px || last[1] !== py) out.push([px, py]);\n\t};\n\tfor (const c of parseSvgPath(d)) {\n\t\tif (c.type === 'M') {\n\t\t\tif (started) break;\n\t\t\tstarted = true;\n\t\t\tx = c.x;\n\t\t\ty = c.y;\n\t\t\tpush(x, y);\n\t\t} else if (c.type === 'Z') {\n\t\t\tif (out.length) push(out[0][0], out[0][1]);\n\t\t\tbreak;\n\t\t} else if (c.type === 'C' || c.type === 'Q') {\n\t\t\tconst pts = c.type === 'C' ? [[x, y], [c.x1, c.y1], [c.x2, c.y2], [c.x, c.y]] : [[x, y], [c.x1, c.y1], [c.x, c.y]];\n\t\t\tlet hull = 0;\n\t\t\tfor (let i = 1; i < pts.length; i++) hull += Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]);\n\t\t\tconst n = Math.max(1, Math.min(256, Math.ceil(hull / Math.max(0.25, step))));\n\t\t\tfor (let k = 1; k <= n; k++) {\n\t\t\t\tconst t = k / n;\n\t\t\t\tconst u = 1 - t;\n\t\t\t\tif (c.type === 'C') {\n\t\t\t\t\tpush(\n\t\t\t\t\t\tu * u * u * x + 3 * u * u * t * c.x1 + 3 * u * t * t * c.x2 + t * t * t * c.x,\n\t\t\t\t\t\tu * u * u * y + 3 * u * u * t * c.y1 + 3 * u * t * t * c.y2 + t * t * t * c.y\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tpush(u * u * x + 2 * u * t * c.x1 + t * t * c.x, u * u * y + 2 * u * t * c.y1 + t * t * c.y);\n\t\t\t\t}\n\t\t\t}\n\t\t\tx = c.x;\n\t\t\ty = c.y;\n\t\t} else {\n\t\t\t// Lines, and arcs as their chords (freehand paths have none).\n\t\t\tx = c.x;\n\t\t\ty = c.y;\n\t\t\tpush(x, y);\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n * Resamples per-point values into `count` values spread evenly along the polyline's length (the\n * profile a brushed stroke stores). Values are rounded to three decimals.\n */\nexport function profileAlongPolyline(points: readonly Point[], values: readonly number[], count = 32): number[] {\n\tconst n = Math.min(points.length, values.length);\n\tif (n === 0) return [];\n\tif (n === 1) return [round3(values[0])];\n\tconst lengths = [0];\n\tfor (let i = 1; i < n; i++) lengths.push(lengths[i - 1] + Math.hypot(points[i][0] - points[i - 1][0], points[i][1] - points[i - 1][1]));\n\tconst total = lengths[n - 1];\n\tconst m = Math.max(2, Math.min(count, n));\n\tconst out: number[] = [];\n\tlet j = 0;\n\tfor (let k = 0; k < m; k++) {\n\t\tconst at = total > 0 ? (total * k) / (m - 1) : 0;\n\t\twhile (j < n - 2 && lengths[j + 1] < at) j++;\n\t\tconst span = lengths[j + 1] - lengths[j];\n\t\tconst f = span > 0 ? Math.min(1, Math.max(0, (at - lengths[j]) / span)) : 0;\n\t\tout.push(round3(values[j] + (values[j + 1] - values[j]) * f));\n\t}\n\treturn out;\n}\n\nconst round3 = (v: number) => Math.round(v * 1000) / 1000;\n\n// ---------------------------------------------------------------------------\n// The lazily loaded renderer\n// ---------------------------------------------------------------------------\n\n/** The renderer chunk (`./brushstrokeRender.ts`). */\nexport interface CanvasBrushstrokeRenderer {\n\tlistCanvasBrushes(): CanvasBrushPreset[];\n\t/** Throws for an unknown or non-dry brush; the result is the paint engine's brush. */\n\tresolveCanvasBrush(brush: CanvasBrush, width: number): unknown;\n\t/** Throws for paint that is not a colour or gradient paint a canvas stroke can use; the result is the paint engine's `PaintSource`. */\n\tresolveCanvasPaint(paint: unknown): unknown;\n\trenderShapeBrushstrokeNow(shape: BrushedPathShape, scale: number): CanvasBrushstrokeImage | null;\n\tbrushedShapeSvgNow(shape: BrushedPathShape, size: ShapeSize, scale: number): string;\n}\n\nlet loading: Promise<CanvasBrushstrokeRenderer> | null = null;\n\n/**\n * Loads the brushstroke renderer (the paint engine's dry brushes, the paint presets and a CSS\n * colour parser). Called for you by the functions below; call it early to warm up.\n */\nexport function loadCanvasBrushstrokeRenderer(): Promise<CanvasBrushstrokeRenderer> {\n\tloading ??= (import('./brushstrokeRender.js') as Promise<CanvasBrushstrokeRenderer>).catch((error) => {\n\t\tloading = null;\n\t\tthrow error;\n\t});\n\treturn loading;\n}\n\n/** The dry paint presets a freehand stroke can use (wet, mixer, blender, smudge and eraser presets are left out). */\nexport async function listCanvasBrushes(): Promise<CanvasBrushPreset[]> {\n\treturn (await loadCanvasBrushstrokeRenderer()).listCanvasBrushes();\n}\n\n/**\n * Checks a brush: an unknown preset id, a wet (or other non-dry) preset, or settings that are not\n * an object throw an error saying which presets can be used.\n */\nexport async function validateCanvasBrush(brush: CanvasBrush): Promise<void> {\n\t(await loadCanvasBrushstrokeRenderer()).resolveCanvasBrush(brush, 1);\n}\n\n/**\n * Checks a brushed stroke's `paint` (a colour or gradient paint): bad stops, an unknown mapping,\n * or a mapping that needs timed samples (`velocity`, `time`) throw an error saying what to use.\n */\nexport async function validateCanvasBrushPaint(paint: CanvasBrushPaint): Promise<void> {\n\t(await loadCanvasBrushstrokeRenderer()).resolveCanvasPaint(paint);\n}\n\nexport interface RenderShapeBrushstrokeOptions {\n\t/** Image pixels per path unit; pass `brushstrokeScaleBucket(zoom × node scale, devicePixelRatio)` (default 1). */\n\tscale?: number;\n}\n\n/**\n * Renders a brushed path shape to a cached PNG placed in path coordinates, or null for a shape\n * without a brush or an empty path. Throws for an unknown or non-dry brush.\n */\nexport async function renderShapeBrushstroke(shape: ShapeDescription, options: RenderShapeBrushstrokeOptions = {}): Promise<CanvasBrushstrokeImage | null> {\n\tif (!isBrushedShape(shape)) return null;\n\treturn (await loadCanvasBrushstrokeRenderer()).renderShapeBrushstrokeNow(shape, options.scale ?? 1);\n}\n\n/**\n * The brushed stroke as a standalone SVG document of `size` (the node box), with the image\n * embedded as a PNG data URL: what an SVG export writes for the node. Shapes without a brush give\n * null (export them as paths).\n */\nexport async function getBrushedShapeSvg(shape: ShapeDescription, size: ShapeSize, options: RenderShapeBrushstrokeOptions = {}): Promise<string | null> {\n\tif (!isBrushedShape(shape)) return null;\n\treturn (await loadCanvasBrushstrokeRenderer()).brushedShapeSvgNow(shape, size, options.scale ?? 2);\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/chunk-KEENUAFN.cjs","../src/canvas/brushstroke.ts"],"names":[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;ADvFA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,8dAAC","file":"/home/runner/work/editor/editor/packages/core/dist/chunk-KEENUAFN.cjs","sourcesContent":[null,"/**\n * Brushed freehand strokes: a path shape with a `brush` keeps its path (selection, editing, eraser\n * hit-testing, grouping and export work as for any path) and is drawn with the paint engine's\n * dry brushstroke renderer instead of an SVG stroke. The renderer, the paint presets and the colour\n * parser live in a separate chunk, loaded the first time a brushed stroke is drawn, so canvases\n * without brushes never load the paint engine.\n */\nimport { brushstrokeScaleBucket } from '../paint/brushstroke-scale.js';\nimport { parseSvgPath, type PathShape, type ShapeDescription, type ShapeSize } from './shapeGeometry.js';\nimport type { Point } from './types.js';\nimport type { CanvasBrush, CanvasBrushPaint, CanvasBrushPreset, CanvasBrushstroke } from './brushTypes.js';\n\nexport type { CanvasBrush, CanvasBrushPaint, CanvasBrushPaintMapping, CanvasBrushPaintStop, CanvasBrushPreset, CanvasBrushSettings, CanvasBrushstroke } from './brushTypes.js';\n\nexport { brushstrokeScaleBucket };\n\n/** A brushed stroke's image, placed in the path's coordinates (the shape's view box). */\nexport interface CanvasBrushstrokeImage {\n\t/** PNG data URL. */\n\thref: string;\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n\t/** Image pixels per path unit. */\n\tscale: number;\n}\n\n/** A path shape with a brush. */\nexport type BrushedPathShape = PathShape & { brush: CanvasBrushstroke };\n\n/** Whether a shape is a brushed stroke. */\nexport function isBrushedShape(shape: ShapeDescription | null | undefined): shape is BrushedPathShape {\n\treturn !!shape && shape.kind === 'path' && !!shape.brush && typeof shape.brush === 'object' && shape.brush.brush != null;\n}\n\n/**\n * The open polyline of a path's first subpath, in path coordinates: lines kept, curves sampled\n * every `step` units or so. Brushed strokes are drawn along it.\n */\nexport function pathDataToPolyline(d: string, step = 2): Point[] {\n\tconst out: Point[] = [];\n\tlet x = 0;\n\tlet y = 0;\n\tlet started = false;\n\tconst push = (px: number, py: number) => {\n\t\tconst last = out[out.length - 1];\n\t\tif (!last || last[0] !== px || last[1] !== py) out.push([px, py]);\n\t};\n\tfor (const c of parseSvgPath(d)) {\n\t\tif (c.type === 'M') {\n\t\t\tif (started) break;\n\t\t\tstarted = true;\n\t\t\tx = c.x;\n\t\t\ty = c.y;\n\t\t\tpush(x, y);\n\t\t} else if (c.type === 'Z') {\n\t\t\tif (out.length) push(out[0][0], out[0][1]);\n\t\t\tbreak;\n\t\t} else if (c.type === 'C' || c.type === 'Q') {\n\t\t\tconst pts = c.type === 'C' ? [[x, y], [c.x1, c.y1], [c.x2, c.y2], [c.x, c.y]] : [[x, y], [c.x1, c.y1], [c.x, c.y]];\n\t\t\tlet hull = 0;\n\t\t\tfor (let i = 1; i < pts.length; i++) hull += Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]);\n\t\t\tconst n = Math.max(1, Math.min(256, Math.ceil(hull / Math.max(0.25, step))));\n\t\t\tfor (let k = 1; k <= n; k++) {\n\t\t\t\tconst t = k / n;\n\t\t\t\tconst u = 1 - t;\n\t\t\t\tif (c.type === 'C') {\n\t\t\t\t\tpush(\n\t\t\t\t\t\tu * u * u * x + 3 * u * u * t * c.x1 + 3 * u * t * t * c.x2 + t * t * t * c.x,\n\t\t\t\t\t\tu * u * u * y + 3 * u * u * t * c.y1 + 3 * u * t * t * c.y2 + t * t * t * c.y\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tpush(u * u * x + 2 * u * t * c.x1 + t * t * c.x, u * u * y + 2 * u * t * c.y1 + t * t * c.y);\n\t\t\t\t}\n\t\t\t}\n\t\t\tx = c.x;\n\t\t\ty = c.y;\n\t\t} else {\n\t\t\t// Lines, and arcs as their chords (freehand paths have none).\n\t\t\tx = c.x;\n\t\t\ty = c.y;\n\t\t\tpush(x, y);\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n * Resamples per-point values into `count` values spread evenly along the polyline's length (the\n * profile a brushed stroke stores). Values are rounded to three decimals.\n */\nexport function profileAlongPolyline(points: readonly Point[], values: readonly number[], count = 32): number[] {\n\tconst n = Math.min(points.length, values.length);\n\tif (n === 0) return [];\n\tif (n === 1) return [round3(values[0])];\n\tconst lengths = [0];\n\tfor (let i = 1; i < n; i++) lengths.push(lengths[i - 1] + Math.hypot(points[i][0] - points[i - 1][0], points[i][1] - points[i - 1][1]));\n\tconst total = lengths[n - 1];\n\tconst m = Math.max(2, Math.min(count, n));\n\tconst out: number[] = [];\n\tlet j = 0;\n\tfor (let k = 0; k < m; k++) {\n\t\tconst at = total > 0 ? (total * k) / (m - 1) : 0;\n\t\twhile (j < n - 2 && lengths[j + 1] < at) j++;\n\t\tconst span = lengths[j + 1] - lengths[j];\n\t\tconst f = span > 0 ? Math.min(1, Math.max(0, (at - lengths[j]) / span)) : 0;\n\t\tout.push(round3(values[j] + (values[j + 1] - values[j]) * f));\n\t}\n\treturn out;\n}\n\nconst round3 = (v: number) => Math.round(v * 1000) / 1000;\n\n// ---------------------------------------------------------------------------\n// The lazily loaded renderer\n// ---------------------------------------------------------------------------\n\n/** The renderer chunk (`./brushstrokeRender.ts`). */\nexport interface CanvasBrushstrokeRenderer {\n\tlistCanvasBrushes(): CanvasBrushPreset[];\n\t/** Throws for an unknown or non-dry brush; the result is the paint engine's brush. */\n\tresolveCanvasBrush(brush: CanvasBrush, width: number): unknown;\n\t/** Throws for paint that is not a colour or gradient paint a canvas stroke can use; the result is the paint engine's `PaintSource`. */\n\tresolveCanvasPaint(paint: unknown): unknown;\n\trenderShapeBrushstrokeNow(shape: BrushedPathShape, scale: number): CanvasBrushstrokeImage | null;\n\tbrushedShapeSvgNow(shape: BrushedPathShape, size: ShapeSize, scale: number): string;\n}\n\nlet loading: Promise<CanvasBrushstrokeRenderer> | null = null;\n\n/**\n * Loads the brushstroke renderer (the paint engine's dry brushes, the paint presets and a CSS\n * colour parser). Called for you by the functions below; call it early to warm up.\n */\nexport function loadCanvasBrushstrokeRenderer(): Promise<CanvasBrushstrokeRenderer> {\n\tloading ??= (import('./brushstrokeRender.js') as Promise<CanvasBrushstrokeRenderer>).catch((error) => {\n\t\tloading = null;\n\t\tthrow error;\n\t});\n\treturn loading;\n}\n\n/** The dry paint presets a freehand stroke can use (wet, mixer, blender, smudge and eraser presets are left out). */\nexport async function listCanvasBrushes(): Promise<CanvasBrushPreset[]> {\n\treturn (await loadCanvasBrushstrokeRenderer()).listCanvasBrushes();\n}\n\n/**\n * Checks a brush: an unknown preset id, a wet (or other non-dry) preset, or settings that are not\n * an object throw an error saying which presets can be used.\n */\nexport async function validateCanvasBrush(brush: CanvasBrush): Promise<void> {\n\t(await loadCanvasBrushstrokeRenderer()).resolveCanvasBrush(brush, 1);\n}\n\n/**\n * Checks a brushed stroke's `paint` (a colour or gradient paint): bad stops, an unknown mapping,\n * or a mapping that needs timed samples (`velocity`, `time`) throw an error saying what to use.\n */\nexport async function validateCanvasBrushPaint(paint: CanvasBrushPaint): Promise<void> {\n\t(await loadCanvasBrushstrokeRenderer()).resolveCanvasPaint(paint);\n}\n\nexport interface RenderShapeBrushstrokeOptions {\n\t/** Image pixels per path unit; pass `brushstrokeScaleBucket(zoom × node scale, devicePixelRatio)` (default 1). */\n\tscale?: number;\n}\n\n/**\n * Renders a brushed path shape to a cached PNG placed in path coordinates, or null for a shape\n * without a brush or an empty path. Throws for an unknown or non-dry brush.\n */\nexport async function renderShapeBrushstroke(shape: ShapeDescription, options: RenderShapeBrushstrokeOptions = {}): Promise<CanvasBrushstrokeImage | null> {\n\tif (!isBrushedShape(shape)) return null;\n\treturn (await loadCanvasBrushstrokeRenderer()).renderShapeBrushstrokeNow(shape, options.scale ?? 1);\n}\n\n/**\n * The brushed stroke as a standalone SVG document of `size` (the node box), with the image\n * embedded as a PNG data URL: what an SVG export writes for the node. Shapes without a brush give\n * null (export them as paths).\n */\nexport async function getBrushedShapeSvg(shape: ShapeDescription, size: ShapeSize, options: RenderShapeBrushstrokeOptions = {}): Promise<string | null> {\n\tif (!isBrushedShape(shape)) return null;\n\treturn (await loadCanvasBrushstrokeRenderer()).brushedShapeSvgNow(shape, size, options.scale ?? 2);\n}\n"]}
@@ -34,7 +34,7 @@ import {
34
34
  translateSurface,
35
35
  writeDeepRegion,
36
36
  writeRegion
37
- } from "./chunk-BR7EKQUP.js";
37
+ } from "./chunk-3G6J7UFV.js";
38
38
 
39
39
  // src/raster/effects/model.ts
40
40
  var DEFAULT_GLOBAL_LIGHT = { angle: 120, altitude: 30 };
@@ -4314,4 +4314,4 @@ export {
4314
4314
  warpSurface,
4315
4315
  compositeSurfaceOver
4316
4316
  };
4317
- //# sourceMappingURL=chunk-2HC4DRF4.js.map
4317
+ //# sourceMappingURL=chunk-LLFHCSU2.js.map
@@ -1,4 +1,9 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;// src/raster/pigment.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
2
+
3
+
4
+ var _chunk643B2HKCcjs = require('./chunk-643B2HKC.cjs');
5
+
6
+ // src/raster/pigment.ts
2
7
  var PIGMENT_BANDS = 36;
3
8
  var PIGMENT_LAMBDA_MIN = 380;
4
9
  var PIGMENT_LAMBDA_STEP = 10;
@@ -1336,6 +1341,321 @@ function keepDeepSamples(before, after) {
1336
1341
  return tiles ? new TiledSurface(ch, tiles, after.defaultValue) : after;
1337
1342
  }
1338
1343
 
1344
+ // src/raster/png.ts
1345
+ var SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10];
1346
+ var crcTable = null;
1347
+ function crc32(bytes, start, end) {
1348
+ if (!crcTable) {
1349
+ crcTable = new Uint32Array(256);
1350
+ for (let n = 0; n < 256; n++) {
1351
+ let c2 = n;
1352
+ for (let k = 0; k < 8; k++) c2 = c2 & 1 ? 3988292384 ^ c2 >>> 1 : c2 >>> 1;
1353
+ crcTable[n] = c2 >>> 0;
1354
+ }
1355
+ }
1356
+ let c = 4294967295;
1357
+ for (let i = start; i < end; i++) c = crcTable[(c ^ bytes[i]) & 255] ^ c >>> 8;
1358
+ return (c ^ 4294967295) >>> 0;
1359
+ }
1360
+ function paeth(a, b, c) {
1361
+ const p = a + b - c;
1362
+ const pa = Math.abs(p - a);
1363
+ const pb = Math.abs(p - b);
1364
+ const pc = Math.abs(p - c);
1365
+ return pa <= pb && pa <= pc ? a : pb <= pc ? b : c;
1366
+ }
1367
+ function encodePng(width, height, data, channels = 4) {
1368
+ const stride = width * channels;
1369
+ const raw = new Uint8Array((stride + 1) * height);
1370
+ const bpp = channels;
1371
+ const cand = [new Uint8Array(stride), new Uint8Array(stride), new Uint8Array(stride), new Uint8Array(stride), new Uint8Array(stride)];
1372
+ for (let y = 0; y < height; y++) {
1373
+ const row = y * stride;
1374
+ const prevRow = (y - 1) * stride;
1375
+ let best = 0;
1376
+ let bestScore = Infinity;
1377
+ for (let f = 0; f < 5; f++) {
1378
+ const out2 = cand[f];
1379
+ let score = 0;
1380
+ for (let x = 0; x < stride; x++) {
1381
+ const v = data[row + x];
1382
+ const a = x >= bpp ? data[row + x - bpp] : 0;
1383
+ const b = y > 0 ? data[prevRow + x] : 0;
1384
+ const c = x >= bpp && y > 0 ? data[prevRow + x - bpp] : 0;
1385
+ let r;
1386
+ switch (f) {
1387
+ case 0:
1388
+ r = v;
1389
+ break;
1390
+ case 1:
1391
+ r = v - a;
1392
+ break;
1393
+ case 2:
1394
+ r = v - b;
1395
+ break;
1396
+ case 3:
1397
+ r = v - (a + b >> 1);
1398
+ break;
1399
+ default:
1400
+ r = v - paeth(a, b, c);
1401
+ }
1402
+ r &= 255;
1403
+ out2[x] = r;
1404
+ score += r < 128 ? r : 256 - r;
1405
+ if (score >= bestScore) break;
1406
+ }
1407
+ if (score < bestScore) {
1408
+ bestScore = score;
1409
+ best = f;
1410
+ }
1411
+ }
1412
+ const o = y * (stride + 1);
1413
+ raw[o] = best;
1414
+ raw.set(cand[best], o + 1);
1415
+ }
1416
+ const idat = _chunk643B2HKCcjs.deflate.call(void 0, raw);
1417
+ const chunks = [];
1418
+ const ihdr = new Uint8Array(13);
1419
+ writeU32(ihdr, 0, width);
1420
+ writeU32(ihdr, 4, height);
1421
+ ihdr[8] = 8;
1422
+ ihdr[9] = channels === 1 ? 0 : 6;
1423
+ chunks.push(["IHDR", ihdr], ["IDAT", idat], ["IEND", new Uint8Array(0)]);
1424
+ let size = 8;
1425
+ for (const [, d] of chunks) size += 12 + d.length;
1426
+ const out = new Uint8Array(size);
1427
+ out.set(SIGNATURE, 0);
1428
+ let p = 8;
1429
+ for (const [type, d] of chunks) {
1430
+ writeU32(out, p, d.length);
1431
+ for (let i = 0; i < 4; i++) out[p + 4 + i] = type.charCodeAt(i);
1432
+ out.set(d, p + 8);
1433
+ writeU32(out, p + 8 + d.length, crc32(out, p + 4, p + 8 + d.length));
1434
+ p += 12 + d.length;
1435
+ }
1436
+ return out;
1437
+ }
1438
+ function writeU32(b, o, v) {
1439
+ b[o] = v >>> 24;
1440
+ b[o + 1] = v >>> 16 & 255;
1441
+ b[o + 2] = v >>> 8 & 255;
1442
+ b[o + 3] = v & 255;
1443
+ }
1444
+ function readU32(b, o) {
1445
+ return (b[o] << 24 | b[o + 1] << 16 | b[o + 2] << 8 | b[o + 3]) >>> 0;
1446
+ }
1447
+ function isPng(bytes) {
1448
+ return bytes.length > 8 && SIGNATURE.every((v, i) => bytes[i] === v);
1449
+ }
1450
+ function decodePng(bytes, options = {}) {
1451
+ if (!isPng(bytes)) throw new Error("Not a PNG image.");
1452
+ let p = 8;
1453
+ let width = 0;
1454
+ let height = 0;
1455
+ let depth = 0;
1456
+ let type = 0;
1457
+ let interlace = 0;
1458
+ let palette = null;
1459
+ let trns = null;
1460
+ const idat = [];
1461
+ while (p + 8 <= bytes.length) {
1462
+ const len = readU32(bytes, p);
1463
+ const t = String.fromCharCode(bytes[p + 4], bytes[p + 5], bytes[p + 6], bytes[p + 7]);
1464
+ const body = bytes.subarray(p + 8, p + 8 + len);
1465
+ if (p + 12 + len > bytes.length) throw new Error("Truncated PNG.");
1466
+ if (t === "IHDR") {
1467
+ width = readU32(body, 0);
1468
+ height = readU32(body, 4);
1469
+ depth = body[8];
1470
+ type = body[9];
1471
+ interlace = body[12];
1472
+ } else if (t === "PLTE") palette = body;
1473
+ else if (t === "tRNS") trns = body;
1474
+ else if (t === "IDAT") idat.push(body);
1475
+ else if (t === "IEND") break;
1476
+ p += 12 + len;
1477
+ }
1478
+ if (!width || !height) throw new Error("PNG has no image header.");
1479
+ if (interlace) throw new Error("Interlaced PNGs are not supported here; decode them with a canvas.");
1480
+ const maxPixels = _nullishCoalesce(options.maxPixels, () => ( 1 << 28));
1481
+ if (width * height > maxPixels) throw new Error(`PNG is too large (${width}\xD7${height}).`);
1482
+ const samples = type === 0 ? 1 : type === 2 ? 3 : type === 3 ? 1 : type === 4 ? 2 : type === 6 ? 4 : 0;
1483
+ if (!samples || ![1, 2, 4, 8, 16].includes(depth)) throw new Error(`Unsupported PNG format (type ${type}, depth ${depth}).`);
1484
+ let total = 0;
1485
+ for (const c of idat) total += c.length;
1486
+ const z = new Uint8Array(total);
1487
+ let o = 0;
1488
+ for (const c of idat) {
1489
+ z.set(c, o);
1490
+ o += c.length;
1491
+ }
1492
+ const bitsPerPixel = samples * depth;
1493
+ const stride = Math.ceil(width * bitsPerPixel / 8);
1494
+ const raw = _chunk643B2HKCcjs.inflate.call(void 0, z, { maxOutput: (stride + 1) * height, sizeHint: (stride + 1) * height });
1495
+ if (raw.length < (stride + 1) * height) throw new Error("PNG image data is truncated.");
1496
+ const bpp = Math.max(1, bitsPerPixel >> 3);
1497
+ const lines = new Uint8Array(stride * height);
1498
+ for (let y = 0; y < height; y++) {
1499
+ const f = raw[y * (stride + 1)];
1500
+ const src = y * (stride + 1) + 1;
1501
+ const dst = y * stride;
1502
+ const up = dst - stride;
1503
+ for (let x = 0; x < stride; x++) {
1504
+ const v = raw[src + x];
1505
+ const a = x >= bpp ? lines[dst + x - bpp] : 0;
1506
+ const b = y > 0 ? lines[up + x] : 0;
1507
+ const c = x >= bpp && y > 0 ? lines[up + x - bpp] : 0;
1508
+ let r;
1509
+ switch (f) {
1510
+ case 0:
1511
+ r = v;
1512
+ break;
1513
+ case 1:
1514
+ r = v + a;
1515
+ break;
1516
+ case 2:
1517
+ r = v + b;
1518
+ break;
1519
+ case 3:
1520
+ r = v + (a + b >> 1);
1521
+ break;
1522
+ case 4:
1523
+ r = v + paeth(a, b, c);
1524
+ break;
1525
+ default:
1526
+ throw new Error(`Invalid PNG filter ${f}.`);
1527
+ }
1528
+ lines[dst + x] = r & 255;
1529
+ }
1530
+ }
1531
+ const sample = (y, i) => {
1532
+ const row = y * stride;
1533
+ if (depth === 8) return lines[row + i];
1534
+ if (depth === 16) return lines[row + i * 2];
1535
+ const perByte = 8 / depth;
1536
+ const byte = lines[row + Math.floor(i / perByte)];
1537
+ const shift = 8 - depth * (i % perByte + 1);
1538
+ const v = byte >> shift & (1 << depth) - 1;
1539
+ return type === 3 ? v : Math.round(v * 255 / ((1 << depth) - 1));
1540
+ };
1541
+ const gray = options.keepGray && type === 0 && !trns;
1542
+ const channels = gray ? 1 : 4;
1543
+ const out = new Uint8ClampedArray(width * height * channels);
1544
+ const trnsGray = trns && type === 0 ? depth === 16 ? trns[0] : sample16(trns, 0, depth) : -1;
1545
+ const trnsRgb = trns && type === 2 ? [0, 1, 2].map((k) => depth === 16 ? trns[k * 2] : sample16(trns, k, depth)) : null;
1546
+ for (let y = 0; y < height; y++) {
1547
+ for (let x = 0; x < width; x++) {
1548
+ const d = (y * width + x) * channels;
1549
+ if (type === 0) {
1550
+ const v = sample(y, x);
1551
+ if (gray) out[d] = v;
1552
+ else {
1553
+ out[d] = out[d + 1] = out[d + 2] = v;
1554
+ out[d + 3] = v === trnsGray && trns ? 0 : 255;
1555
+ }
1556
+ } else if (type === 2) {
1557
+ const r = sample(y, x * 3);
1558
+ const g = sample(y, x * 3 + 1);
1559
+ const b = sample(y, x * 3 + 2);
1560
+ out[d] = r;
1561
+ out[d + 1] = g;
1562
+ out[d + 2] = b;
1563
+ out[d + 3] = trnsRgb && r === trnsRgb[0] && g === trnsRgb[1] && b === trnsRgb[2] ? 0 : 255;
1564
+ } else if (type === 3) {
1565
+ const i = sample(y, x);
1566
+ if (!palette || i * 3 + 2 >= palette.length) throw new Error("PNG palette index out of range.");
1567
+ out[d] = palette[i * 3];
1568
+ out[d + 1] = palette[i * 3 + 1];
1569
+ out[d + 2] = palette[i * 3 + 2];
1570
+ out[d + 3] = trns && i < trns.length ? trns[i] : 255;
1571
+ } else if (type === 4) {
1572
+ const v = sample(y, x * 2);
1573
+ out[d] = out[d + 1] = out[d + 2] = v;
1574
+ out[d + 3] = sample(y, x * 2 + 1);
1575
+ } else {
1576
+ out[d] = sample(y, x * 4);
1577
+ out[d + 1] = sample(y, x * 4 + 1);
1578
+ out[d + 2] = sample(y, x * 4 + 2);
1579
+ out[d + 3] = sample(y, x * 4 + 3);
1580
+ }
1581
+ }
1582
+ }
1583
+ return { width, height, channels, data: out };
1584
+ }
1585
+ function sample16(trns, k, depth) {
1586
+ const v = trns[k * 2] << 8 | trns[k * 2 + 1];
1587
+ if (depth === 8) return v & 255;
1588
+ return Math.round((v & (1 << depth) - 1) * 255 / ((1 << depth) - 1));
1589
+ }
1590
+ var B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1591
+ var B64_INV = null;
1592
+ function bytesToBase64(bytes) {
1593
+ const parts = [];
1594
+ const CHUNK = 3 * 4096;
1595
+ for (let start = 0; start < bytes.length; start += CHUNK) {
1596
+ const end = Math.min(bytes.length, start + CHUNK);
1597
+ let s = "";
1598
+ let i = start;
1599
+ for (; i + 2 < end; i += 3) {
1600
+ const n = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2];
1601
+ s += B64[n >> 18] + B64[n >> 12 & 63] + B64[n >> 6 & 63] + B64[n & 63];
1602
+ }
1603
+ if (i < end) {
1604
+ const n = bytes[i] << 16 | (i + 1 < end ? bytes[i + 1] << 8 : 0);
1605
+ s += B64[n >> 18] + B64[n >> 12 & 63] + (i + 1 < end ? B64[n >> 6 & 63] : "=") + "=";
1606
+ }
1607
+ parts.push(s);
1608
+ }
1609
+ return parts.join("");
1610
+ }
1611
+ function base64ToBytes(text) {
1612
+ if (!B64_INV) {
1613
+ B64_INV = new Int16Array(128).fill(-1);
1614
+ for (let i = 0; i < 64; i++) B64_INV[B64.charCodeAt(i)] = i;
1615
+ B64_INV["-".charCodeAt(0)] = 62;
1616
+ B64_INV["_".charCodeAt(0)] = 63;
1617
+ }
1618
+ const inv = B64_INV;
1619
+ const clean = text.replace(/[\s=]/g, "");
1620
+ const out = new Uint8Array(Math.floor(clean.length * 3 / 4));
1621
+ let bits = 0;
1622
+ let acc = 0;
1623
+ let o = 0;
1624
+ for (let i = 0; i < clean.length; i++) {
1625
+ const c = clean.charCodeAt(i);
1626
+ const v = c < 128 ? inv[c] : -1;
1627
+ if (v < 0) throw new Error("Invalid base64 data.");
1628
+ acc = acc << 6 | v;
1629
+ bits += 6;
1630
+ if (bits >= 8) {
1631
+ bits -= 8;
1632
+ out[o++] = acc >> bits & 255;
1633
+ }
1634
+ }
1635
+ return out.subarray(0, o);
1636
+ }
1637
+ function parseDataUrl(url) {
1638
+ const m = /^data:([^;,]*)((?:;[^;,]*)*?),/i.exec(url);
1639
+ if (!m) return null;
1640
+ const body = url.slice(m[0].length);
1641
+ const isBase64 = /;base64/i.test(m[2]);
1642
+ if (isBase64) return { mime: m[1] || "text/plain", bytes: base64ToBytes(body) };
1643
+ const text = decodeURIComponent(body);
1644
+ const bytes = new Uint8Array(text.length);
1645
+ for (let i = 0; i < text.length; i++) bytes[i] = text.charCodeAt(i) & 255;
1646
+ return { mime: m[1] || "text/plain", bytes };
1647
+ }
1648
+ function pngDataUrl(width, height, data, channels = 4) {
1649
+ return `data:image/png;base64,${bytesToBase64(encodePng(width, height, data, channels))}`;
1650
+ }
1651
+
1652
+
1653
+
1654
+
1655
+
1656
+
1657
+
1658
+
1339
1659
 
1340
1660
 
1341
1661
 
@@ -1412,5 +1732,5 @@ function keepDeepSamples(before, after) {
1412
1732
 
1413
1733
 
1414
1734
 
1415
- exports.PIGMENT_BANDS = PIGMENT_BANDS; exports.PIGMENT_LAMBDA_MIN = PIGMENT_LAMBDA_MIN; exports.PIGMENT_LAMBDA_STEP = PIGMENT_LAMBDA_STEP; exports.PIGMENT_WAVELENGTHS = PIGMENT_WAVELENGTHS; exports.rgbToReflectance = rgbToReflectance; exports.reflectanceToRgb = reflectanceToRgb; exports.createPigment = createPigment; exports.setPigmentColor = setPigmentColor; exports.mixPigments = mixPigments; exports.lerpPigment = lerpPigment; exports.lerpPigmentInto = lerpPigmentInto; exports.BLEND_MODES = BLEND_MODES; exports.isBlendMode = isBlendMode; exports.PAINTERLY_BLEND_MODES = PAINTERLY_BLEND_MODES; exports.isPainterlyBlendMode = isPainterlyBlendMode; exports.standardBlendMode = standardBlendMode; exports.normalizeBlendMode = normalizeBlendMode; exports.canvasCompositeOperation = canvasCompositeOperation; exports.isSeparableBlendMode = isSeparableBlendMode; exports.blendChannel = blendChannel; exports.blendLum = blendLum; exports.setLum = setLum; exports.blendRgb = blendRgb; exports.SHADOW_AMBIENT = SHADOW_AMBIENT; exports.mixPigmentRgb = mixPigmentRgb; exports.pigment8 = pigment8; exports.mixPigment8 = mixPigment8; exports.blendPixel = blendPixel; exports.blendImageData = blendImageData; exports.TILE = TILE; exports.TILE_SHIFT = TILE_SHIFT; exports.tileKey = tileKey; exports.tileCoord = tileCoord; exports.tileRect = tileRect; exports.TiledSurface = TiledSurface; exports.uniformTile = uniformTile; exports.packRgba = packRgba; exports.finishTile = finishTile; exports.emptySurface = emptySurface; exports.solidSurface = solidSurface; exports.surfaceFromPixels = surfaceFromPixels; exports.tilesInRect = tilesInRect; exports.readRegion = readRegion; exports.readPixel = readPixel; exports.contentBounds = contentBounds; exports.SurfaceDraft = SurfaceDraft; exports.writeRegion = writeRegion; exports.fillRect = fillRect; exports.translateSurface = translateSurface; exports.surfaceBytes = surfaceBytes; exports.collectTiles = collectTiles; exports.surfacesEqual = surfacesEqual; exports.BIT_DEPTHS = BIT_DEPTHS; exports.isBitDepth = isBitDepth; exports.srgbDecode = srgbDecode; exports.srgbEncode = srgbEncode; exports.to16From8 = to16From8; exports.to32From8 = to32From8; exports.to32From16 = to32From16; exports.to16From32 = to16From32; exports.to8From16 = to8From16; exports.to8From32 = to8From32; exports.proxyOf = proxyOf; exports.depthOf = depthOf; exports.deepTile = deepTile; exports.tileSamples16 = tileSamples16; exports.tileSamples32 = tileSamples32; exports.tileSamples = tileSamples; exports.surfaceDepth = surfaceDepth; exports.readDeepRegion = readDeepRegion; exports.writeDeepRegion = writeDeepRegion; exports.surfaceFromDeepPixels = surfaceFromDeepPixels; exports.convertSurfaceDepth = convertSurfaceDepth; exports.deepBytes = deepBytes; exports.keepDeepSamples = keepDeepSamples;
1416
- //# sourceMappingURL=chunk-J5BA3BQ6.cjs.map
1735
+ exports.PIGMENT_BANDS = PIGMENT_BANDS; exports.PIGMENT_LAMBDA_MIN = PIGMENT_LAMBDA_MIN; exports.PIGMENT_LAMBDA_STEP = PIGMENT_LAMBDA_STEP; exports.PIGMENT_WAVELENGTHS = PIGMENT_WAVELENGTHS; exports.rgbToReflectance = rgbToReflectance; exports.reflectanceToRgb = reflectanceToRgb; exports.createPigment = createPigment; exports.setPigmentColor = setPigmentColor; exports.mixPigments = mixPigments; exports.lerpPigment = lerpPigment; exports.lerpPigmentInto = lerpPigmentInto; exports.BLEND_MODES = BLEND_MODES; exports.isBlendMode = isBlendMode; exports.PAINTERLY_BLEND_MODES = PAINTERLY_BLEND_MODES; exports.isPainterlyBlendMode = isPainterlyBlendMode; exports.standardBlendMode = standardBlendMode; exports.normalizeBlendMode = normalizeBlendMode; exports.canvasCompositeOperation = canvasCompositeOperation; exports.isSeparableBlendMode = isSeparableBlendMode; exports.blendChannel = blendChannel; exports.blendLum = blendLum; exports.setLum = setLum; exports.blendRgb = blendRgb; exports.SHADOW_AMBIENT = SHADOW_AMBIENT; exports.mixPigmentRgb = mixPigmentRgb; exports.pigment8 = pigment8; exports.mixPigment8 = mixPigment8; exports.blendPixel = blendPixel; exports.blendImageData = blendImageData; exports.TILE = TILE; exports.TILE_SHIFT = TILE_SHIFT; exports.tileKey = tileKey; exports.tileCoord = tileCoord; exports.tileRect = tileRect; exports.TiledSurface = TiledSurface; exports.uniformTile = uniformTile; exports.packRgba = packRgba; exports.finishTile = finishTile; exports.emptySurface = emptySurface; exports.solidSurface = solidSurface; exports.surfaceFromPixels = surfaceFromPixels; exports.tilesInRect = tilesInRect; exports.readRegion = readRegion; exports.readPixel = readPixel; exports.contentBounds = contentBounds; exports.SurfaceDraft = SurfaceDraft; exports.writeRegion = writeRegion; exports.fillRect = fillRect; exports.translateSurface = translateSurface; exports.surfaceBytes = surfaceBytes; exports.collectTiles = collectTiles; exports.surfacesEqual = surfacesEqual; exports.BIT_DEPTHS = BIT_DEPTHS; exports.isBitDepth = isBitDepth; exports.srgbDecode = srgbDecode; exports.srgbEncode = srgbEncode; exports.to16From8 = to16From8; exports.to32From8 = to32From8; exports.to32From16 = to32From16; exports.to16From32 = to16From32; exports.to8From16 = to8From16; exports.to8From32 = to8From32; exports.proxyOf = proxyOf; exports.depthOf = depthOf; exports.deepTile = deepTile; exports.tileSamples16 = tileSamples16; exports.tileSamples32 = tileSamples32; exports.tileSamples = tileSamples; exports.surfaceDepth = surfaceDepth; exports.readDeepRegion = readDeepRegion; exports.writeDeepRegion = writeDeepRegion; exports.surfaceFromDeepPixels = surfaceFromDeepPixels; exports.convertSurfaceDepth = convertSurfaceDepth; exports.deepBytes = deepBytes; exports.keepDeepSamples = keepDeepSamples; exports.encodePng = encodePng; exports.isPng = isPng; exports.decodePng = decodePng; exports.bytesToBase64 = bytesToBase64; exports.base64ToBytes = base64ToBytes; exports.parseDataUrl = parseDataUrl; exports.pngDataUrl = pngDataUrl;
1736
+ //# sourceMappingURL=chunk-O7LUD7MH.cjs.map