@pixerate/editor 0.266.2 → 0.268.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 (149) hide show
  1. package/dist/agent/index.cjs +2 -2
  2. package/dist/agent/index.js +1 -1
  3. package/dist/animation-editor/controller.d.cts +8 -0
  4. package/dist/animation-editor/controller.d.ts +8 -0
  5. package/dist/animation-editor/effect-tools.d.cts +1 -1
  6. package/dist/animation-editor/effect-tools.d.ts +1 -1
  7. package/dist/animation-editor/index.cjs +175 -108
  8. package/dist/animation-editor/index.js +94 -27
  9. package/dist/brushes/index.cjs +201 -75
  10. package/dist/brushes/index.d.cts +4 -3
  11. package/dist/brushes/index.d.ts +4 -3
  12. package/dist/brushes/index.js +138 -12
  13. package/dist/brushes/library.d.cts +27 -1
  14. package/dist/brushes/library.d.ts +27 -1
  15. package/dist/brushes/profiles.d.cts +10 -1
  16. package/dist/brushes/profiles.d.ts +10 -1
  17. package/dist/brushes/schema.d.cts +4 -0
  18. package/dist/brushes/schema.d.ts +4 -0
  19. package/dist/brushes/sources.d.cts +114 -0
  20. package/dist/brushes/sources.d.ts +114 -0
  21. package/dist/brushes/types.d.cts +37 -5
  22. package/dist/brushes/types.d.ts +37 -5
  23. package/dist/brushes/ui.d.cts +40 -4
  24. package/dist/brushes/ui.d.ts +40 -4
  25. package/dist/{brushstrokeRender-KD453OBX.js → brushstrokeRender-A727TTNQ.js} +7 -7
  26. package/dist/{brushstrokeRender-FSUWXUZY.cjs → brushstrokeRender-WR2N5HHY.cjs} +23 -23
  27. package/dist/canvas/brushTypes.d.cts +12 -0
  28. package/dist/canvas/brushTypes.d.ts +12 -0
  29. package/dist/canvas/brushstroke.d.cts +1 -1
  30. package/dist/canvas/brushstroke.d.ts +1 -1
  31. package/dist/canvas/drawController.d.cts +19 -4
  32. package/dist/canvas/drawController.d.ts +19 -4
  33. package/dist/canvas/index.cjs +144 -105
  34. package/dist/canvas/index.js +46 -7
  35. package/dist/{chunk-TOID45I2.cjs → chunk-2WOGXEDX.cjs} +1 -1
  36. package/dist/{chunk-XORJ7UZO.cjs → chunk-3VHH6V67.cjs} +13 -12
  37. package/dist/{chunk-3C33YTNN.js → chunk-3XDSNIGF.js} +73 -6
  38. package/dist/chunk-62MFUHSI.cjs +802 -0
  39. package/dist/{chunk-R44Y3EFS.js → chunk-74ODPZLX.js} +17 -345
  40. package/dist/{chunk-GCVFEPJG.js → chunk-ACTHSQOI.js} +182 -0
  41. package/dist/chunk-ADMRNWR7.js +340 -0
  42. package/dist/{chunk-MVUQSK5J.cjs → chunk-B3G7BKUV.cjs} +111 -439
  43. package/dist/{chunk-DXYHQ2VN.js → chunk-BAZMCFVL.js} +1 -1
  44. package/dist/{chunk-VRK322ZC.cjs → chunk-BPJSI4NT.cjs} +2 -2
  45. package/dist/{chunk-RFJZGTHA.cjs → chunk-EU2ZZA6L.cjs} +400 -69
  46. package/dist/{chunk-XC6DPRYI.js → chunk-GSTSZPSR.js} +154 -949
  47. package/dist/{chunk-EZOJBP4D.js → chunk-HFY5LG5J.js} +1 -1
  48. package/dist/chunk-HVO6XCI4.js +802 -0
  49. package/dist/{chunk-YHDHFJUC.cjs → chunk-J5VQYK7T.cjs} +217 -1012
  50. package/dist/{chunk-XRXFVRGY.cjs → chunk-JBB3GDBB.cjs} +2483 -208
  51. package/dist/{chunk-ACFSFUQH.js → chunk-JL6YH5WD.js} +4 -0
  52. package/dist/{chunk-CIJBSUM5.js → chunk-KZI3YWKW.js} +353 -22
  53. package/dist/{chunk-4ODRXQRW.js → chunk-LETF75CA.js} +1 -1
  54. package/dist/{chunk-FQPUF2W2.cjs → chunk-NIBFKXMD.cjs} +217 -35
  55. package/dist/{chunk-AQZQWXEU.cjs → chunk-NPWWSCWT.cjs} +35 -35
  56. package/dist/{chunk-DOZ6F2K2.js → chunk-NSETJI74.js} +3 -2
  57. package/dist/{chunk-PE6YJMQT.cjs → chunk-PFHJS4HE.cjs} +20 -19
  58. package/dist/{chunk-7KNW3WXZ.cjs → chunk-QEVLRLUN.cjs} +63 -0
  59. package/dist/{chunk-LK4SXL3V.js → chunk-QNY7BDFP.js} +1 -1
  60. package/dist/{chunk-OTN6VB5S.cjs → chunk-RDFHWAHL.cjs} +5 -1
  61. package/dist/{chunk-PXDIAYB6.cjs → chunk-STLTOISW.cjs} +34 -214
  62. package/dist/{chunk-T2LDTEXK.js → chunk-UVTO3D4E.js} +2333 -58
  63. package/dist/{chunk-6JL2D5SG.js → chunk-VE6UKYQ2.js} +3 -2
  64. package/dist/{chunk-TXFWZ5ZJ.js → chunk-W6JDUXP3.js} +4 -184
  65. package/dist/{chunk-3SBLVGOM.cjs → chunk-YOVXQHA3.cjs} +23 -23
  66. package/dist/{chunk-WLUVZKVD.cjs → chunk-YXP6X3SY.cjs} +103 -36
  67. package/dist/chunk-YZWM6ZIP.cjs +340 -0
  68. package/dist/{chunk-472INMWH.js → chunk-ZA7L5YJB.js} +63 -0
  69. package/dist/commands/builtins.d.cts +12 -1
  70. package/dist/commands/builtins.d.ts +12 -1
  71. package/dist/commands/index.cjs +2 -2
  72. package/dist/commands/index.js +1 -1
  73. package/dist/image-editor/controller.d.cts +1 -1
  74. package/dist/image-editor/controller.d.ts +1 -1
  75. package/dist/image-editor/index.cjs +868 -864
  76. package/dist/image-editor/index.js +123 -119
  77. package/dist/paint/index.cjs +8 -6
  78. package/dist/paint/index.js +56 -54
  79. package/dist/paint-editor/brush-library-tools.d.cts +12 -2
  80. package/dist/paint-editor/brush-library-tools.d.ts +12 -2
  81. package/dist/paint-editor/brush-model.d.cts +29 -1
  82. package/dist/paint-editor/brush-model.d.ts +29 -1
  83. package/dist/paint-editor/brush-source-art.d.cts +32 -0
  84. package/dist/paint-editor/brush-source-art.d.ts +32 -0
  85. package/dist/paint-editor/controller.d.cts +11 -4
  86. package/dist/paint-editor/controller.d.ts +11 -4
  87. package/dist/paint-editor/dab-stroke.d.cts +2 -0
  88. package/dist/paint-editor/dab-stroke.d.ts +2 -0
  89. package/dist/paint-editor/engine.d.cts +11 -2
  90. package/dist/paint-editor/engine.d.ts +11 -2
  91. package/dist/paint-editor/index.cjs +967 -2335
  92. package/dist/paint-editor/index.d.cts +3 -1
  93. package/dist/paint-editor/index.d.ts +3 -1
  94. package/dist/paint-editor/index.js +394 -1762
  95. package/dist/paint-editor/path-samples.d.cts +2 -0
  96. package/dist/paint-editor/path-samples.d.ts +2 -0
  97. package/dist/paint-editor/presence.d.cts +20 -1
  98. package/dist/paint-editor/presence.d.ts +20 -1
  99. package/dist/paint-editor/stamp-tip.d.cts +8 -5
  100. package/dist/paint-editor/stamp-tip.d.ts +8 -5
  101. package/dist/paint-editor/thumbnails.d.cts +6 -0
  102. package/dist/paint-editor/thumbnails.d.ts +6 -0
  103. package/dist/paint-editor/tip-grain.d.cts +34 -0
  104. package/dist/paint-editor/tip-grain.d.ts +34 -0
  105. package/dist/raster/index.cjs +2 -2
  106. package/dist/raster/index.js +9 -9
  107. package/dist/stickers/helpers.d.cts +2 -0
  108. package/dist/stickers/helpers.d.ts +2 -0
  109. package/dist/stickers/index.cjs +41 -35
  110. package/dist/stickers/index.js +22 -16
  111. package/dist/stickers/types.d.cts +4 -2
  112. package/dist/stickers/types.d.ts +4 -2
  113. package/dist/vector/backdrop.d.cts +13 -0
  114. package/dist/vector/backdrop.d.ts +13 -0
  115. package/dist/vector/brushstroke.d.cts +54 -7
  116. package/dist/vector/brushstroke.d.ts +54 -7
  117. package/dist/vector/brushstrokeMedia.d.cts +96 -0
  118. package/dist/vector/brushstrokeMedia.d.ts +96 -0
  119. package/dist/vector/controller.d.cts +17 -3
  120. package/dist/vector/controller.d.ts +17 -3
  121. package/dist/vector/index.cjs +1850 -1390
  122. package/dist/vector/index.d.cts +2 -0
  123. package/dist/vector/index.d.ts +2 -0
  124. package/dist/vector/index.js +520 -60
  125. package/dist/vector/render.d.cts +6 -0
  126. package/dist/vector/render.d.ts +6 -0
  127. package/dist/vector/types.d.cts +14 -0
  128. package/dist/vector/types.d.ts +14 -0
  129. package/package.json +1 -1
  130. package/skills/pixerate-animation-editor/SKILL.md +1 -0
  131. package/skills/pixerate-brushes/SKILL.md +37 -10
  132. package/skills/pixerate-brushes-design/SKILL.md +15 -5
  133. package/skills/pixerate-brushes-design/evals/port-to-vector.json +8 -8
  134. package/skills/pixerate-canvas/SKILL.md +11 -1
  135. package/skills/pixerate-image-editor/SKILL.md +19 -64
  136. package/skills/pixerate-image-editor/references/color-management.md +2 -1
  137. package/skills/pixerate-image-editor/references/free-transform.md +12 -0
  138. package/skills/pixerate-image-editor/references/layer-effects.md +10 -0
  139. package/skills/pixerate-image-editor/references/painting.md +17 -0
  140. package/skills/pixerate-image-editor/references/photoshop-files.md +1 -1
  141. package/skills/pixerate-image-editor/references/shapes-and-type.md +14 -0
  142. package/skills/pixerate-image-editor/references/smart-objects.md +10 -0
  143. package/skills/pixerate-paint-editor/SKILL.md +14 -4
  144. package/skills/pixerate-paint-editor/references/brush-facets.md +3 -1
  145. package/skills/pixerate-paint-editor/references/wet-media.md +9 -0
  146. package/skills/pixerate-paint-sketch-to-finish/SKILL.md +1 -0
  147. package/skills/pixerate-vector/SKILL.md +16 -6
  148. package/skills/pixerate-vector/references/best-practices.md +1 -0
  149. package/skills/pixerate-vector/references/commands.md +19 -0
@@ -7,7 +7,8 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkOTN6VB5Scjs = require('./chunk-OTN6VB5S.cjs');
10
+
11
+ var _chunkRDFHWAHLcjs = require('./chunk-RDFHWAHL.cjs');
11
12
 
12
13
 
13
14
  var _chunkU67EN7GGcjs = require('./chunk-U67EN7GG.cjs');
@@ -17,26 +18,26 @@ var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, o
17
18
  var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
18
19
  function stickerForAgent(provider, s) {
19
20
  const { id, thumbnail: _thumbnail, ...rest } = s;
20
- return { ref: _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, provider, id), ...rest };
21
+ return { ref: _chunkRDFHWAHLcjs.stickerRefOf.call(void 0, provider, id), ...rest };
21
22
  }
22
23
  async function knownRefs(provider, cap = 500) {
23
24
  const refs = [];
24
25
  let after;
25
26
  while (refs.length < cap) {
26
- const page = await provider.list({ limit: _chunkOTN6VB5Scjs.MAX_STICKER_PAGE, ...after ? { after } : {} });
27
- refs.push(...page.items.map((s) => _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, provider, s.id)));
27
+ const page = await provider.list({ limit: _chunkRDFHWAHLcjs.MAX_STICKER_PAGE, ...after ? { after } : {} });
28
+ refs.push(...page.items.map((s) => _chunkRDFHWAHLcjs.stickerRefOf.call(void 0, provider, s.id)));
28
29
  if (!page.next || !page.items.length) break;
29
30
  after = page.next;
30
31
  }
31
32
  return refs;
32
33
  }
33
34
  async function describeStickerRef(provider, ref) {
34
- _chunkOTN6VB5Scjs.parseStickerRef.call(void 0, ref);
35
- const id = _chunkOTN6VB5Scjs.stickerIdFor.call(void 0, provider, ref);
35
+ _chunkRDFHWAHLcjs.parseStickerRef.call(void 0, ref);
36
+ const id = _chunkRDFHWAHLcjs.stickerIdFor.call(void 0, provider, ref);
36
37
  const found = id === null ? void 0 : await provider.describe(id);
37
38
  if (found) return found;
38
- const near = _chunkOTN6VB5Scjs.closestStickerRefs.call(void 0, ref, await knownRefs(provider));
39
- const owner = _chunkOTN6VB5Scjs.parseStickerRef.call(void 0, ref).provider;
39
+ const near = _chunkRDFHWAHLcjs.closestStickerRefs.call(void 0, ref, await knownRefs(provider));
40
+ const owner = _chunkRDFHWAHLcjs.parseStickerRef.call(void 0, ref).provider;
40
41
  const where = id === null && !provider.namespaced ? ` The sticker library is "${provider.id}", not "${owner}".` : "";
41
42
  throw new (0, _chunkU67EN7GGcjs.StickerError)("unknown_sticker", `No sticker "${ref}".${where} Closest: ${near.join(", ") || "none"}; find_stickers lists them.`);
42
43
  }
@@ -53,7 +54,7 @@ function createStickerTools(options) {
53
54
  collection: { type: "string", minLength: 1, description: "Only this collection id (the result lists them; default every collection)." },
54
55
  tags: { type: "array", maxItems: 10, items: { type: "string", description: "A tag." }, description: "Only stickers with every one of these tags." },
55
56
  commercial: { type: "boolean", description: "true: only stickers whose licence allows commercial use." },
56
- limit: { type: "integer", minimum: 1, maximum: _chunkOTN6VB5Scjs.MAX_STICKER_PAGE, description: "Page size (default 24)." },
57
+ limit: { type: "integer", minimum: 1, maximum: _chunkRDFHWAHLcjs.MAX_STICKER_PAGE, description: "Page size (default 24)." },
57
58
  after: { type: "string", description: "next from the previous page." }
58
59
  },
59
60
  additionalProperties: false
@@ -65,15 +66,15 @@ function createStickerTools(options) {
65
66
  if (category !== void 0 && categories && !categories.some((c) => c.id === category)) {
66
67
  throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `No category "${category}" in "${p.name}"; categories: ${categories.map((c) => c.id).join(", ")}.`);
67
68
  }
68
- const collections = await _asyncNullishCoalesce(await _optionalChain([p, 'access', _3 => _3.listCollections, 'optionalCall', _4 => _4()]), async () => ( null));
69
- if (collection !== void 0 && !_optionalChain([collections, 'optionalAccess', _5 => _5.some, 'call', _6 => _6((c) => c.id === collection)])) {
70
- throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", _optionalChain([collections, 'optionalAccess', _7 => _7.length]) ? `No collection "${collection}" in "${p.name}"; collections: ${collections.map((c) => c.id).join(", ")}.` : `"${p.name}" has no collections; leave collection out.`);
69
+ const collections = await _asyncNullishCoalesce(await _chunkRDFHWAHLcjs.providerCollections.call(void 0, p), async () => ( null));
70
+ if (collection !== void 0 && !_optionalChain([collections, 'optionalAccess', _3 => _3.some, 'call', _4 => _4((c) => c.id === collection)])) {
71
+ throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", _optionalChain([collections, 'optionalAccess', _5 => _5.length]) ? `No collection "${collection}" in "${p.name}"; collections: ${collections.map((c) => c.id).join(", ")}.` : `"${p.name}" has no collections; leave collection out.`);
71
72
  }
72
73
  const o = { ...category !== void 0 ? { category } : {}, ...collection !== void 0 ? { collection } : {}, ...tags ? { tags } : {}, ...commercial ? { licence: { commercial: true } } : {}, ...limit !== void 0 ? { limit } : {}, ...after !== void 0 ? { after } : {} };
73
74
  const q = typeof query === "string" ? query.trim() : "";
74
75
  if (q && !p.capabilities.supportsSearch) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `"${p.name}" can't search; leave query out and filter by category instead.`);
75
76
  const page = q ? await p.search(q, o) : await p.list(o);
76
- return { provider: p.id, items: page.items.map((s) => stickerForAgent(p, s)), total: page.total, ...page.next ? { next: page.next } : {}, ...categories ? { categories } : {}, ..._optionalChain([collections, 'optionalAccess', _8 => _8.length]) ? { collections } : {} };
77
+ return { provider: p.id, items: page.items.map((s) => stickerForAgent(p, s)), total: page.total, ...page.next ? { next: page.next } : {}, ...categories ? { categories } : {}, ..._optionalChain([collections, 'optionalAccess', _6 => _6.length]) ? { collections } : {} };
77
78
  }
78
79
  };
79
80
  const describe = {
@@ -86,28 +87,28 @@ function createStickerTools(options) {
86
87
  const p = options.provider();
87
88
  const d = await describeStickerRef(p, ref);
88
89
  const { thumbnail: _thumbnail, id, ...rest } = d;
89
- return { ref: _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, p, id), ...rest };
90
+ return { ref: _chunkRDFHWAHLcjs.stickerRefOf.call(void 0, p, id), ...rest };
90
91
  }
91
92
  };
92
93
  return options.insert ? [find, describe, createInsertStickerTool(options.provider, options.insert)] : [find, describe];
93
94
  }
94
95
  async function loadForHost(provider, ref, d, host, colour, size, variant) {
95
- const id = _chunkOTN6VB5Scjs.stickerIdFor.call(void 0, provider, ref);
96
+ const id = _chunkRDFHWAHLcjs.stickerIdFor.call(void 0, provider, ref);
96
97
  const format = d.formats.includes(host.format) ? host.format : _nullishCoalesce(d.formats[0], () => ( host.format));
97
98
  return provider.load(id, { format, ...format === "png" ? { size: Math.max(8, Math.min(_nullishCoalesce(provider.capabilities.maxSize, () => ( 1024)), Math.round(size))) } : {}, ...colour && d.tintable ? { colour } : {}, ...variant !== "light" ? { variant } : {} });
98
99
  }
99
100
  async function insertSticker(provider, host, options) {
100
101
  const d = await describeStickerRef(provider, options.ref);
101
- const has = _chunkOTN6VB5Scjs.stickerVariantsOf.call(void 0, d);
102
+ const has = _chunkRDFHWAHLcjs.stickerVariantsOf.call(void 0, d);
102
103
  if (options.variant !== void 0 && !has.includes(options.variant)) throw new (0, _chunkU67EN7GGcjs.StickerError)("unsupported_variant", `"${options.ref}" has no ${JSON.stringify(options.variant)} variant; it has ${has.join(", ")}. Leave variant out to pick for the background.`);
103
- const variant = _nullishCoalesce(options.variant, () => ( _chunkOTN6VB5Scjs.stickerVariantFor.call(void 0, d, _nullishCoalesce(_optionalChain([host, 'access', _9 => _9.dark, 'optionalCall', _10 => _10()]), () => ( false)))));
104
+ const variant = _nullishCoalesce(options.variant, () => ( _chunkRDFHWAHLcjs.stickerVariantFor.call(void 0, d, _nullishCoalesce(_optionalChain([host, 'access', _7 => _7.dark, 'optionalCall', _8 => _8()]), () => ( false)))));
104
105
  if (options.color !== void 0 && !d.tintable) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `"${options.ref}" is not tintable (its art has its own colours); leave color out, or pick a tintable sticker (find_stickers lists tintable).`);
105
106
  if (options.width !== void 0 && !(options.width > 0)) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `width must be a positive size, got ${options.width}.`);
106
107
  const w = _nullishCoalesce(options.width, () => ( d.width));
107
108
  const h = w * d.height / d.width;
108
109
  const centre = host.defaultCentre();
109
110
  const asset = await loadForHost(provider, options.ref, d, host, options.color, Math.max(w, h), variant);
110
- const ref = _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, provider, d.id);
111
+ const ref = _chunkRDFHWAHLcjs.stickerRefOf.call(void 0, provider, d.id);
111
112
  const made = await host.insert({ ref, description: d, asset, variant, x: _nullishCoalesce(options.x, () => ( centre.x)), y: _nullishCoalesce(options.y, () => ( centre.y)), width: w, height: h, ...options.color ? { colour: options.color.toLowerCase() } : {} });
112
113
  return { ...made, ref, width: w, height: h, variant, licence: d.licence };
113
114
  }
@@ -124,7 +125,7 @@ function createInsertStickerTool(provider, host) {
124
125
  y: { type: "number", description: "Centre y in document units (default the middle of the view or document)." },
125
126
  width: { type: "number", exclusiveMinimum: 0, maximum: 1e4, description: "Width in document units (default the natural width); the height follows the aspect." },
126
127
  color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$", description: "Tint #rrggbb for tintable stickers (default the sticker's own colour); refused for stickers that are not tintable." },
127
- variant: { type: "string", enum: [..._chunkOTN6VB5Scjs.STICKER_VARIANTS], description: "light or dark art (default: dark on a dark background when the sticker has it, else light); one the sticker does not list (find_stickers variants) is refused." }
128
+ variant: { type: "string", enum: [..._chunkRDFHWAHLcjs.STICKER_VARIANTS], description: "light or dark art (default: dark on a dark background when the sticker has it, else light); one the sticker does not list (find_stickers variants) is refused." }
128
129
  },
129
130
  required: ["ref"],
130
131
  additionalProperties: false
@@ -382,9 +382,72 @@ function createDrawCommands(target, options = {}) {
382
382
  readOnly: true,
383
383
  run: async () => ({ brushes: await target.listBrushes() })
384
384
  },
385
+ ...createBrushChoiceCommands(target, base, prefix),
385
386
  ...createGestureCommands(target, base, prefix, options)
386
387
  ];
387
388
  }
389
+ function createBrushChoiceCommands(target, base, prefix) {
390
+ const { brushSettings, selectBrush, setColorLocked, setColorScheme } = target;
391
+ if (!brushSettings || !selectBrush || !setColorLocked || !setColorScheme) return [];
392
+ const settings = () => brushSettings();
393
+ const RESULT = "Returns { brush, color, colorScheme, colorLocked, colorFollowsScheme } (colorFollowsScheme: the colour is a brush's light / dark default and changes with the scheme).";
394
+ return [
395
+ {
396
+ ...base,
397
+ id: `${prefix}selectBrush`,
398
+ label: "Choose Pen Brush",
399
+ keywords: ["brush", "pen", "pick brush", "chalk", "pencil", "ink"],
400
+ description: `Chooses the brush the pen and highlighter draw with by hand (brushId from canvas.listBrushes, or null for a plain vector stroke), at the brush's own size. A brush with a default colour (the ballpoint's blue, the chalk's light / dark pair) makes it the stroke colour unless keepColour or the colour is locked (canvas.setColorLocked). Does not draw; canvas.drawFreehand takes its own brush. ${RESULT}`,
401
+ params: {
402
+ type: "object",
403
+ additionalProperties: false,
404
+ required: ["brushId"],
405
+ properties: {
406
+ brushId: { type: ["string", "null"], minLength: 1, description: "A brush id from canvas.listBrushes, or null for a plain vector stroke." },
407
+ keepColour: { type: "boolean", description: "Keep the current stroke colour this once instead of taking the brush's default colour (default false)." }
408
+ }
409
+ },
410
+ run: async (_ctx, params) => {
411
+ await selectBrush(params.brushId, params.keepColour ? { keepColour: true } : {});
412
+ return settings();
413
+ }
414
+ },
415
+ {
416
+ ...base,
417
+ id: `${prefix}setColorLocked`,
418
+ label: "Keep My Colour",
419
+ keywords: ["lock colour", "keep colour", "brush colour", "color lock"],
420
+ description: `Locks or unlocks the stroke colour ("Keep my colour"): while locked, canvas.selectBrush keeps the current colour instead of taking a brush's default colour. ${RESULT}`,
421
+ params: {
422
+ type: "object",
423
+ additionalProperties: false,
424
+ required: ["locked"],
425
+ properties: { locked: { type: "boolean", description: "true locks the colour, false unlocks it (the canvas starts unlocked)." } }
426
+ },
427
+ run: (_ctx, params) => {
428
+ setColorLocked(params.locked);
429
+ return settings();
430
+ }
431
+ },
432
+ {
433
+ ...base,
434
+ id: `${prefix}setColorScheme`,
435
+ label: "Brush Colours for Light / Dark",
436
+ keywords: ["colour scheme", "dark mode", "light mode", "theme", "brush colour"],
437
+ description: `Sets the colour scheme that picks the side of a brush's light / dark default colour (white chalk in dark, dark chalk in light). A stroke colour that came from such a default follows; strokes already drawn keep theirs, and canvas.drawFreehand resolves brush defaults for this scheme. The host usually sets it to match its theme. ${RESULT}`,
438
+ params: {
439
+ type: "object",
440
+ additionalProperties: false,
441
+ required: ["scheme"],
442
+ properties: { scheme: { type: "string", enum: ["light", "dark"], description: "light (dark chalk on a light background) or dark (light chalk on a dark one)." } }
443
+ },
444
+ run: (_ctx, params) => {
445
+ setColorScheme(params.scheme);
446
+ return settings();
447
+ }
448
+ }
449
+ ];
450
+ }
388
451
  var GESTURE_RECT_PARAM = {
389
452
  type: "object",
390
453
  additionalProperties: false,
@@ -18,7 +18,7 @@ import {
18
18
  unionBounds,
19
19
  vectorGradientPoints,
20
20
  widthProfileAt
21
- } from "./chunk-T2LDTEXK.js";
21
+ } from "./chunk-UVTO3D4E.js";
22
22
  import {
23
23
  segmentLength,
24
24
  segmentParamAtLength,
@@ -115,6 +115,9 @@ function stickerCollections(items, names = {}) {
115
115
  }
116
116
  return [...out.values()];
117
117
  }
118
+ function providerCollections(provider) {
119
+ return provider.collections ? provider.collections() : _optionalChain([provider, 'access', _10 => _10.listCollections, 'optionalCall', _11 => _11()]);
120
+ }
118
121
  function parseStickerRef(ref) {
119
122
  if (typeof ref !== "string" || !ref) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", 'A sticker ref is a "provider:id" string, e.g. "editor:star" (find_stickers lists them).');
120
123
  const i = ref.indexOf(":");
@@ -201,4 +204,5 @@ var StickersSlot = (_class = class {
201
204
 
202
205
 
203
206
 
204
- exports.STAMP_KINDS = STAMP_KINDS; exports.stampCoverage = stampCoverage; exports.STICKER_VARIANTS = STICKER_VARIANTS; exports.DEFAULT_STICKER_PAGE = DEFAULT_STICKER_PAGE; exports.MAX_STICKER_PAGE = MAX_STICKER_PAGE; exports.EDITOR_STICKERS_ID = EDITOR_STICKERS_ID; exports.checkStickerSearchOptions = checkStickerSearchOptions; exports.stickerPage = stickerPage; exports.stickerVariantsOf = stickerVariantsOf; exports.checkStickerVariant = checkStickerVariant; exports.stickerVariantFor = stickerVariantFor; exports.stickerCollections = stickerCollections; exports.parseStickerRef = parseStickerRef; exports.normalizeStickerRef = normalizeStickerRef; exports.editorStampOf = editorStampOf; exports.stickerRefOf = stickerRefOf; exports.stickerIdFor = stickerIdFor; exports.closestStickerRefs = closestStickerRefs; exports.StickersSlot = StickersSlot;
207
+
208
+ exports.STAMP_KINDS = STAMP_KINDS; exports.stampCoverage = stampCoverage; exports.STICKER_VARIANTS = STICKER_VARIANTS; exports.DEFAULT_STICKER_PAGE = DEFAULT_STICKER_PAGE; exports.MAX_STICKER_PAGE = MAX_STICKER_PAGE; exports.EDITOR_STICKERS_ID = EDITOR_STICKERS_ID; exports.checkStickerSearchOptions = checkStickerSearchOptions; exports.stickerPage = stickerPage; exports.stickerVariantsOf = stickerVariantsOf; exports.checkStickerVariant = checkStickerVariant; exports.stickerVariantFor = stickerVariantFor; exports.stickerCollections = stickerCollections; exports.providerCollections = providerCollections; exports.parseStickerRef = parseStickerRef; exports.normalizeStickerRef = normalizeStickerRef; exports.editorStampOf = editorStampOf; exports.stickerRefOf = stickerRefOf; exports.stickerIdFor = stickerIdFor; exports.closestStickerRefs = closestStickerRefs; exports.StickersSlot = StickersSlot;
@@ -1,4 +1,4 @@
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;
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;
2
2
 
3
3
 
4
4
 
@@ -10,9 +10,9 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkFQPUF2W2cjs = require('./chunk-FQPUF2W2.cjs');
14
13
 
15
14
 
15
+ var _chunkNIBFKXMDcjs = require('./chunk-NIBFKXMD.cjs');
16
16
 
17
17
 
18
18
  var _chunk3K6HWEXZcjs = require('./chunk-3K6HWEXZ.cjs');
@@ -34,180 +34,6 @@ var _chunkW5M3J7PVcjs = require('./chunk-W5M3J7PV.cjs');
34
34
 
35
35
  var _chunk474IQG74cjs = require('./chunk-474IQG74.cjs');
36
36
 
37
- // src/paint/grain.ts
38
- var GRAIN_PATTERNS = ["smooth", "cold-pressed", "hot-pressed", "rough", "vellum", "laid", "ingres", "sanded", "canvas", "linen", "gesso"];
39
- var GRAIN_TILE = 256;
40
- var clamp01 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
41
- function patternHeights(pattern, n, seed) {
42
- const out = new Float32Array(n * n);
43
- const salt = Math.imul(seed | 0, 2654435761) + 17;
44
- if (pattern === "smooth") return out.fill(1);
45
- const noise = (cx, cy, oct, s = 0) => new (0, _chunk3K6HWEXZcjs.TileableNoise)(n, cx, cy, oct, salt + s);
46
- const k = n / GRAIN_TILE;
47
- switch (pattern) {
48
- case "cold-pressed": {
49
- const base = noise(20 * k, 20 * k, 4);
50
- const fine = noise(64 * k, 64 * k, 2, 3);
51
- for (let y = 0; y < n; y++)
52
- for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 1.8 + 0.5 + (fine.at(x, y) - 0.5) * 0.5 + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.12);
53
- break;
54
- }
55
- case "hot-pressed": {
56
- const base = noise(40 * k, 40 * k, 3);
57
- for (let y = 0; y < n; y++) for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 1.1 + 0.6 + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.08);
58
- break;
59
- }
60
- case "rough": {
61
- const base = noise(10 * k, 10 * k, 5);
62
- const blot = noise(28 * k, 28 * k, 2, 5);
63
- for (let y = 0; y < n; y++)
64
- for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 2.4 + 0.5 + (blot.at(x, y) - 0.5) * 0.7 + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.15);
65
- break;
66
- }
67
- case "vellum": {
68
- const base = noise(40 * k, 40 * k, 3);
69
- for (let y = 0; y < n; y++) for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 1.6 + 0.55 + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.2);
70
- break;
71
- }
72
- case "laid": {
73
- const pulp = noise(32 * k, 32 * k, 3);
74
- const chain = n / 8;
75
- for (let y = 0; y < n; y++) {
76
- const laid = 0.5 + 0.5 * Math.cos(2 * Math.PI * y / 4);
77
- for (let x = 0; x < n; x++) {
78
- const c = Math.abs((x + 0.5) % chain - chain / 2) / (chain / 2);
79
- const chainLine = c > 0.94 ? -0.35 : 0;
80
- out[y * n + x] = clamp01(0.3 + 0.5 * laid + chainLine + (pulp.at(x, y) - 0.5) * 0.6);
81
- }
82
- }
83
- break;
84
- }
85
- case "ingres": {
86
- const fibres = noise(64 * k, 12 * k, 3);
87
- const base = noise(16 * k, 16 * k, 3, 7);
88
- for (let y = 0; y < n; y++)
89
- for (let x = 0; x < n; x++) {
90
- const g = _chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt ^ 85);
91
- out[y * n + x] = clamp01((fibres.at(x, y) - 0.5) * 1.5 + (base.at(x, y) - 0.5) * 0.7 + 0.55 + (g < 0.1 ? -0.3 : 0));
92
- }
93
- break;
94
- }
95
- case "sanded": {
96
- const grit = noise(96 * k, 96 * k, 2);
97
- for (let y = 0; y < n; y++)
98
- for (let x = 0; x < n; x++) {
99
- const h = _chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt);
100
- out[y * n + x] = clamp01((grit.at(x, y) - 0.5) * 2.4 + 0.5 + (h - 0.5) * 0.7);
101
- }
102
- break;
103
- }
104
- case "canvas":
105
- case "linen": {
106
- const period = (pattern === "canvas" ? 8 : 5) * k;
107
- const threads = Math.max(2, 2 * Math.round(n / period / 2));
108
- const p = n / threads;
109
- const slub = noise(threads, threads, 2, 11);
110
- for (let y = 0; y < n; y++)
111
- for (let x = 0; x < n; x++) {
112
- const fx = (x + 0.5) / p;
113
- const fy = (y + 0.5) / p;
114
- const cx = Math.floor(fx);
115
- const cy = Math.floor(fy);
116
- const warp = Math.sin(Math.PI * (fx - cx));
117
- const weft = Math.sin(Math.PI * (fy - cy));
118
- const top = (cx + cy) % 2 === 0 ? warp : weft;
119
- const irregular = pattern === "linen" ? (slub.at(x, y) - 0.5) * 0.5 : 0;
120
- out[y * n + x] = clamp01(0.2 + 0.7 * top + irregular + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.15);
121
- }
122
- break;
123
- }
124
- case "gesso": {
125
- const streaks = noise(2 * k, 28 * k, 3);
126
- const tooth = noise(64 * k, 64 * k, 2, 13);
127
- for (let y = 0; y < n; y++)
128
- for (let x = 0; x < n; x++) out[y * n + x] = clamp01((streaks.at(x, y) - 0.5) * 1.8 + (tooth.at(x, y) - 0.5) * 0.9 + 0.55);
129
- break;
130
- }
131
- }
132
- return out;
133
- }
134
- var rawCache = /* @__PURE__ */ new Map();
135
- function grainHeights(pattern, seed, size = GRAIN_TILE) {
136
- const key = `${pattern}:${seed}:${size}`;
137
- let h = rawCache.get(key);
138
- if (!h) {
139
- h = patternHeights(pattern, size, seed);
140
- if (rawCache.size > 32) rawCache.delete(rawCache.keys().next().value);
141
- rawCache.set(key, h);
142
- }
143
- return h;
144
- }
145
- var PaperGrain = (_class = class {
146
- __init() {this.size = GRAIN_TILE}
147
-
148
-
149
-
150
-
151
-
152
-
153
- constructor(paper, media = "dry") {;_class.prototype.__init.call(this);
154
- const raw = grainHeights(paper.pattern, paper.seed);
155
- const t = paper[media];
156
- this.flat = paper.pattern === "smooth";
157
- if (t.contrast === 1 && !t.invert) this.heights = raw;
158
- else {
159
- const out = new Float32Array(raw.length);
160
- for (let i = 0; i < raw.length; i++) {
161
- const v = clamp01((raw[i] - 0.5) * t.contrast + 0.5);
162
- out[i] = t.invert ? 1 - v : v;
163
- }
164
- this.heights = out;
165
- }
166
- this.scale = paper.scale;
167
- this.mirror = paper.tiling === "mirror";
168
- this.ox = _nullishCoalesce(_optionalChain([paper, 'access', _ => _.offset, 'optionalAccess', _2 => _2.x]), () => ( 0));
169
- this.oy = _nullishCoalesce(_optionalChain([paper, 'access', _3 => _3.offset, 'optionalAccess', _4 => _4.y]), () => ( 0));
170
- }
171
- /** Tile cell index for a coordinate in grain pixels (mirrored on odd tiles when mirroring). */
172
- wrap(v) {
173
- const n = this.size;
174
- if (!this.mirror) return (v % n + n) % n;
175
- const p = (v % (2 * n) + 2 * n) % (2 * n);
176
- return p < n ? p : 2 * n - 1 - p;
177
- }
178
- /** Height 0..1 at document position (x, y). */
179
- at(x, y) {
180
- const u = (x - this.ox) / this.scale - 0.5;
181
- const v = (y - this.oy) / this.scale - 0.5;
182
- const x0 = Math.floor(u);
183
- const y0 = Math.floor(v);
184
- const fx = u - x0;
185
- const fy = v - y0;
186
- const n = this.size;
187
- const h = this.heights;
188
- const a = this.wrap(x0);
189
- const b = this.wrap(x0 + 1);
190
- const c = this.wrap(y0) * n;
191
- const d = this.wrap(y0 + 1) * n;
192
- const top = h[c + a] + (h[c + b] - h[c + a]) * fx;
193
- const bot = h[d + a] + (h[d + b] - h[d + a]) * fx;
194
- return top + (bot - top) * fy;
195
- }
196
- }, _class);
197
- function grainCatch(h, depth, pressure) {
198
- if (depth <= 0) return 1;
199
- const t = depth * (0.75 - 0.65 * Math.min(1, Math.max(0, pressure)));
200
- const u = clamp01((h - t + 0.18) / 0.36);
201
- return 1 - depth + depth * u * u * (3 - 2 * u);
202
- }
203
- function strokeGrainCatch(h, depth, pressure) {
204
- if (depth <= 0) return 1;
205
- const p = Math.min(1, Math.max(0, pressure));
206
- const amount = Math.min(1, depth * (1.4 - 0.6 * p));
207
- const u = clamp01((h - 0.2 - 0.25 * (1 - p)) / 0.5);
208
- return 1 - amount + amount * u * u * (3 - 2 * u);
209
- }
210
-
211
37
  // src/paint/path-stroke.ts
212
38
  var JITTER_SIZE = 1;
213
39
  var JITTER_ANGLE = 2;
@@ -228,16 +54,16 @@ function lean(s) {
228
54
  return null;
229
55
  }
230
56
  function pathStrokeDabs(samples, options) {
231
- const brush = _chunkFQPUF2W2cjs.normalizeBrush.call(void 0, options.brush);
57
+ const brush = _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, options.brush);
232
58
  const pts = options.closed && samples.length > 2 ? [...samples, samples[0]] : [...samples];
233
59
  if (!pts.length) return [];
234
60
  const tilt = _nullishCoalesce(options.tilt, () => ( {}));
235
61
  const minSize = Math.min(1, Math.max(0, _nullishCoalesce(options.minSize, () => ( 0))));
236
62
  let index = 0;
237
- const t0 = _nullishCoalesce(_optionalChain([pts, 'access', _5 => _5.find, 'call', _6 => _6((s) => typeof s.t === "number" && Number.isFinite(s.t)), 'optionalAccess', _7 => _7.t]), () => ( null));
63
+ const t0 = _nullishCoalesce(_optionalChain([pts, 'access', _ => _.find, 'call', _2 => _2((s) => typeof s.t === "number" && Number.isFinite(s.t)), 'optionalAccess', _3 => _3.t]), () => ( null));
238
64
  const dab = (x, y, p, l, dir, travel = 0, time = null, speed = null) => {
239
65
  const pr = Math.min(1, Math.max(0, p));
240
- const lean0 = _nullishCoalesce(_optionalChain([l, 'optionalAccess', _8 => _8.amount]), () => ( 0));
66
+ const lean0 = _nullishCoalesce(_optionalChain([l, 'optionalAccess', _4 => _4.amount]), () => ( 0));
241
67
  const size = brush.size * (brush.pressureSize ? minSize + (1 - minSize) * pr : 1) * (1 + 1.5 * (_nullishCoalesce(tilt.size, () => ( 0))) * lean0);
242
68
  let angle = brush.angle * Math.PI / 180;
243
69
  if (options.followPath) angle += dir;
@@ -301,24 +127,24 @@ function pathStrokeDabs(samples, options) {
301
127
  return out;
302
128
  }
303
129
  function pathStrokeCoverage(samples, options) {
304
- const brush = _chunkFQPUF2W2cjs.normalizeBrush.call(void 0, options.brush);
305
- const coverage = new (0, _chunkFQPUF2W2cjs.CoverageMap)();
130
+ const brush = _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, options.brush);
131
+ const coverage = new (0, _chunkNIBFKXMDcjs.CoverageMap)();
306
132
  const dabs = pathStrokeDabs(samples, options);
307
- const g = _optionalChain([options, 'access', _9 => _9.gradient, 'optionalAccess', _10 => _10.paint, 'access', _11 => _11.type]) === "gradient" ? options.gradient : null;
308
- const sampler = g ? new (0, _chunkFQPUF2W2cjs.PaintGradientSampler)(_chunkFQPUF2W2cjs.resolvePaintGradient.call(void 0, g.paint, _nullishCoalesce(g.colors, () => ( { paint: "#000000", secondary: "#ffffff" }))), _nullishCoalesce(g.seed, () => ( 0))) : null;
309
- const tipTable = _optionalChain([sampler, 'optionalAccess', _12 => _12.acrossTip]) ? sampler.tipTable(_chunkFQPUF2W2cjs.TIP_GRADIENT_STEPS) : null;
133
+ const g = _optionalChain([options, 'access', _5 => _5.gradient, 'optionalAccess', _6 => _6.paint, 'access', _7 => _7.type]) === "gradient" ? options.gradient : null;
134
+ const sampler = g ? new (0, _chunkNIBFKXMDcjs.PaintGradientSampler)(_chunkNIBFKXMDcjs.resolvePaintGradient.call(void 0, g.paint, _nullishCoalesce(g.colors, () => ( { paint: "#000000", secondary: "#ffffff" }))), _nullishCoalesce(g.seed, () => ( 0))) : null;
135
+ const tipTable = _optionalChain([sampler, 'optionalAccess', _8 => _8.acrossTip]) ? sampler.tipTable(_chunkNIBFKXMDcjs.TIP_GRADIENT_STEPS) : null;
310
136
  const scratch = { field: new Float32Array(0), sample: { rgb: [0, 0, 0], alpha: 1 } };
311
137
  let buf = new Float32Array(0);
312
138
  let bounds = null;
313
139
  for (const d of dabs) {
314
- const rect = _chunkFQPUF2W2cjs.dabRect.call(void 0, d, brush.hardness);
140
+ const rect = _chunkNIBFKXMDcjs.dabRect.call(void 0, d, brush.hardness);
315
141
  const n = rect.width * rect.height;
316
142
  if (n <= 0) continue;
317
143
  if (buf.length < n) buf = new Float32Array(n);
318
144
  const vals = buf.subarray(0, n);
319
- _chunkFQPUF2W2cjs.rasterizeDab.call(void 0, d, brush.hardness, rect, vals);
145
+ _chunkNIBFKXMDcjs.rasterizeDab.call(void 0, d, brush.hardness, rect, vals);
320
146
  if (sampler) {
321
- const { color, field } = _chunkFQPUF2W2cjs.gradientDabColor.call(void 0, sampler, tipTable, d, d.params, rect, vals, scratch);
147
+ const { color, field } = _chunkNIBFKXMDcjs.gradientDabColor.call(void 0, sampler, tipTable, d, d.params, rect, vals, scratch);
322
148
  coverage.accumulate(rect, vals, d.opacity, color, field);
323
149
  } else coverage.accumulate(rect, vals, d.opacity);
324
150
  if (!bounds) bounds = { ...rect };
@@ -330,12 +156,12 @@ function pathStrokeCoverage(samples, options) {
330
156
  }
331
157
  const grain = options.grain;
332
158
  if (grain && grain.depth > 0 && dabs.length) {
333
- const pressure = dabs.reduce((sum, d) => sum + (_nullishCoalesce(_optionalChain([d, 'access', _13 => _13.params, 'optionalAccess', _14 => _14.pressure]), () => ( 1))), 0) / dabs.length;
159
+ const pressure = dabs.reduce((sum, d) => sum + (_nullishCoalesce(_optionalChain([d, 'access', _9 => _9.params, 'optionalAccess', _10 => _10.pressure]), () => ( 1))), 0) / dabs.length;
334
160
  for (const [key, t] of coverage.tiles) {
335
161
  const { tx, ty } = _chunk474IQG74cjs.tileCoord.call(void 0, key);
336
162
  for (let y = 0, k = 0; y < _chunk474IQG74cjs.TILE; y++) {
337
163
  const gy = ty * _chunk474IQG74cjs.TILE + y + 0.5;
338
- for (let x = 0; x < _chunk474IQG74cjs.TILE; x++, k++) if (t[k] > 0) t[k] *= strokeGrainCatch(grain.at(tx * _chunk474IQG74cjs.TILE + x + 0.5, gy), grain.depth, pressure);
164
+ for (let x = 0; x < _chunk474IQG74cjs.TILE; x++, k++) if (t[k] > 0) t[k] *= _chunkNIBFKXMDcjs.strokeGrainCatch.call(void 0, grain.at(tx * _chunk474IQG74cjs.TILE + x + 0.5, gy), grain.depth, pressure);
339
165
  }
340
166
  }
341
167
  }
@@ -343,14 +169,14 @@ function pathStrokeCoverage(samples, options) {
343
169
  }
344
170
  function paintPathStroke(surface, samples, options) {
345
171
  if (surface.channels !== 4) throw new Error("paintPathStroke paints RGBA surfaces (4 channels).");
346
- const brush = _chunkFQPUF2W2cjs.normalizeBrush.call(void 0, options.brush);
172
+ const brush = _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, options.brush);
347
173
  const hex = (c) => "#" + [0, 1, 2].map((i) => Math.round(Math.min(255, Math.max(0, c[i]))).toString(16).padStart(2, "0")).join("");
348
174
  let color = options.color;
349
- if (_optionalChain([options, 'access', _15 => _15.paint, 'optionalAccess', _16 => _16.paint, 'access', _17 => _17.type]) === "color") {
350
- const rgb = _chunkFQPUF2W2cjs.hexToPaintRgb.call(void 0, options.paint.paint.color).map((v) => Math.round(v * 255));
175
+ if (_optionalChain([options, 'access', _11 => _11.paint, 'optionalAccess', _12 => _12.paint, 'access', _13 => _13.type]) === "color") {
176
+ const rgb = _chunkNIBFKXMDcjs.hexToPaintRgb.call(void 0, options.paint.paint.color).map((v) => Math.round(v * 255));
351
177
  color = [rgb[0], rgb[1], rgb[2], color[3]];
352
178
  }
353
- const gradient = _optionalChain([options, 'access', _18 => _18.paint, 'optionalAccess', _19 => _19.paint, 'access', _20 => _20.type]) === "gradient" ? { ...options.paint, colors: _nullishCoalesce(options.paint.colors, () => ( { paint: hex(color), secondary: "#ffffff" })) } : null;
179
+ const gradient = _optionalChain([options, 'access', _14 => _14.paint, 'optionalAccess', _15 => _15.paint, 'access', _16 => _16.type]) === "gradient" ? { ...options.paint, colors: _nullishCoalesce(options.paint.colors, () => ( { paint: hex(color), secondary: "#ffffff" })) } : null;
354
180
  const { coverage, bounds, dabs } = pathStrokeCoverage(samples, { ...options, gradient });
355
181
  if (!bounds) return { surface, bounds: null, dabs };
356
182
  const offset = _nullishCoalesce(options.offset, () => ( { x: 0, y: 0 }));
@@ -367,9 +193,9 @@ function paintPathStroke(surface, samples, options) {
367
193
  const tiles = new Map(surface.tiles);
368
194
  for (const { tx, ty } of _chunk474IQG74cjs.tilesInRect.call(void 0, { x: bounds.x - offset.x, y: bounds.y - offset.y, width: bounds.width, height: bounds.height })) {
369
195
  const key = _chunk474IQG74cjs.tileKey.call(void 0, tx, ty);
370
- const src = _optionalChain([surface, 'access', _21 => _21.tiles, 'access', _22 => _22.get, 'call', _23 => _23(key), 'optionalAccess', _24 => _24.data]);
196
+ const src = _optionalChain([surface, 'access', _17 => _17.tiles, 'access', _18 => _18.get, 'call', _19 => _19(key), 'optionalAccess', _20 => _20.data]);
371
197
  const base = src && src.length === _chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE * 4 ? src : new Uint8ClampedArray(_chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE * 4);
372
- const t = _chunk474IQG74cjs.finishTile.call(void 0, _chunkFQPUF2W2cjs.applyStrokeToTile.call(void 0, coverage, base, 4, tx, ty, apply), 4, surface.defaultValue);
198
+ const t = _chunk474IQG74cjs.finishTile.call(void 0, _chunkNIBFKXMDcjs.applyStrokeToTile.call(void 0, coverage, base, 4, tx, ty, apply), 4, surface.defaultValue);
373
199
  if (t) tiles.set(key, t);
374
200
  else tiles.delete(key);
375
201
  }
@@ -413,7 +239,7 @@ var REFUSED_ENGINES = {
413
239
  };
414
240
  function brushstrokeStrokeOptions(brush) {
415
241
  if (!brush || typeof brush !== "object") throw new Error("A brushstroke needs a brush: tip settings ({ size, hardness, \u2026 }) or a paint brush preset.");
416
- if (!("tip" in brush) || !brush.tip) return { brush: _chunkFQPUF2W2cjs.normalizeBrush.call(void 0, brush) };
242
+ if (!("tip" in brush) || !brush.tip) return { brush: _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, brush) };
417
243
  const engine = _nullishCoalesce(brush.engine, () => ( "dab"));
418
244
  if (engine !== "dab") {
419
245
  const label = _nullishCoalesce(_nullishCoalesce(brush.name, () => ( brush.id)), () => ( "This brush"));
@@ -423,7 +249,7 @@ function brushstrokeStrokeOptions(brush) {
423
249
  const d = _nullishCoalesce(brush.dynamics, () => ( {}));
424
250
  const tilt = { size: _nullishCoalesce(d.tiltSize, () => ( 0)), roundness: _nullishCoalesce(d.tiltRoundness, () => ( 0)) };
425
251
  return {
426
- brush: _chunkFQPUF2W2cjs.normalizeBrush.call(void 0, brush.tip),
252
+ brush: _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, brush.tip),
427
253
  followPath: brush.rotation === "stroke",
428
254
  minSize: _nullishCoalesce(d.minSize, () => ( 0)),
429
255
  ...tilt.size || tilt.roundness ? { tilt } : {}
@@ -447,7 +273,7 @@ function paperGrain(paper) {
447
273
  const key = `${pattern}:${seed}:${scale}`;
448
274
  let g = papers.get(key);
449
275
  if (!g) {
450
- g = new PaperGrain({ pattern, seed, scale, tiling: "mirror", dry: { contrast: 1, invert: false }, wet: { contrast: 1, invert: false } });
276
+ g = new (0, _chunkNIBFKXMDcjs.PaperGrain)({ pattern, seed, scale, tiling: "mirror", dry: { contrast: 1, invert: false }, wet: { contrast: 1, invert: false } });
451
277
  if (papers.size > 16) papers.delete(papers.keys().next().value);
452
278
  papers.set(key, g);
453
279
  }
@@ -463,7 +289,7 @@ function renderBrushstroke(input, brush, options = {}) {
463
289
  let scale = finite(options.scale) && options.scale > 0 ? Math.min(_chunkYQGCPL5Xcjs.BRUSHSTROKE_MAX_SCALE, Math.max(_chunkYQGCPL5Xcjs.BRUSHSTROKE_MIN_SCALE, options.scale)) : 1;
464
290
  if (!samples.length) return { image: { width: 0, height: 0, data: new Uint8ClampedArray(0) }, bounds: null, scale, dabs: 0 };
465
291
  const tip = strokeOptions.brush;
466
- const reach = tip.size * (1 + 1.5 * (_nullishCoalesce(_optionalChain([strokeOptions, 'access', _25 => _25.tilt, 'optionalAccess', _26 => _26.size]), () => ( 0)))) + 4;
292
+ const reach = tip.size * (1 + 1.5 * (_nullishCoalesce(_optionalChain([strokeOptions, 'access', _21 => _21.tilt, 'optionalAccess', _22 => _22.size]), () => ( 0)))) + 4;
467
293
  let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
468
294
  for (const s of samples) {
469
295
  x0 = Math.min(x0, s.x);
@@ -486,8 +312,8 @@ function renderBrushstroke(input, brush, options = {}) {
486
312
  let grain;
487
313
  if (paper && depth > 0) {
488
314
  const g = paperGrain(paper);
489
- const ox = _nullishCoalesce(_optionalChain([ch, 'access', _27 => _27.origin, 'optionalAccess', _28 => _28.x]), () => ( 0));
490
- const oy = _nullishCoalesce(_optionalChain([ch, 'access', _29 => _29.origin, 'optionalAccess', _30 => _30.y]), () => ( 0));
315
+ const ox = _nullishCoalesce(_optionalChain([ch, 'access', _23 => _23.origin, 'optionalAccess', _24 => _24.x]), () => ( 0));
316
+ const oy = _nullishCoalesce(_optionalChain([ch, 'access', _25 => _25.origin, 'optionalAccess', _26 => _26.y]), () => ( 0));
491
317
  const k = (finite(ch.unit) && ch.unit > 0 ? ch.unit : 1) / scale;
492
318
  grain = { depth, at: (x, y) => g.at(ox + x * k, oy + y * k) };
493
319
  }
@@ -500,7 +326,7 @@ function renderBrushstroke(input, brush, options = {}) {
500
326
  closed: _nullishCoalesce(options.closed, () => ( strokeOptions.closed)),
501
327
  color,
502
328
  // Gradient lengths are in path units: scale them with the image.
503
- ...source ? { paint: { paint: source.type === "gradient" ? _chunkFQPUF2W2cjs.scalePaintGradient.call(void 0, source, scale) : source, seed: _nullishCoalesce(options.seed, () => ( 0)) } } : {}
329
+ ...source ? { paint: { paint: source.type === "gradient" ? _chunkNIBFKXMDcjs.scalePaintGradient.call(void 0, source, scale) : source, seed: _nullishCoalesce(options.seed, () => ( 0)) } } : {}
504
330
  });
505
331
  if (!bounds) return { image: { width: 0, height: 0, data: new Uint8ClampedArray(0) }, bounds: null, scale, dabs };
506
332
  const rect = bounds;
@@ -542,14 +368,14 @@ function brushstrokeKey(input, brush, options = {}) {
542
368
  const scale = finite(options.scale) ? options.scale : 1;
543
369
  return `${hashString(path).toString(16)}:${path.length}:${hashString(rest2).toString(16)}:${scale}`;
544
370
  }
545
- var BrushstrokeCache = (_class2 = class {
546
- constructor(capacity = 64) {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);
371
+ var BrushstrokeCache = (_class = class {
372
+ constructor(capacity = 64) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
547
373
  this.capacity = capacity;
548
374
  }
549
375
 
550
- __init2() {this.entries = /* @__PURE__ */ new Map()}
376
+ __init() {this.entries = /* @__PURE__ */ new Map()}
551
377
  /** Renders that missed the cache (for tests and stats). */
552
- __init3() {this.misses = 0}
378
+ __init2() {this.misses = 0}
553
379
  get size() {
554
380
  return this.entries.size;
555
381
  }
@@ -571,13 +397,7 @@ var BrushstrokeCache = (_class2 = class {
571
397
  clear() {
572
398
  this.entries.clear();
573
399
  }
574
- }, _class2);
575
-
576
-
577
-
578
-
579
-
580
-
400
+ }, _class);
581
401
 
582
402
 
583
403
 
@@ -591,4 +411,4 @@ var BrushstrokeCache = (_class2 = class {
591
411
 
592
412
 
593
413
 
594
- exports.GRAIN_PATTERNS = GRAIN_PATTERNS; exports.GRAIN_TILE = GRAIN_TILE; exports.grainHeights = grainHeights; exports.PaperGrain = PaperGrain; exports.grainCatch = grainCatch; exports.strokeGrainCatch = strokeGrainCatch; exports.pathStrokeDabs = pathStrokeDabs; exports.pathStrokeCoverage = pathStrokeCoverage; exports.paintPathStroke = paintPathStroke; exports.brushstrokeSamples = brushstrokeSamples; exports.brushstrokeStrokeOptions = brushstrokeStrokeOptions; exports.isBrushstrokeBrush = isBrushstrokeBrush; exports.renderBrushstroke = renderBrushstroke; exports.brushstrokeDataUrl = brushstrokeDataUrl; exports.brushstrokeToCanvas = brushstrokeToCanvas; exports.brushstrokeKey = brushstrokeKey; exports.BrushstrokeCache = BrushstrokeCache;
414
+ exports.pathStrokeDabs = pathStrokeDabs; exports.pathStrokeCoverage = pathStrokeCoverage; exports.paintPathStroke = paintPathStroke; exports.brushstrokeSamples = brushstrokeSamples; exports.brushstrokeStrokeOptions = brushstrokeStrokeOptions; exports.isBrushstrokeBrush = isBrushstrokeBrush; exports.renderBrushstroke = renderBrushstroke; exports.brushstrokeDataUrl = brushstrokeDataUrl; exports.brushstrokeToCanvas = brushstrokeToCanvas; exports.brushstrokeKey = brushstrokeKey; exports.BrushstrokeCache = BrushstrokeCache;