@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
@@ -1,9 +1,9 @@
1
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; }
2
2
 
3
- var _chunkVRK322ZCcjs = require('./chunk-VRK322ZC.cjs');
3
+ var _chunkBPJSI4NTcjs = require('./chunk-BPJSI4NT.cjs');
4
4
 
5
5
 
6
- var _chunkTOID45I2cjs = require('./chunk-TOID45I2.cjs');
6
+ var _chunk2WOGXEDXcjs = require('./chunk-2WOGXEDX.cjs');
7
7
 
8
8
 
9
9
 
@@ -14,8 +14,8 @@ var _chunkTOID45I2cjs = require('./chunk-TOID45I2.cjs');
14
14
 
15
15
 
16
16
 
17
- var _chunkRFJZGTHAcjs = require('./chunk-RFJZGTHA.cjs');
18
- require('./chunk-OTN6VB5S.cjs');
17
+ var _chunkEU2ZZA6Lcjs = require('./chunk-EU2ZZA6L.cjs');
18
+ require('./chunk-RDFHWAHL.cjs');
19
19
 
20
20
 
21
21
 
@@ -30,14 +30,14 @@ require('./chunk-WOFXZ3XU.cjs');
30
30
 
31
31
 
32
32
 
33
- var _chunkPXDIAYB6cjs = require('./chunk-PXDIAYB6.cjs');
33
+ var _chunkSTLTOISWcjs = require('./chunk-STLTOISW.cjs');
34
34
 
35
35
 
36
- var _chunkFQPUF2W2cjs = require('./chunk-FQPUF2W2.cjs');
36
+ var _chunkNIBFKXMDcjs = require('./chunk-NIBFKXMD.cjs');
37
37
  require('./chunk-3K6HWEXZ.cjs');
38
38
  require('./chunk-YQGCPL5X.cjs');
39
- require('./chunk-W5M3J7PV.cjs');
40
39
  require('./chunk-2VX55NFM.cjs');
40
+ require('./chunk-W5M3J7PV.cjs');
41
41
  require('./chunk-474IQG74.cjs');
42
42
  require('./chunk-XFM3OCHU.cjs');
43
43
 
@@ -48,17 +48,17 @@ require('./chunk-5UEFBM2M.cjs');
48
48
  require('./chunk-IPJ3TEYR.cjs');
49
49
 
50
50
  // src/canvas/brushstrokeRender.ts
51
- var PRESETS = _chunkRFJZGTHAcjs.listPresets.call(void 0, _chunkRFJZGTHAcjs.CANVAS_PROFILE).map((spec) => _chunkRFJZGTHAcjs.BUILTIN_BRUSHES.find((b) => b.id === spec.id));
51
+ var PRESETS = _chunkEU2ZZA6Lcjs.listPresets.call(void 0, _chunkEU2ZZA6Lcjs.CANVAS_PROFILE).map((spec) => _chunkEU2ZZA6Lcjs.BUILTIN_BRUSHES.find((b) => b.id === spec.id));
52
52
  var presetIds = () => PRESETS.map((b) => b.id).join(", ");
53
- var refusal = (brush) => _chunkRFJZGTHAcjs.checkBrush.call(void 0, brush, _chunkRFJZGTHAcjs.CANVAS_PROFILE).issues.filter((i) => i.severity === "error").map((i) => `${i.reason} ${i.fix}`).join(" ");
53
+ var refusal = (brush) => _chunkEU2ZZA6Lcjs.checkBrush.call(void 0, brush, _chunkEU2ZZA6Lcjs.CANVAS_PROFILE).issues.filter((i) => i.severity === "error").map((i) => `${i.reason} ${i.fix}`).join(" ");
54
54
  function readCanvasBrushSpec(spec) {
55
55
  let brush;
56
56
  try {
57
- brush = _chunkRFJZGTHAcjs.normalizeBrushSpec.call(void 0, spec);
57
+ brush = _chunkEU2ZZA6Lcjs.normalizeBrushSpec.call(void 0, spec);
58
58
  } catch (e) {
59
59
  throw new Error(`Not a brush: ${e.message}`);
60
60
  }
61
- if (!_chunkRFJZGTHAcjs.checkBrush.call(void 0, brush, _chunkRFJZGTHAcjs.CANVAS_PROFILE).ok) throw new Error(`Brush '${brush.id}' (${brush.name}) can't brush a canvas stroke: ${refusal(brush)}`);
61
+ if (!_chunkEU2ZZA6Lcjs.checkBrush.call(void 0, brush, _chunkEU2ZZA6Lcjs.CANVAS_PROFILE).ok) throw new Error(`Brush '${brush.id}' (${brush.name}) can't brush a canvas stroke: ${refusal(brush)}`);
62
62
  return brush;
63
63
  }
64
64
  function listCanvasBrushes(user = []) {
@@ -66,12 +66,12 @@ function listCanvasBrushes(user = []) {
66
66
  const d = _optionalChain([spec, 'access', _2 => _2.colour, 'optionalAccess', _3 => _3.default]);
67
67
  return typeof d === "string" || _chunkMLLTWAXHcjs.isDualColor.call(void 0, d) ? { defaultColor: d } : {};
68
68
  };
69
- const out = PRESETS.map((b) => ({ id: b.id, name: b.name, category: b.category, size: b.tip.size, builtin: true, ...colourOf(_chunkRFJZGTHAcjs.BRUSH_PRESETS.find((p) => p.id === b.id)) }));
69
+ const out = PRESETS.map((b) => ({ id: b.id, name: b.name, category: b.category, size: b.tip.size, builtin: true, ...colourOf(_chunkEU2ZZA6Lcjs.BRUSH_PRESETS.find((p) => p.id === b.id)) }));
70
70
  for (const raw of user) {
71
71
  try {
72
72
  const brush = readCanvasBrushSpec(raw);
73
73
  if (out.some((b) => b.id === brush.id)) continue;
74
- out.push({ id: brush.id, name: brush.name, category: _chunkRFJZGTHAcjs.resolveCategory.call(void 0, brush), size: _chunkRFJZGTHAcjs.resolveBrush.call(void 0, brush).tip.size, builtin: false, spec: brush, ...colourOf(brush) });
74
+ out.push({ id: brush.id, name: brush.name, category: _chunkEU2ZZA6Lcjs.resolveCategory.call(void 0, brush), size: _chunkEU2ZZA6Lcjs.resolveBrush.call(void 0, brush).tip.size, builtin: false, spec: brush, ...colourOf(brush) });
75
75
  } catch (e2) {
76
76
  }
77
77
  }
@@ -82,15 +82,15 @@ function resolveCanvasBrush(brush, width, spec) {
82
82
  const sized = (b) => given === void 0 ? b : { ...b, tip: { ...b.tip, size: given } };
83
83
  if (typeof brush === "string") {
84
84
  if (spec !== void 0 && spec !== null) {
85
- const saved = _chunkRFJZGTHAcjs.resolveBrush.call(void 0, readCanvasBrushSpec(spec));
86
- if (!_chunkPXDIAYB6cjs.isBrushstrokeBrush.call(void 0, saved)) throw new Error(`Brush '${saved.id}' (${saved.name}) can't brush a canvas stroke: it is not a dry dab brush.`);
85
+ const saved = _chunkEU2ZZA6Lcjs.resolveBrush.call(void 0, readCanvasBrushSpec(spec));
86
+ if (!_chunkSTLTOISWcjs.isBrushstrokeBrush.call(void 0, saved)) throw new Error(`Brush '${saved.id}' (${saved.name}) can't brush a canvas stroke: it is not a dry dab brush.`);
87
87
  return sized(saved);
88
88
  }
89
89
  const preset = PRESETS.find((b) => b.id === brush);
90
90
  if (preset) return sized(preset);
91
- const other = _chunkRFJZGTHAcjs.BRUSH_PRESETS.find((b) => b.id === brush);
91
+ const other = _chunkEU2ZZA6Lcjs.BRUSH_PRESETS.find((b) => b.id === brush);
92
92
  if (other) throw new Error(`Brush '${brush}' (${other.name}) can't brush a canvas stroke: ${refusal(other)} Use one of: ${presetIds()}, or a saved brush the canvas can paint.`);
93
- throw new Error(`Unknown brush '${brush}'. ${_chunkRFJZGTHAcjs.closest.call(void 0, brush, PRESETS.map((b) => b.id))}Use one of the dry presets (${presetIds()}), a saved brush from the brush library, or tip settings ({ hardness, spacing, flow, \u2026 }).`);
93
+ throw new Error(`Unknown brush '${brush}'. ${_chunkEU2ZZA6Lcjs.closest.call(void 0, brush, PRESETS.map((b) => b.id))}Use one of the dry presets (${presetIds()}), a saved brush from the brush library, or tip settings ({ hardness, spacing, flow, \u2026 }).`);
94
94
  }
95
95
  if (!brush || typeof brush !== "object" || Array.isArray(brush)) {
96
96
  throw new Error("A brush is a preset or saved brush id (see listCanvasBrushes / canvas.listBrushes) or an object of tip settings.");
@@ -98,7 +98,7 @@ function resolveCanvasBrush(brush, width, spec) {
98
98
  return { size: _nullishCoalesce(given, () => ( 3)), ...brush };
99
99
  }
100
100
  function resolveCanvasPaint(paint) {
101
- const source = _chunkFQPUF2W2cjs.parsePaintSource.call(void 0, paint, "paint");
101
+ const source = _chunkNIBFKXMDcjs.parsePaintSource.call(void 0, paint, "paint");
102
102
  if (source.type === "gradient" && (source.map.by === "velocity" || source.map.by === "time")) {
103
103
  throw new Error(`paint.map.by "${source.map.by}" needs timed samples, which canvas strokes do not record; use distance, pressure, tilt, direction, across-tip or random.`);
104
104
  }
@@ -119,14 +119,14 @@ function strokeColor(shape) {
119
119
  const n = parseInt(parsed.hex.slice(1), 16);
120
120
  return [n >> 16 & 255, n >> 8 & 255, n & 255, Math.round(parsed.alpha * 255)];
121
121
  }
122
- var cache = new (0, _chunkPXDIAYB6cjs.BrushstrokeCache)(128);
122
+ var cache = new (0, _chunkSTLTOISWcjs.BrushstrokeCache)(128);
123
123
  var urls = /* @__PURE__ */ new WeakMap();
124
124
  function renderShapeBrushstrokeNow(shape, scale, place = {}) {
125
125
  const seed = shape.brush.seed;
126
126
  const textured = typeof seed === "number" && Number.isFinite(seed);
127
127
  const size = _nullishCoalesce(shape.brush.size, () => ( (textured ? void 0 : _nullishCoalesce(shape.strokeWidth, () => ( 3)))));
128
128
  const brush = resolveCanvasBrush(shape.brush.brush, size, shape.brush.spec);
129
- const points = _chunkTOID45I2cjs.pathDataToPolyline.call(void 0, shape.d);
129
+ const points = _chunk2WOGXEDXcjs.pathDataToPolyline.call(void 0, shape.d);
130
130
  if (!points.length) return null;
131
131
  const { pressure, tiltX, tiltY } = shape.brush;
132
132
  const input = {
@@ -149,7 +149,7 @@ function renderShapeBrushstrokeNow(shape, scale, place = {}) {
149
149
  if (!stroke.bounds) return null;
150
150
  let href = urls.get(stroke);
151
151
  if (href === void 0) {
152
- href = _chunkPXDIAYB6cjs.brushstrokeDataUrl.call(void 0, stroke);
152
+ href = _chunkSTLTOISWcjs.brushstrokeDataUrl.call(void 0, stroke);
153
153
  urls.set(stroke, href);
154
154
  }
155
155
  return { href, ...stroke.bounds, scale: stroke.scale };
@@ -164,8 +164,8 @@ function brushedShapeSvgNow(shape, size, scale, place = {}) {
164
164
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${f(size.width)}" height="${f(size.height)}" viewBox="0 0 ${f(size.width)} ${f(size.height)}">${content}</svg>`;
165
165
  }
166
166
  function swatchColour(brush, background, spec) {
167
- const facets = typeof brush !== "string" ? null : spec ? readCanvasBrushSpec(spec) : _chunkRFJZGTHAcjs.BRUSH_PRESETS.find((b) => b.id === brush);
168
- return background && facets ? _chunkVRK322ZCcjs.brushPreviewColours.call(void 0, facets, { paper: background, profile: _chunkRFJZGTHAcjs.CANVAS_PROFILE, keepPaper: true }).color : "#1f2937";
167
+ const facets = typeof brush !== "string" ? null : spec ? readCanvasBrushSpec(spec) : _chunkEU2ZZA6Lcjs.BRUSH_PRESETS.find((b) => b.id === brush);
168
+ return background && facets ? _chunkBPJSI4NTcjs.brushPreviewColours.call(void 0, facets, { paper: background, profile: _chunkEU2ZZA6Lcjs.CANVAS_PROFILE, keepPaper: true }).color : "#1f2937";
169
169
  }
170
170
  function brushSwatchNow(brush, options, spec) {
171
171
  const w = options.width && options.width > 8 ? options.width : 96;
@@ -153,3 +153,15 @@ export interface CanvasBrushPreset {
153
153
  /** The preset's own tip diameter in canvas units: a new brushed stroke's default size. */
154
154
  size: number;
155
155
  }
156
+ /** What the canvas brush picker is set to (`brushSettings()` of the draw controller). */
157
+ export interface CanvasBrushChoice {
158
+ /** The preset or saved brush id the pen draws with by hand, or null for a plain vector stroke. */
159
+ brush: string | null;
160
+ /** The stroke colour, or null while strokes take a gradient. */
161
+ color: string | null;
162
+ colorScheme: 'light' | 'dark';
163
+ /** "Keep my colour": choosing a brush keeps the stroke colour. */
164
+ colorLocked: boolean;
165
+ /** The colour is a brush's light / dark default and changes with the scheme. */
166
+ colorFollowsScheme: boolean;
167
+ }
@@ -153,3 +153,15 @@ export interface CanvasBrushPreset {
153
153
  /** The preset's own tip diameter in canvas units: a new brushed stroke's default size. */
154
154
  size: number;
155
155
  }
156
+ /** What the canvas brush picker is set to (`brushSettings()` of the draw controller). */
157
+ export interface CanvasBrushChoice {
158
+ /** The preset or saved brush id the pen draws with by hand, or null for a plain vector stroke. */
159
+ brush: string | null;
160
+ /** The stroke colour, or null while strokes take a gradient. */
161
+ color: string | null;
162
+ colorScheme: 'light' | 'dark';
163
+ /** "Keep my colour": choosing a brush keeps the stroke colour. */
164
+ colorLocked: boolean;
165
+ /** The colour is a brush's light / dark default and changes with the scheme. */
166
+ colorFollowsScheme: boolean;
167
+ }
@@ -11,7 +11,7 @@ import type { Point } from './types.cjs';
11
11
  import type { CanvasBrush, CanvasBrushPaint, CanvasBrushPreset, CanvasBrushSpec, CanvasBrushstroke } from './brushTypes.cjs';
12
12
  import type { BrushLibrary } from '../brushes/library.cjs';
13
13
  import type { BrushPreviewRenderer } from '../brushes/tools.cjs';
14
- export type { CanvasBrush, CanvasBrushPaint, CanvasBrushPaintMapping, CanvasBrushPaintStop, CanvasBrushPaper, CanvasBrushPreset, CanvasBrushSettings, CanvasBrushSpec, CanvasBrushstroke } from './brushTypes.cjs';
14
+ export type { CanvasBrush, CanvasBrushPaint, CanvasBrushPaintMapping, CanvasBrushPaintStop, CanvasBrushPaper, CanvasBrushChoice, CanvasBrushPreset, CanvasBrushSettings, CanvasBrushSpec, CanvasBrushstroke } from './brushTypes.cjs';
15
15
  export { brushstrokeScaleBucket };
16
16
  /** A brushed stroke's image, placed in the path's coordinates (the shape's view box). */
17
17
  export interface CanvasBrushstrokeImage {
@@ -11,7 +11,7 @@ import type { Point } from './types.js';
11
11
  import type { CanvasBrush, CanvasBrushPaint, CanvasBrushPreset, CanvasBrushSpec, CanvasBrushstroke } from './brushTypes.js';
12
12
  import type { BrushLibrary } from '../brushes/library.js';
13
13
  import type { BrushPreviewRenderer } from '../brushes/tools.js';
14
- export type { CanvasBrush, CanvasBrushPaint, CanvasBrushPaintMapping, CanvasBrushPaintStop, CanvasBrushPaper, CanvasBrushPreset, CanvasBrushSettings, CanvasBrushSpec, CanvasBrushstroke } from './brushTypes.js';
14
+ export type { CanvasBrush, CanvasBrushPaint, CanvasBrushPaintMapping, CanvasBrushPaintStop, CanvasBrushPaper, CanvasBrushChoice, CanvasBrushPreset, CanvasBrushSettings, CanvasBrushSpec, CanvasBrushstroke } from './brushTypes.js';
15
15
  export { brushstrokeScaleBucket };
16
16
  /** A brushed stroke's image, placed in the path's coordinates (the shape's view box). */
17
17
  export interface CanvasBrushstrokeImage {
@@ -7,7 +7,7 @@ import type { CanvasNode, Point } from './types.cjs';
7
7
  import { type FreehandDrawOptions, type FreehandPenSample, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool } from './freehand.cjs';
8
8
  import { type CanvasBrush } from './brushstroke.cjs';
9
9
  import type { BrushLibrary } from '../brushes/library.cjs';
10
- import type { CanvasBrushPreset } from './brushTypes.cjs';
10
+ import type { CanvasBrushPreset, CanvasBrushChoice } from './brushTypes.cjs';
11
11
  /** A stroke drawn by code or an agent (`drawStroke`). */
12
12
  export interface DrawStrokeInput {
13
13
  /** Points in canvas (flow) coordinates, at least one. */
@@ -45,6 +45,8 @@ export interface CanvasDrawControllerOptions<TNode extends CanvasNode = CanvasNo
45
45
  brushLibrary?: Pick<BrushLibrary, 'list' | 'get' | 'isBuiltin'>;
46
46
  /** The host's colour scheme (default light): a brush's light / dark default colour resolves to its side. */
47
47
  colorScheme?: 'light' | 'dark';
48
+ /** Start with the colour locked: choosing a brush keeps the stroke colour (see `setColorLocked`). */
49
+ colorLocked?: boolean;
48
50
  getNodes: () => TNode[];
49
51
  setNodes: (nodes: TNode[]) => void;
50
52
  history?: ArrangeHistoryTarget;
@@ -54,6 +56,8 @@ export interface CanvasDrawControllerOptions<TNode extends CanvasNode = CanvasNo
54
56
  generateNodeId?: () => string;
55
57
  onToolChange?: (tool: FreehandTool) => void;
56
58
  onStyleChange?: (style: FreehandStrokeStyle) => void;
59
+ /** The colour lock changed (`setColorLocked`). */
60
+ onColorLockChange?: (locked: boolean) => void;
57
61
  onActiveStrokeChange?: (stroke: FreehandStroke | null) => void;
58
62
  onStrokeComplete?: (node: TNode) => void;
59
63
  onNodesErase?: (erasedNodes: TNode[]) => void;
@@ -82,14 +86,25 @@ export declare function createCanvasDrawController<TNode extends CanvasNode = Ca
82
86
  /**
83
87
  * A brush picker's choice: brushes the pen and highlighter with `id` (`null`: a plain vector
84
88
  * stroke) at the brush's own size, embedding a saved brush, and makes its default colour
85
- * (resolved for the colour scheme) the stroke colour unless `keepColour`. Throws for a brush
86
- * the canvas can't paint. Resolves with the brush chosen.
89
+ * (resolved for the colour scheme) the stroke colour unless `keepColour` or the colour is
90
+ * locked (`setColorLocked`). A light / dark default resolves again when the scheme changes,
91
+ * until another colour is set. Throws for a brush the canvas can't paint. Resolves with the
92
+ * brush chosen.
87
93
  */
88
94
  selectBrush(id: string | null, choice?: {
89
95
  keepColour?: boolean;
90
96
  }): Promise<CanvasBrushPreset | null>;
91
- /** The host's colour scheme, for brushes' light / dark default colours. */
97
+ readonly colorScheme: "light" | "dark";
98
+ /**
99
+ * The host's colour scheme, for brushes' light / dark default colours: a stroke colour that
100
+ * came from one (`selectBrush`) resolves to the new side. Strokes already drawn keep theirs.
101
+ */
92
102
  setColorScheme(scheme: "light" | "dark"): void;
103
+ readonly colorLocked: boolean;
104
+ /** Locks the stroke colour ("Keep my colour"): choosing a brush with a default colour keeps it. */
105
+ setColorLocked(locked: boolean): void;
106
+ /** What the brush picker is set to: the brush, colour, scheme and lock (a snapshot). */
107
+ brushSettings(): CanvasBrushChoice;
93
108
  /** The saved brush to embed for a brush id (undefined for presets and tip settings); for a brush picker. */
94
109
  brushSpec: (brush: CanvasBrush) => Promise<import("./brushTypes.cjs").CanvasBrushSpec | undefined>;
95
110
  };
@@ -7,7 +7,7 @@ import type { CanvasNode, Point } from './types.js';
7
7
  import { type FreehandDrawOptions, type FreehandPenSample, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool } from './freehand.js';
8
8
  import { type CanvasBrush } from './brushstroke.js';
9
9
  import type { BrushLibrary } from '../brushes/library.js';
10
- import type { CanvasBrushPreset } from './brushTypes.js';
10
+ import type { CanvasBrushPreset, CanvasBrushChoice } from './brushTypes.js';
11
11
  /** A stroke drawn by code or an agent (`drawStroke`). */
12
12
  export interface DrawStrokeInput {
13
13
  /** Points in canvas (flow) coordinates, at least one. */
@@ -45,6 +45,8 @@ export interface CanvasDrawControllerOptions<TNode extends CanvasNode = CanvasNo
45
45
  brushLibrary?: Pick<BrushLibrary, 'list' | 'get' | 'isBuiltin'>;
46
46
  /** The host's colour scheme (default light): a brush's light / dark default colour resolves to its side. */
47
47
  colorScheme?: 'light' | 'dark';
48
+ /** Start with the colour locked: choosing a brush keeps the stroke colour (see `setColorLocked`). */
49
+ colorLocked?: boolean;
48
50
  getNodes: () => TNode[];
49
51
  setNodes: (nodes: TNode[]) => void;
50
52
  history?: ArrangeHistoryTarget;
@@ -54,6 +56,8 @@ export interface CanvasDrawControllerOptions<TNode extends CanvasNode = CanvasNo
54
56
  generateNodeId?: () => string;
55
57
  onToolChange?: (tool: FreehandTool) => void;
56
58
  onStyleChange?: (style: FreehandStrokeStyle) => void;
59
+ /** The colour lock changed (`setColorLocked`). */
60
+ onColorLockChange?: (locked: boolean) => void;
57
61
  onActiveStrokeChange?: (stroke: FreehandStroke | null) => void;
58
62
  onStrokeComplete?: (node: TNode) => void;
59
63
  onNodesErase?: (erasedNodes: TNode[]) => void;
@@ -82,14 +86,25 @@ export declare function createCanvasDrawController<TNode extends CanvasNode = Ca
82
86
  /**
83
87
  * A brush picker's choice: brushes the pen and highlighter with `id` (`null`: a plain vector
84
88
  * stroke) at the brush's own size, embedding a saved brush, and makes its default colour
85
- * (resolved for the colour scheme) the stroke colour unless `keepColour`. Throws for a brush
86
- * the canvas can't paint. Resolves with the brush chosen.
89
+ * (resolved for the colour scheme) the stroke colour unless `keepColour` or the colour is
90
+ * locked (`setColorLocked`). A light / dark default resolves again when the scheme changes,
91
+ * until another colour is set. Throws for a brush the canvas can't paint. Resolves with the
92
+ * brush chosen.
87
93
  */
88
94
  selectBrush(id: string | null, choice?: {
89
95
  keepColour?: boolean;
90
96
  }): Promise<CanvasBrushPreset | null>;
91
- /** The host's colour scheme, for brushes' light / dark default colours. */
97
+ readonly colorScheme: "light" | "dark";
98
+ /**
99
+ * The host's colour scheme, for brushes' light / dark default colours: a stroke colour that
100
+ * came from one (`selectBrush`) resolves to the new side. Strokes already drawn keep theirs.
101
+ */
92
102
  setColorScheme(scheme: "light" | "dark"): void;
103
+ readonly colorLocked: boolean;
104
+ /** Locks the stroke colour ("Keep my colour"): choosing a brush with a default colour keeps it. */
105
+ setColorLocked(locked: boolean): void;
106
+ /** What the brush picker is set to: the brush, colour, scheme and lock (a snapshot). */
107
+ brushSettings(): CanvasBrushChoice;
93
108
  /** The saved brush to embed for a brush id (undefined for presets and tip settings); for a brush picker. */
94
109
  brushSpec: (brush: CanvasBrush) => Promise<import("./brushTypes.js").CanvasBrushSpec | undefined>;
95
110
  };