@pixerate/editor 0.264.0 → 0.265.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 (46) hide show
  1. package/dist/animation-editor/index.cjs +60 -61
  2. package/dist/animation-editor/index.js +4 -5
  3. package/dist/brushes/index.cjs +73 -60
  4. package/dist/brushes/index.d.cts +1 -0
  5. package/dist/brushes/index.d.ts +1 -0
  6. package/dist/brushes/index.js +17 -4
  7. package/dist/brushes/preview.d.cts +59 -0
  8. package/dist/brushes/preview.d.ts +59 -0
  9. package/dist/brushes/tools.d.cts +12 -5
  10. package/dist/brushes/tools.d.ts +12 -5
  11. package/dist/{brushstrokeRender-3MOI7PH4.js → brushstrokeRender-4UB6NRJW.js} +11 -4
  12. package/dist/{brushstrokeRender-SMMPIJF2.cjs → brushstrokeRender-JQ2XQRUD.cjs} +22 -15
  13. package/dist/canvas/brushstroke.d.cts +6 -1
  14. package/dist/canvas/brushstroke.d.ts +6 -1
  15. package/dist/canvas/index.cjs +16 -17
  16. package/dist/canvas/index.js +2 -3
  17. package/dist/{chunk-F3KKR6DD.cjs → chunk-5OE4ZZ6V.cjs} +30 -30
  18. package/dist/{chunk-BY5EBP26.cjs → chunk-677777GH.cjs} +3 -3
  19. package/dist/{chunk-G5ADO47G.cjs → chunk-7NQOGWLM.cjs} +3 -2
  20. package/dist/{chunk-WWI6FLH2.js → chunk-7PW6VCNW.js} +2 -2
  21. package/dist/{chunk-CECCP2V7.js → chunk-BLR4KWYQ.js} +1 -1
  22. package/dist/chunk-DEBIFWY6.cjs +77 -0
  23. package/dist/{chunk-KXNZNOEF.cjs → chunk-DGXTEPCU.cjs} +94 -94
  24. package/dist/{chunk-3CI7FRMK.js → chunk-DVPQFMH6.js} +13 -1
  25. package/dist/{chunk-EE7SAYBF.js → chunk-J4SGJCPW.js} +3 -3
  26. package/dist/{chunk-A2IS7EHE.cjs → chunk-JBZRVLXV.cjs} +14 -2
  27. package/dist/{chunk-V7MJ4HIN.cjs → chunk-NOP4Y5AB.cjs} +23 -23
  28. package/dist/{chunk-FQC5TDB6.cjs → chunk-O53MOGXG.cjs} +35 -35
  29. package/dist/{chunk-4OJC4MCD.js → chunk-Q6RVVJW6.js} +1 -1
  30. package/dist/{chunk-HAUDEVMC.js → chunk-WY23AUCA.js} +2 -2
  31. package/dist/{chunk-JEML4FSA.js → chunk-XDNWQMHY.js} +3 -2
  32. package/dist/{chunk-ROBSFJ6F.js → chunk-Z2Z2OHRM.js} +1 -1
  33. package/dist/{chunk-USJX5SW4.cjs → chunk-ZHRVCW3M.cjs} +12 -12
  34. package/dist/chunk-ZS7LB2MV.js +77 -0
  35. package/dist/image-editor/index.cjs +788 -790
  36. package/dist/image-editor/index.js +6 -8
  37. package/dist/paint-editor/controller.d.cts +1 -1
  38. package/dist/paint-editor/controller.d.ts +1 -1
  39. package/dist/paint-editor/index.cjs +92 -87
  40. package/dist/paint-editor/index.js +16 -11
  41. package/dist/vector/index.cjs +970 -971
  42. package/dist/vector/index.js +5 -6
  43. package/package.json +1 -1
  44. package/skills/pixerate-brushes/SKILL.md +7 -2
  45. package/dist/chunk-FJBQTZS4.js +0 -17
  46. package/dist/chunk-LRTR4ASZ.cjs +0 -17
@@ -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-SMMPIJF2.cjs"))).catch((error) => {
77
+ loading ??= Promise.resolve().then(() => _interopRequireWildcard(require("./brushstrokeRender-JQ2XQRUD.cjs"))).catch((error) => {
78
78
  loading = null;
79
79
  throw error;
80
80
  });
@@ -117,7 +117,8 @@ async function renderCanvasBrushSwatch(brush, options = {}, spec) {
117
117
  return (await loadCanvasBrushstrokeRenderer()).brushSwatchNow(brush, options, spec);
118
118
  }
119
119
  var renderCanvasBrushPreview = async (brush, { width, height, color }) => {
120
- const url = await renderCanvasBrushSwatch(brush.id, { width, height, color, scale: 1 }, brush);
120
+ const { light: _light, ...plain } = brush;
121
+ const url = await renderCanvasBrushSwatch(brush.id, { width, height, color, scale: 1 }, plain);
121
122
  return { data: url.replace(/^data:image\/png;base64,/, ""), mimeType: "image/png" };
122
123
  };
123
124
 
@@ -7,7 +7,7 @@ import {
7
7
  listPresets,
8
8
  normalizeBrushSpec,
9
9
  resolveBrush
10
- } from "./chunk-EE7SAYBF.js";
10
+ } from "./chunk-J4SGJCPW.js";
11
11
  import {
12
12
  parseProvenance
13
13
  } from "./chunk-M6DNZNVY.js";
@@ -51,7 +51,7 @@ import {
51
51
  } from "./chunk-PWBZH3FK.js";
52
52
  import {
53
53
  brushColourHex
54
- } from "./chunk-FJBQTZS4.js";
54
+ } from "./chunk-DVPQFMH6.js";
55
55
  import {
56
56
  BrushstrokeCache,
57
57
  GRAIN_PATTERNS,
@@ -5,7 +5,7 @@ import {
5
5
  moveAnchorHandle,
6
6
  subpathSegment,
7
7
  subpathSegmentCount
8
- } from "./chunk-WWI6FLH2.js";
8
+ } from "./chunk-7PW6VCNW.js";
9
9
  import {
10
10
  segmentPoint
11
11
  } from "./chunk-WEIK3UYB.js";
@@ -0,0 +1,77 @@
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
+
3
+ var _chunk677777GHcjs = require('./chunk-677777GH.cjs');
4
+
5
+
6
+ var _chunkJBZRVLXVcjs = require('./chunk-JBZRVLXV.cjs');
7
+
8
+
9
+ var _chunkMLLTWAXHcjs = require('./chunk-MLLTWAXH.cjs');
10
+
11
+
12
+
13
+ var _chunkSXQHWXELcjs = require('./chunk-SXQHWXEL.cjs');
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+ var _chunk5UEFBM2Mcjs = require('./chunk-5UEFBM2M.cjs');
23
+
24
+ // src/brushes/preview.ts
25
+ var BRUSH_PREVIEW_DARK_PAPER = "#141414";
26
+ var BRUSH_PREVIEW_MIN_CONTRAST = 3;
27
+ var BRUSH_PREVIEW_FALLBACKS = {
28
+ dry: { light: "#3f3f46", dark: "#e4e4e7" },
29
+ ink: { light: "#1e293b", dark: "#e2e8f0" },
30
+ paint: { light: "#1d4ed8", dark: "#93c5fd" },
31
+ spray: { light: "#0f766e", dark: "#5eead4" },
32
+ other: { light: "#334155", dark: "#cbd5e1" },
33
+ tools: { light: "#475569", dark: "#cbd5e1" }
34
+ };
35
+ function brushPreviewsOnDark(brush) {
36
+ return (_nullishCoalesce(_optionalChain([brush, 'access', _ => _.light, 'optionalAccess', _2 => _2.amount]), () => ( 0))) > 0 && _optionalChain([brush, 'access', _3 => _3.tip, 'optionalAccess', _4 => _4.blend]) !== "multiply";
37
+ }
38
+ var hexOf = (c) => _nullishCoalesce(_chunkJBZRVLXVcjs.brushColourHex.call(void 0, c, "light"), () => ( "#ffffff"));
39
+ function brushPreviewStrength(brush) {
40
+ const opacity = _nullishCoalesce(brush.tip.opacity, () => ( 1));
41
+ const flow = _nullishCoalesce(brush.tip.flow, () => ( 1));
42
+ const grain = _nullishCoalesce(_optionalChain([brush, 'access', _5 => _5.behaviour, 'optionalAccess', _6 => _6.grain]), () => ( 0));
43
+ return Math.max(0.25, Math.min(1, 0.85 * opacity * (0.6 + 0.4 * flow) * (1 - 0.3 * grain)));
44
+ }
45
+ var over = (fg, bg, alpha) => ({ r: fg.r * alpha + bg.r * (1 - alpha), g: fg.g * alpha + bg.g * (1 - alpha), b: fg.b * alpha + bg.b * (1 - alpha), a: 1 });
46
+ function brushPreviewColours(brush, options = {}) {
47
+ const profile = _nullishCoalesce(options.profile, () => ( _chunk677777GHcjs.PAINT_PROFILE));
48
+ let background = profile.light === "full" && brushPreviewsOnDark(brush) ? BRUSH_PREVIEW_DARK_PAPER : hexOf(_nullishCoalesce(options.paper, () => ( "#ffffff")));
49
+ if (!options.keepPaper && brush.tip.blend === "multiply" && _chunk5UEFBM2Mcjs.relativeLuminance.call(void 0, _chunk5UEFBM2Mcjs.parseColor.call(void 0, background)) < 0.18) background = "#ffffff";
50
+ const bg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, background);
51
+ const scheme = _chunk5UEFBM2Mcjs.relativeLuminance.call(void 0, bg) < 0.18 ? "dark" : "light";
52
+ const own = brush.kind === "mark" ? _optionalChain([brush, 'access', _7 => _7.colour, 'optionalAccess', _8 => _8.default]) : void 0;
53
+ const ownHex = typeof own === "string" || _chunkMLLTWAXHcjs.isDualColor.call(void 0, own) ? _chunkJBZRVLXVcjs.brushColourHex.call(void 0, own, scheme) : null;
54
+ if (ownHex && brush.tip.blend === "multiply" && (_nullishCoalesce(_optionalChain([brush, 'access', _9 => _9.light, 'optionalAccess', _10 => _10.amount]), () => ( 0))) > 0 && scheme === "light") return { background, color: ownHex, scheme };
55
+ const group = brush.kind === "tool" ? "tools" : _nullishCoalesce(brush.medium, () => ( "other"));
56
+ const color = _nullishCoalesce(ownHex, () => ( _chunkJBZRVLXVcjs.brushColourHex.call(void 0, _nullishCoalesce(BRUSH_PREVIEW_FALLBACKS[group], () => ( BRUSH_PREVIEW_FALLBACKS.other)), scheme)));
57
+ const alpha = brushPreviewStrength(brush);
58
+ const reads = (c) => _chunk5UEFBM2Mcjs.contrastRatio.call(void 0, over(c, bg, alpha), bg) >= BRUSH_PREVIEW_MIN_CONTRAST;
59
+ const fg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, color);
60
+ if (reads(fg)) return { background, color, scheme };
61
+ const lch = _chunk5UEFBM2Mcjs.oklabToOklch.call(void 0, _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, fg));
62
+ const step = scheme === "dark" ? 0.01 : -0.01;
63
+ for (let l = lch.l + step; l >= 0 && l <= 1; l += step) {
64
+ const hex = _chunkSXQHWXELcjs.formatHex.call(void 0, _chunkSXQHWXELcjs.toSrgbGamut.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { ...lch, l }))));
65
+ if (reads(_chunk5UEFBM2Mcjs.parseColor.call(void 0, hex))) return { background, color: hex, scheme };
66
+ }
67
+ return { background, color: scheme === "dark" ? "#ffffff" : "#000000", scheme };
68
+ }
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+ exports.BRUSH_PREVIEW_DARK_PAPER = BRUSH_PREVIEW_DARK_PAPER; exports.BRUSH_PREVIEW_MIN_CONTRAST = BRUSH_PREVIEW_MIN_CONTRAST; exports.BRUSH_PREVIEW_FALLBACKS = BRUSH_PREVIEW_FALLBACKS; exports.brushPreviewsOnDark = brushPreviewsOnDark; exports.brushPreviewStrength = brushPreviewStrength; exports.brushPreviewColours = brushPreviewColours;