@pixerate/editor 0.264.1 → 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.
- package/dist/animation-editor/index.cjs +60 -61
- package/dist/animation-editor/index.js +4 -5
- package/dist/brushes/index.cjs +73 -60
- package/dist/brushes/index.d.cts +1 -0
- package/dist/brushes/index.d.ts +1 -0
- package/dist/brushes/index.js +17 -4
- package/dist/brushes/preview.d.cts +59 -0
- package/dist/brushes/preview.d.ts +59 -0
- package/dist/brushes/tools.d.cts +12 -5
- package/dist/brushes/tools.d.ts +12 -5
- package/dist/{brushstrokeRender-3MOI7PH4.js → brushstrokeRender-4UB6NRJW.js} +11 -4
- package/dist/{brushstrokeRender-SMMPIJF2.cjs → brushstrokeRender-JQ2XQRUD.cjs} +22 -15
- package/dist/canvas/brushstroke.d.cts +6 -1
- package/dist/canvas/brushstroke.d.ts +6 -1
- package/dist/canvas/index.cjs +16 -17
- package/dist/canvas/index.js +2 -3
- package/dist/{chunk-F3KKR6DD.cjs → chunk-5OE4ZZ6V.cjs} +30 -30
- package/dist/{chunk-BY5EBP26.cjs → chunk-677777GH.cjs} +3 -3
- package/dist/{chunk-G5ADO47G.cjs → chunk-7NQOGWLM.cjs} +3 -2
- package/dist/{chunk-WWI6FLH2.js → chunk-7PW6VCNW.js} +2 -2
- package/dist/{chunk-CECCP2V7.js → chunk-BLR4KWYQ.js} +1 -1
- package/dist/chunk-DEBIFWY6.cjs +77 -0
- package/dist/{chunk-KXNZNOEF.cjs → chunk-DGXTEPCU.cjs} +94 -94
- package/dist/{chunk-3CI7FRMK.js → chunk-DVPQFMH6.js} +13 -1
- package/dist/{chunk-EE7SAYBF.js → chunk-J4SGJCPW.js} +3 -3
- package/dist/{chunk-A2IS7EHE.cjs → chunk-JBZRVLXV.cjs} +14 -2
- package/dist/{chunk-V7MJ4HIN.cjs → chunk-NOP4Y5AB.cjs} +23 -23
- package/dist/{chunk-FQC5TDB6.cjs → chunk-O53MOGXG.cjs} +35 -35
- package/dist/{chunk-4OJC4MCD.js → chunk-Q6RVVJW6.js} +1 -1
- package/dist/{chunk-HAUDEVMC.js → chunk-WY23AUCA.js} +2 -2
- package/dist/{chunk-JEML4FSA.js → chunk-XDNWQMHY.js} +3 -2
- package/dist/{chunk-ROBSFJ6F.js → chunk-Z2Z2OHRM.js} +1 -1
- package/dist/{chunk-USJX5SW4.cjs → chunk-ZHRVCW3M.cjs} +12 -12
- package/dist/chunk-ZS7LB2MV.js +77 -0
- package/dist/image-editor/index.cjs +788 -790
- package/dist/image-editor/index.js +6 -8
- package/dist/paint-editor/index.cjs +88 -84
- package/dist/paint-editor/index.js +12 -8
- package/dist/vector/index.cjs +970 -971
- package/dist/vector/index.js +5 -6
- package/package.json +1 -1
- package/skills/pixerate-brushes/SKILL.md +7 -2
- package/dist/chunk-FJBQTZS4.js +0 -17
- package/dist/chunk-LRTR4ASZ.cjs +0 -17
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isDualColor,
|
|
3
|
+
resolveColor
|
|
4
|
+
} from "./chunk-VR6OGHU5.js";
|
|
5
|
+
|
|
1
6
|
// src/image-editor/layers/css-color.ts
|
|
2
7
|
var NAMED = {
|
|
3
8
|
aliceblue: "f0f8ff",
|
|
@@ -194,6 +199,13 @@ function parseCssColor(value) {
|
|
|
194
199
|
return null;
|
|
195
200
|
}
|
|
196
201
|
|
|
202
|
+
// src/brushes/colour.ts
|
|
203
|
+
function brushColourHex(value, scheme) {
|
|
204
|
+
const css = typeof value === "string" || isDualColor(value) ? resolveColor(value, scheme) : null;
|
|
205
|
+
return css ? parseCssColor(css)?.hex.toLowerCase() ?? null : null;
|
|
206
|
+
}
|
|
207
|
+
|
|
197
208
|
export {
|
|
198
|
-
parseCssColor
|
|
209
|
+
parseCssColor,
|
|
210
|
+
brushColourHex
|
|
199
211
|
};
|
|
@@ -2443,7 +2443,7 @@ var BRUSH_PRESETS = [
|
|
|
2443
2443
|
tip: { shape: "round", size: 3, hardness: 0.95, spacing: 0.05, opacity: 0.9 },
|
|
2444
2444
|
dynamics: { smoothing: 0.35, pressureSmoothing: 0.3, pressureOpacity: true, minSize: 0.7, opacityJitter: 0.08 },
|
|
2445
2445
|
behaviour: { grain: 0.15 },
|
|
2446
|
-
colour: { default: "#1e3a8a", palette: ["#1e3a8a", "#111827", "#b91c1c", "#166534"] }
|
|
2446
|
+
colour: { default: { light: "#1e3a8a", dark: "#93c5fd" }, palette: [{ light: "#1e3a8a", dark: "#93c5fd" }, { light: "#111827", dark: "#f3f4f6" }, "#b91c1c", "#166534"] }
|
|
2447
2447
|
},
|
|
2448
2448
|
// A gel pen: an even, opaque, saturated line.
|
|
2449
2449
|
{
|
|
@@ -2454,7 +2454,7 @@ var BRUSH_PRESETS = [
|
|
|
2454
2454
|
variety: "gel",
|
|
2455
2455
|
tip: { shape: "round", size: 4, spacing: 0.04 },
|
|
2456
2456
|
dynamics: { smoothing: 0.3, pressureSmoothing: 0.3, minSize: 0.8 },
|
|
2457
|
-
colour: { default: "#111827", palette: ["#111827", "#7c3aed", "#db2777", "#0891b2", "#16a34a", "#f59e0b"] }
|
|
2457
|
+
colour: { default: { light: "#111827", dark: "#f3f4f6" }, palette: [{ light: "#111827", dark: "#f3f4f6" }, "#7c3aed", "#db2777", "#0891b2", "#16a34a", "#f59e0b"] }
|
|
2458
2458
|
},
|
|
2459
2459
|
// A fineliner: one width, whatever the pressure.
|
|
2460
2460
|
{
|
|
@@ -2465,7 +2465,7 @@ var BRUSH_PRESETS = [
|
|
|
2465
2465
|
variety: "fineliner",
|
|
2466
2466
|
tip: { shape: "round", size: 2, spacing: 0.05 },
|
|
2467
2467
|
dynamics: { smoothing: 0.4, pressureSize: false },
|
|
2468
|
-
colour: { default: "#111827" }
|
|
2468
|
+
colour: { default: { light: "#111827", dark: "#f3f4f6" } }
|
|
2469
2469
|
},
|
|
2470
2470
|
// A wax crayon: waxy, catching the paper's peaks, a little uneven.
|
|
2471
2471
|
{
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
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
|
+
|
|
4
|
+
var _chunkMLLTWAXHcjs = require('./chunk-MLLTWAXH.cjs');
|
|
5
|
+
|
|
6
|
+
// src/image-editor/layers/css-color.ts
|
|
2
7
|
var NAMED = {
|
|
3
8
|
aliceblue: "f0f8ff",
|
|
4
9
|
antiquewhite: "faebd7",
|
|
@@ -194,6 +199,13 @@ function parseCssColor(value) {
|
|
|
194
199
|
return null;
|
|
195
200
|
}
|
|
196
201
|
|
|
202
|
+
// src/brushes/colour.ts
|
|
203
|
+
function brushColourHex(value, scheme) {
|
|
204
|
+
const css = typeof value === "string" || _chunkMLLTWAXHcjs.isDualColor.call(void 0, value) ? _chunkMLLTWAXHcjs.resolveColor.call(void 0, value, scheme) : null;
|
|
205
|
+
return css ? _nullishCoalesce(_optionalChain([parseCssColor, 'call', _ => _(css), 'optionalAccess', _2 => _2.hex, 'access', _3 => _3.toLowerCase, 'call', _4 => _4()]), () => ( null)) : null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
|
|
197
209
|
|
|
198
210
|
|
|
199
|
-
exports.parseCssColor = parseCssColor;
|
|
211
|
+
exports.parseCssColor = parseCssColor; exports.brushColourHex = brushColourHex;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkZHRVCW3Mcjs = require('./chunk-ZHRVCW3M.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunkGF2RBSDMcjs = require('./chunk-GF2RBSDM.cjs');
|
|
@@ -1361,12 +1361,12 @@ var unit = (x, y) => {
|
|
|
1361
1361
|
return l > 1e-12 && Number.isFinite(l) ? [x / l, y / l] : null;
|
|
1362
1362
|
};
|
|
1363
1363
|
function cubicOf(sp, i) {
|
|
1364
|
-
const s =
|
|
1364
|
+
const s = _chunkZHRVCW3Mcjs.subpathSegment.call(void 0, sp, i);
|
|
1365
1365
|
if (s.length === 4) return s;
|
|
1366
1366
|
const [a, b] = s;
|
|
1367
1367
|
return [a, [a[0] + (b[0] - a[0]) / 3, a[1] + (b[1] - a[1]) / 3], [a[0] + 2 * (b[0] - a[0]) / 3, a[1] + 2 * (b[1] - a[1]) / 3], b];
|
|
1368
1368
|
}
|
|
1369
|
-
var isLine = (sp, i) =>
|
|
1369
|
+
var isLine = (sp, i) => _chunkZHRVCW3Mcjs.subpathSegment.call(void 0, sp, i).length === 2;
|
|
1370
1370
|
function startTangent(c) {
|
|
1371
1371
|
for (let k = 1; k < 4; k++) {
|
|
1372
1372
|
const u = unit(c[k][0] - c[0][0], c[k][1] - c[0][1]);
|
|
@@ -1386,10 +1386,10 @@ function sample(c, n, out, withStart) {
|
|
|
1386
1386
|
}
|
|
1387
1387
|
var onAnchor = (a, h) => !h || Math.abs(h.x - a.x) < EPS && Math.abs(h.y - a.y) < EPS;
|
|
1388
1388
|
function tidy(a, keepType = true) {
|
|
1389
|
-
const next =
|
|
1389
|
+
const next = _chunkZHRVCW3Mcjs.cloneAnchor.call(void 0, a);
|
|
1390
1390
|
if (onAnchor(next, next.in)) delete next.in;
|
|
1391
1391
|
if (onAnchor(next, next.out)) delete next.out;
|
|
1392
|
-
const shown =
|
|
1392
|
+
const shown = _chunkZHRVCW3Mcjs.inferAnchorType.call(void 0, next);
|
|
1393
1393
|
const type = keepType && a.type ? a.type === "symmetric" && shown !== "symmetric" ? shown === "corner" ? "corner" : "smooth" : a.type === "smooth" && shown === "corner" ? "corner" : a.type : shown;
|
|
1394
1394
|
if (type === "corner") delete next.type;
|
|
1395
1395
|
else next.type = type;
|
|
@@ -1433,7 +1433,7 @@ function fitAcross(pts, N, t0, t1) {
|
|
|
1433
1433
|
return goldenMin(fit, 0, 1);
|
|
1434
1434
|
}
|
|
1435
1435
|
function removeAnchorKeepingShape(sp, index) {
|
|
1436
|
-
const anchors = sp.anchors.map(
|
|
1436
|
+
const anchors = sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor);
|
|
1437
1437
|
const n = anchors.length;
|
|
1438
1438
|
if (index < 0 || index >= n) return { anchors, closed: sp.closed };
|
|
1439
1439
|
if ((sp.closed || index > 0 && index < n - 1) && n >= 3) {
|
|
@@ -1467,12 +1467,12 @@ function removeAnchorKeepingShape(sp, index) {
|
|
|
1467
1467
|
}
|
|
1468
1468
|
function removeAnchorsKeepingShape(sp, indices) {
|
|
1469
1469
|
const order = [...new Set(indices)].filter((i) => i >= 0 && i < sp.anchors.length).sort((a, b) => b - a);
|
|
1470
|
-
return order.reduce((acc, i) => removeAnchorKeepingShape(acc, i), { anchors: sp.anchors.map(
|
|
1470
|
+
return order.reduce((acc, i) => removeAnchorKeepingShape(acc, i), { anchors: sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor), closed: sp.closed });
|
|
1471
1471
|
}
|
|
1472
1472
|
function bendSegment(sp, segment, t, p) {
|
|
1473
|
-
const anchors = sp.anchors.map(
|
|
1473
|
+
const anchors = sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor);
|
|
1474
1474
|
const n = anchors.length;
|
|
1475
|
-
if (segment < 0 || segment >=
|
|
1475
|
+
if (segment < 0 || segment >= _chunkZHRVCW3Mcjs.subpathSegmentCount.call(void 0, sp) || !Number.isFinite(t) || !Number.isFinite(p.x) || !Number.isFinite(p.y)) return { anchors, closed: sp.closed };
|
|
1476
1476
|
const tc = Math.min(0.95, Math.max(0.05, t));
|
|
1477
1477
|
const ia = segment;
|
|
1478
1478
|
const ib = (segment + 1) % n;
|
|
@@ -1483,16 +1483,16 @@ function bendSegment(sp, segment, t, p) {
|
|
|
1483
1483
|
const oy = (p.y - (a.y + (b.y - a.y) * tc)) / k;
|
|
1484
1484
|
const c1 = { x: a.x + (b.x - a.x) / 3 + ox, y: a.y + (b.y - a.y) / 3 + oy };
|
|
1485
1485
|
const c2 = { x: b.x + (a.x - b.x) / 3 + ox, y: b.y + (a.y - b.y) / 3 + oy };
|
|
1486
|
-
anchors[ia] =
|
|
1487
|
-
anchors[ib] =
|
|
1486
|
+
anchors[ia] = _chunkZHRVCW3Mcjs.moveAnchorHandle.call(void 0, a, "out", c1);
|
|
1487
|
+
anchors[ib] = _chunkZHRVCW3Mcjs.moveAnchorHandle.call(void 0, b, "in", c2);
|
|
1488
1488
|
return { anchors, closed: sp.closed };
|
|
1489
1489
|
}
|
|
1490
1490
|
function subpathPointAt(sp, segment, t) {
|
|
1491
|
-
const [x, y] = _chunkGF2RBSDMcjs.segmentPoint.call(void 0,
|
|
1491
|
+
const [x, y] = _chunkGF2RBSDMcjs.segmentPoint.call(void 0, _chunkZHRVCW3Mcjs.subpathSegment.call(void 0, sp, segment), t);
|
|
1492
1492
|
return { x, y };
|
|
1493
1493
|
}
|
|
1494
1494
|
function curvatureMoveAnchor(sp, index, q) {
|
|
1495
|
-
const anchors = sp.anchors.map(
|
|
1495
|
+
const anchors = sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor);
|
|
1496
1496
|
const a = sp.anchors[index];
|
|
1497
1497
|
if (!a) return { anchors, closed: sp.closed };
|
|
1498
1498
|
const own = [
|
|
@@ -1538,7 +1538,7 @@ function curvatureMoveAnchor(sp, index, q) {
|
|
|
1538
1538
|
function cutSubpathAt(sp, at) {
|
|
1539
1539
|
const n = sp.anchors.length;
|
|
1540
1540
|
const cuts = [...new Set(at)].filter((i) => Number.isInteger(i) && i >= 0 && i < n && (sp.closed || i > 0 && i < n - 1)).sort((a, b) => a - b);
|
|
1541
|
-
if (!cuts.length || n < 2) return [{ anchors: sp.anchors.map(
|
|
1541
|
+
if (!cuts.length || n < 2) return [{ anchors: sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor), closed: sp.closed }];
|
|
1542
1542
|
const first = cuts[0];
|
|
1543
1543
|
const run = sp.closed ? Array.from({ length: n + 1 }, (_, i) => sp.anchors[(first + i) % n]) : sp.anchors;
|
|
1544
1544
|
const cutSet = new Set(sp.closed ? [...cuts.map((c) => (c - first + n) % n), n] : cuts);
|
|
@@ -1546,7 +1546,7 @@ function cutSubpathAt(sp, at) {
|
|
|
1546
1546
|
let cur = [];
|
|
1547
1547
|
run.forEach((a, i) => {
|
|
1548
1548
|
if (!cutSet.has(i)) {
|
|
1549
|
-
cur.push(
|
|
1549
|
+
cur.push(_chunkZHRVCW3Mcjs.cloneAnchor.call(void 0, a));
|
|
1550
1550
|
return;
|
|
1551
1551
|
}
|
|
1552
1552
|
if (cur.length) {
|
|
@@ -1561,10 +1561,10 @@ function cutSubpathAt(sp, at) {
|
|
|
1561
1561
|
}
|
|
1562
1562
|
function splitSubpathAt(sp, segment, t, endTolerance = 1e-6) {
|
|
1563
1563
|
const n = sp.anchors.length;
|
|
1564
|
-
if (segment < 0 || segment >=
|
|
1564
|
+
if (segment < 0 || segment >= _chunkZHRVCW3Mcjs.subpathSegmentCount.call(void 0, sp)) return [{ anchors: sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor), closed: sp.closed }];
|
|
1565
1565
|
if (t <= endTolerance) return cutSubpathAt(sp, [segment]);
|
|
1566
1566
|
if (t >= 1 - endTolerance) return cutSubpathAt(sp, [(segment + 1) % n]);
|
|
1567
|
-
const { subpath, index } =
|
|
1567
|
+
const { subpath, index } = _chunkZHRVCW3Mcjs.insertAnchor.call(void 0, sp, segment, t);
|
|
1568
1568
|
return cutSubpathAt(subpath, [index]);
|
|
1569
1569
|
}
|
|
1570
1570
|
var endOf = (sp, last) => sp.anchors[last ? sp.anchors.length - 1 : 0];
|
|
@@ -1587,7 +1587,7 @@ function joinSubpaths(subpaths, tolerance) {
|
|
|
1587
1587
|
const closed = [];
|
|
1588
1588
|
let open = [];
|
|
1589
1589
|
for (const sp of subpaths) {
|
|
1590
|
-
const copy = { anchors: sp.anchors.map(
|
|
1590
|
+
const copy = { anchors: sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor), closed: sp.closed };
|
|
1591
1591
|
if (sp.closed || sp.anchors.length < 2) {
|
|
1592
1592
|
if (sp.anchors.length) closed.push(copy);
|
|
1593
1593
|
} else open.push(copy);
|
|
@@ -1642,7 +1642,7 @@ function smoothSubpath(sp, amount = 1, only) {
|
|
|
1642
1642
|
const t = Math.min(1, Math.max(0, amount));
|
|
1643
1643
|
const orig = sp.anchors;
|
|
1644
1644
|
const n = orig.length;
|
|
1645
|
-
const anchors = orig.map(
|
|
1645
|
+
const anchors = orig.map(_chunkZHRVCW3Mcjs.cloneAnchor);
|
|
1646
1646
|
if (n < 3 || t === 0) return { anchors, closed: sp.closed };
|
|
1647
1647
|
for (let i = 0; i < n; i++) {
|
|
1648
1648
|
if (!sp.closed && (i === 0 || i === n - 1)) continue;
|
|
@@ -1671,8 +1671,8 @@ function smoothSubpath(sp, amount = 1, only) {
|
|
|
1671
1671
|
}
|
|
1672
1672
|
function segsOf(sp) {
|
|
1673
1673
|
const out = [];
|
|
1674
|
-
for (let i = 0; i <
|
|
1675
|
-
const s =
|
|
1674
|
+
for (let i = 0; i < _chunkZHRVCW3Mcjs.subpathSegmentCount.call(void 0, sp); i++) {
|
|
1675
|
+
const s = _chunkZHRVCW3Mcjs.subpathSegment.call(void 0, sp, i);
|
|
1676
1676
|
out.push(s.length === 2 ? { c: s, line: true } : { c: s, line: false });
|
|
1677
1677
|
}
|
|
1678
1678
|
return out;
|
|
@@ -1729,7 +1729,7 @@ function removeRedundantPoints(sp, tolerance) {
|
|
|
1729
1729
|
const tol = Math.max(tolerance, 1e-9);
|
|
1730
1730
|
const types = new Map(sp.anchors.filter((a) => a.type).map((a) => [`${a.x},${a.y}`, a.type]));
|
|
1731
1731
|
const segs = segsOf(sp).filter((s) => !isZeroSeg(s));
|
|
1732
|
-
if (!segs.length) return { anchors: sp.anchors.map(
|
|
1732
|
+
if (!segs.length) return { anchors: sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor), closed: sp.closed };
|
|
1733
1733
|
const minSegs = sp.closed ? 2 : 1;
|
|
1734
1734
|
let changed = true;
|
|
1735
1735
|
while (changed && segs.length > minSegs) {
|
|
@@ -1747,7 +1747,7 @@ function removeRedundantPoints(sp, tolerance) {
|
|
|
1747
1747
|
break;
|
|
1748
1748
|
}
|
|
1749
1749
|
}
|
|
1750
|
-
return _nullishCoalesce(segsToSubpath(segs, sp.closed, types), () => ( { anchors: sp.anchors.map(
|
|
1750
|
+
return _nullishCoalesce(segsToSubpath(segs, sp.closed, types), () => ( { anchors: sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor), closed: sp.closed }));
|
|
1751
1751
|
}
|
|
1752
1752
|
|
|
1753
1753
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkZHRVCW3Mcjs = require('./chunk-ZHRVCW3M.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -37,7 +37,7 @@ var lerpP = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
|
|
37
37
|
var toP = (v) => [v.x, v.y];
|
|
38
38
|
var mapP = (m, p) => [m[0] * p[0] + m[2] * p[1] + m[4], m[1] * p[0] + m[3] * p[1] + m[5]];
|
|
39
39
|
var curvesOf = (c) => Math.max(0, (c.pts.length - 1) / 3) | 0;
|
|
40
|
-
function subpathToMorphContour(sp, m =
|
|
40
|
+
function subpathToMorphContour(sp, m = _chunkZHRVCW3Mcjs.IDENTITY_MATRIX) {
|
|
41
41
|
const n = sp.anchors.length;
|
|
42
42
|
if (!n) return null;
|
|
43
43
|
const first = mapP(m, toP(sp.anchors[0]));
|
|
@@ -67,8 +67,8 @@ function isStraight(p0, p1, p2, p3) {
|
|
|
67
67
|
const u2 = along(p2);
|
|
68
68
|
return off(p1) < tol && off(p2) < tol && u1 >= -1e-9 && u1 <= 1 + 1e-9 && u2 >= -1e-9 && u2 <= 1 + 1e-9;
|
|
69
69
|
}
|
|
70
|
-
function morphContourToSubpath(c, m =
|
|
71
|
-
const pts =
|
|
70
|
+
function morphContourToSubpath(c, m = _chunkZHRVCW3Mcjs.IDENTITY_MATRIX, closed = c.closed) {
|
|
71
|
+
const pts = _chunkZHRVCW3Mcjs.isIdentityMatrix.call(void 0, m) ? c.pts : c.pts.map((p) => mapP(m, p));
|
|
72
72
|
const curves = curvesOf(c);
|
|
73
73
|
const dropLast = closed && c.closed && curves > 0;
|
|
74
74
|
const count = dropLast ? curves : curves + 1;
|
|
@@ -84,7 +84,7 @@ function morphContourToSubpath(c, m = _chunkUSJX5SW4cjs.IDENTITY_MATRIX, closed
|
|
|
84
84
|
anchors[(k + 1) % count].in = { x: p2[0], y: p2[1] };
|
|
85
85
|
}
|
|
86
86
|
for (const a of anchors) {
|
|
87
|
-
const type =
|
|
87
|
+
const type = _chunkZHRVCW3Mcjs.inferAnchorType.call(void 0, a);
|
|
88
88
|
if (type !== "corner") a.type = type;
|
|
89
89
|
}
|
|
90
90
|
const isClosed = closed && curves > 0;
|
|
@@ -267,7 +267,7 @@ function bestStart(fixed, free, useShapeContext) {
|
|
|
267
267
|
return best;
|
|
268
268
|
}
|
|
269
269
|
function placeIn(c, from, to) {
|
|
270
|
-
const b =
|
|
270
|
+
const b = _chunkZHRVCW3Mcjs.unionBounds.call(void 0, [boundsOfPoints(c.pts)]);
|
|
271
271
|
const p = b ? [b.x + b.width / 2, b.y + b.height / 2] : c.pts[0];
|
|
272
272
|
if (!from || !to) return p;
|
|
273
273
|
const fx = from.width > 0 ? (p[0] - from.x) / from.width : 0.5;
|
|
@@ -456,7 +456,7 @@ function interpolateVectorColor(a, b, t) {
|
|
|
456
456
|
}
|
|
457
457
|
function resampleGradientStops(g, offsets) {
|
|
458
458
|
return offsets.map((offset) => {
|
|
459
|
-
const s =
|
|
459
|
+
const s = _chunkZHRVCW3Mcjs.sampleVectorGradient.call(void 0, g, offset);
|
|
460
460
|
return s.opacity < 1 ? { offset, color: s.color, opacity: Math.round(s.opacity * 1e4) / 1e4 } : { offset, color: s.color };
|
|
461
461
|
});
|
|
462
462
|
}
|
|
@@ -467,11 +467,11 @@ function lerpAngle(a, b, t) {
|
|
|
467
467
|
var lerpPoint = (a, b, t) => ({ x: lerpN(a.x, b.x, t), y: lerpN(a.y, b.y, t) });
|
|
468
468
|
var sameColourModel = (a, b) => (_nullishCoalesce(a.interpolation, () => ( "srgb"))) === (_nullishCoalesce(b.interpolation, () => ( "srgb"))) && (_nullishCoalesce(a.smoothness, () => ( 0))) === (_nullishCoalesce(b.smoothness, () => ( 0)));
|
|
469
469
|
function lerpStops(a, b, t) {
|
|
470
|
-
let stopsA =
|
|
471
|
-
let stopsB =
|
|
470
|
+
let stopsA = _chunkZHRVCW3Mcjs.sortedVectorGradientStops.call(void 0, a);
|
|
471
|
+
let stopsB = _chunkZHRVCW3Mcjs.sortedVectorGradientStops.call(void 0, b);
|
|
472
472
|
const resampled = stopsA.length !== stopsB.length || !sameColourModel(a, b);
|
|
473
473
|
if (resampled) {
|
|
474
|
-
const offs = [...
|
|
474
|
+
const offs = [..._chunkZHRVCW3Mcjs.expandVectorGradientStops.call(void 0, a), ..._chunkZHRVCW3Mcjs.expandVectorGradientStops.call(void 0, b), ...stopsA, ...stopsB].map((s) => s.offset).filter(Number.isFinite).sort((x, y) => x - y);
|
|
475
475
|
const common = offs.filter((o, i) => i === 0 || o - offs[i - 1] > 1e-4);
|
|
476
476
|
stopsA = resampleGradientStops(a, common);
|
|
477
477
|
stopsB = resampleGradientStops(b, common);
|
|
@@ -498,8 +498,8 @@ function lerpGradient(a, b, t) {
|
|
|
498
498
|
}
|
|
499
499
|
if (near.spread && near.spread !== "pad") out.spread = near.spread;
|
|
500
500
|
if (near.strokeMode && near.strokeMode !== "within") out.strokeMode = near.strokeMode;
|
|
501
|
-
const ea =
|
|
502
|
-
const eb =
|
|
501
|
+
const ea = _chunkZHRVCW3Mcjs.hasExplicitGradientGeometry.call(void 0, a);
|
|
502
|
+
const eb = _chunkZHRVCW3Mcjs.hasExplicitGradientGeometry.call(void 0, b);
|
|
503
503
|
if (!ea && !eb) {
|
|
504
504
|
if (a.angle !== void 0 || b.angle !== void 0 || a.type === "linear" || a.type === "reflected") {
|
|
505
505
|
const fallback = a.type === "linear" || a.type === "reflected" ? 180 : 90;
|
|
@@ -512,10 +512,10 @@ function lerpGradient(a, b, t) {
|
|
|
512
512
|
}
|
|
513
513
|
return out;
|
|
514
514
|
}
|
|
515
|
-
const pa =
|
|
516
|
-
const pb =
|
|
515
|
+
const pa = _chunkZHRVCW3Mcjs.vectorGradientPoints.call(void 0, a);
|
|
516
|
+
const pb = _chunkZHRVCW3Mcjs.vectorGradientPoints.call(void 0, b);
|
|
517
517
|
if (pa.units !== pb.units) {
|
|
518
|
-
const src =
|
|
518
|
+
const src = _chunkZHRVCW3Mcjs.explicitVectorGradient.call(void 0, near);
|
|
519
519
|
return { ...src, stops: out.stops, ...out.interpolation ? { interpolation: out.interpolation } : {}, ...out.smoothness ? { smoothness: out.smoothness } : {} };
|
|
520
520
|
}
|
|
521
521
|
out.start = lerpPoint(pa.start, pb.start, t);
|
|
@@ -535,14 +535,14 @@ function solidLike(color, like) {
|
|
|
535
535
|
function interpolateVectorPaint(a, b, t) {
|
|
536
536
|
if (t <= 0) return a;
|
|
537
537
|
if (t >= 1) return b;
|
|
538
|
-
const pa =
|
|
539
|
-
const pb =
|
|
538
|
+
const pa = _chunkZHRVCW3Mcjs.hasPaint.call(void 0, a);
|
|
539
|
+
const pb = _chunkZHRVCW3Mcjs.hasPaint.call(void 0, b);
|
|
540
540
|
if (!pa && !pb) return t < 0.5 ? a : b;
|
|
541
541
|
if (typeof a === "string" && pa && typeof b === "string" && pb) return interpolateVectorColor(a, b, t);
|
|
542
542
|
if (!pa && typeof b === "string") return interpolateVectorColor("transparent", b, t);
|
|
543
543
|
if (!pb && typeof a === "string") return interpolateVectorColor(a, "transparent", t);
|
|
544
|
-
const ga = pa &&
|
|
545
|
-
const gb = pb &&
|
|
544
|
+
const ga = pa && _chunkZHRVCW3Mcjs.isVectorGradient.call(void 0, a) ? a : null;
|
|
545
|
+
const gb = pb && _chunkZHRVCW3Mcjs.isVectorGradient.call(void 0, b) ? b : null;
|
|
546
546
|
if (ga && gb) return _nullishCoalesce(lerpGradient(ga, gb, t), () => ( (t < 0.5 ? a : b)));
|
|
547
547
|
if (gb) return _nullishCoalesce(lerpGradient(solidLike(pa ? a : null, gb), gb, t), () => ( b));
|
|
548
548
|
if (ga) return _nullishCoalesce(lerpGradient(ga, solidLike(pb ? b : null, ga), t), () => ( a));
|
|
@@ -553,8 +553,8 @@ function interpolateWidthProfiles(a, b, t) {
|
|
|
553
553
|
const at = [..._nullishCoalesce(a, () => ( [])), ..._nullishCoalesce(b, () => ( [])), { t: 0 }, { t: 1 }].map((p) => p.t).sort((x, y) => x - y);
|
|
554
554
|
const ts = at.filter((v, i) => i === 0 || v - at[i - 1] > 1e-6);
|
|
555
555
|
return ts.map((pos) => {
|
|
556
|
-
const x =
|
|
557
|
-
const y =
|
|
556
|
+
const x = _chunkZHRVCW3Mcjs.widthProfileAt.call(void 0, a, pos);
|
|
557
|
+
const y = _chunkZHRVCW3Mcjs.widthProfileAt.call(void 0, b, pos);
|
|
558
558
|
return { t: pos, left: lerpN(x.left, y.left, t), right: lerpN(x.right, y.right, t) };
|
|
559
559
|
});
|
|
560
560
|
}
|
|
@@ -597,7 +597,7 @@ function reversedStyle(s) {
|
|
|
597
597
|
out.endArrow = s.startArrow;
|
|
598
598
|
out.startArrowScale = s.endArrowScale;
|
|
599
599
|
out.endArrowScale = s.startArrowScale;
|
|
600
|
-
if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile =
|
|
600
|
+
if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile = _chunkZHRVCW3Mcjs.reverseWidthProfile.call(void 0, s.strokeWidthProfile);
|
|
601
601
|
for (const k of ["startArrow", "endArrow", "startArrowScale", "endArrowScale"]) if (out[k] === void 0) delete out[k];
|
|
602
602
|
return out;
|
|
603
603
|
}
|
|
@@ -623,19 +623,19 @@ function styleOf(n) {
|
|
|
623
623
|
return out;
|
|
624
624
|
}
|
|
625
625
|
function contoursOf(node, m) {
|
|
626
|
-
return
|
|
626
|
+
return _chunkZHRVCW3Mcjs.expandVectorCorners.call(void 0, node.subpaths).map((sp) => subpathToMorphContour(sp, m)).filter((c) => !!c);
|
|
627
627
|
}
|
|
628
|
-
function preparePathMorph(a, b, options, ma =
|
|
628
|
+
function preparePathMorph(a, b, options, ma = _chunkZHRVCW3Mcjs.nodeMatrix.call(void 0, a), mb = _chunkZHRVCW3Mcjs.nodeMatrix.call(void 0, b)) {
|
|
629
629
|
const corr = correspondMorphContours(contoursOf(a, ma), contoursOf(b, mb), options);
|
|
630
630
|
const sim = procrustes(corr.a, corr.b);
|
|
631
631
|
const styleA = styleOf(a);
|
|
632
632
|
const styleB = corr.reversed ? reversedStyle(styleOf(b)) : styleOf(b);
|
|
633
|
-
const rigid = !
|
|
633
|
+
const rigid = !_chunkZHRVCW3Mcjs.isIdentityMatrix.call(void 0, ma) || !_chunkZHRVCW3Mcjs.isIdentityMatrix.call(void 0, mb);
|
|
634
634
|
const id = _nullishCoalesce(options.id, () => ( a.id));
|
|
635
635
|
return (t) => {
|
|
636
636
|
const contours = interpolateMorphContours(corr.a, corr.b, t, { linear: options.linear, rigidity: options.rigidity, similarity: sim });
|
|
637
|
-
const m = rigid ? interpolateRigidMatrix(ma, mb, t) :
|
|
638
|
-
const back = rigid ?
|
|
637
|
+
const m = rigid ? interpolateRigidMatrix(ma, mb, t) : _chunkZHRVCW3Mcjs.IDENTITY_MATRIX;
|
|
638
|
+
const back = rigid ? _chunkZHRVCW3Mcjs.invertMatrix.call(void 0, m) : _chunkZHRVCW3Mcjs.IDENTITY_MATRIX;
|
|
639
639
|
const subpaths = contours.map((c, k) => {
|
|
640
640
|
const closed = t <= 0 ? corr.a[k].closed : t >= 1 ? corr.b[k].closed : corr.a[k].closed && corr.b[k].closed;
|
|
641
641
|
return morphContourToSubpath({ closed: corr.a[k].closed && corr.b[k].closed, pts: c.pts }, back, closed);
|
|
@@ -643,14 +643,14 @@ function preparePathMorph(a, b, options, ma = _chunkUSJX5SW4cjs.nodeMatrix.call(
|
|
|
643
643
|
const node = { id, type: "path", subpaths, ...interpolateVectorStyle(styleA, styleB, t) };
|
|
644
644
|
const opacity = lerpN(_nullishCoalesce(a.opacity, () => ( 1)), _nullishCoalesce(b.opacity, () => ( 1)), t);
|
|
645
645
|
if (opacity < 1) node.opacity = opacity;
|
|
646
|
-
if (rigid && !
|
|
646
|
+
if (rigid && !_chunkZHRVCW3Mcjs.isIdentityMatrix.call(void 0, m)) node.transform = m;
|
|
647
647
|
return node;
|
|
648
648
|
};
|
|
649
649
|
}
|
|
650
|
-
function flattenPaths(node, parent =
|
|
651
|
-
const m =
|
|
650
|
+
function flattenPaths(node, parent = _chunkZHRVCW3Mcjs.IDENTITY_MATRIX) {
|
|
651
|
+
const m = _chunkZHRVCW3Mcjs.multiplyMatrices.call(void 0, _chunkZHRVCW3Mcjs.nodeMatrix.call(void 0, node), parent);
|
|
652
652
|
if (node.type === "path") return [{ path: node, m, opacity: 1 }];
|
|
653
|
-
if (node.type === "text" || node.type === "instance") return flattenPaths(
|
|
653
|
+
if (node.type === "text" || node.type === "instance") return flattenPaths(_chunkZHRVCW3Mcjs.expandVectorAppearance.call(void 0, node), parent);
|
|
654
654
|
const o = _nullishCoalesce(node.opacity, () => ( 1));
|
|
655
655
|
return node.children.filter((c) => c.visible !== false).flatMap((c) => flattenPaths(c, m)).map((e) => ({ ...e, opacity: e.opacity * o }));
|
|
656
656
|
}
|
|
@@ -672,8 +672,8 @@ function createVectorMorph(a, b, options = {}) {
|
|
|
672
672
|
}
|
|
673
673
|
const pa = flattenPaths(a);
|
|
674
674
|
const pb = flattenPaths(b);
|
|
675
|
-
const ba =
|
|
676
|
-
const bb =
|
|
675
|
+
const ba = _chunkZHRVCW3Mcjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
|
|
676
|
+
const bb = _chunkZHRVCW3Mcjs.unionBounds.call(void 0, pb.map((e) => placedBounds(e.path, e.m)));
|
|
677
677
|
const id = _nullishCoalesce(options.id, () => ( a.id));
|
|
678
678
|
const parts = [];
|
|
679
679
|
const opacities = [];
|
|
@@ -685,10 +685,10 @@ function createVectorMorph(a, b, options = {}) {
|
|
|
685
685
|
parts.push(preparePathMorph(x.path, y.path, sub, x.m, y.m));
|
|
686
686
|
opacities.push([x.opacity, y.opacity]);
|
|
687
687
|
} else if (x) {
|
|
688
|
-
parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m,
|
|
688
|
+
parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m, _chunkZHRVCW3Mcjs.IDENTITY_MATRIX));
|
|
689
689
|
opacities.push([x.opacity, x.opacity]);
|
|
690
690
|
} else if (y) {
|
|
691
|
-
parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub,
|
|
691
|
+
parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub, _chunkZHRVCW3Mcjs.IDENTITY_MATRIX, y.m));
|
|
692
692
|
opacities.push([y.opacity, y.opacity]);
|
|
693
693
|
}
|
|
694
694
|
}
|
|
@@ -108,7 +108,7 @@ import {
|
|
|
108
108
|
transformTextRect,
|
|
109
109
|
translateMatrix,
|
|
110
110
|
warpPresetMesh
|
|
111
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-7PW6VCNW.js";
|
|
112
112
|
import {
|
|
113
113
|
bezierPathBounds,
|
|
114
114
|
outlineStroke,
|
|
@@ -119,7 +119,7 @@ import {
|
|
|
119
119
|
} from "./chunk-WEIK3UYB.js";
|
|
120
120
|
import {
|
|
121
121
|
parseCssColor
|
|
122
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-DVPQFMH6.js";
|
|
123
123
|
import {
|
|
124
124
|
MAX_BRUSH_SIZE
|
|
125
125
|
} from "./chunk-GCVFEPJG.js";
|
|
@@ -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 ??= import("./brushstrokeRender-
|
|
77
|
+
loading ??= import("./brushstrokeRender-4UB6NRJW.js").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
|
|
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 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk677777GHcjs = require('./chunk-677777GH.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkCVFAAZXEcjs = require('./chunk-CVFAAZXE.cjs');
|
|
@@ -51,7 +51,7 @@ var _chunkGF2RBSDMcjs = require('./chunk-GF2RBSDM.cjs');
|
|
|
51
51
|
var _chunkNM3G4VQTcjs = require('./chunk-NM3G4VQT.cjs');
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
var
|
|
54
|
+
var _chunkJBZRVLXVcjs = require('./chunk-JBZRVLXV.cjs');
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
|
|
@@ -2536,11 +2536,11 @@ function vectorExtrudeFaces(path, params) {
|
|
|
2536
2536
|
|
|
2537
2537
|
// src/vector/brushstroke.ts
|
|
2538
2538
|
var VECTOR_BRUSHSTROKE_SCALE = 2;
|
|
2539
|
-
var PRESETS =
|
|
2539
|
+
var PRESETS = _chunk677777GHcjs.listPresets.call(void 0, _chunk677777GHcjs.VECTOR_PROFILE).map((spec) => _chunk677777GHcjs.BUILTIN_BRUSHES.find((b) => b.id === spec.id));
|
|
2540
2540
|
function admitted(spec) {
|
|
2541
2541
|
try {
|
|
2542
|
-
const brush =
|
|
2543
|
-
return
|
|
2542
|
+
const brush = _chunk677777GHcjs.normalizeBrushSpec.call(void 0, spec);
|
|
2543
|
+
return _chunk677777GHcjs.checkBrush.call(void 0, brush, _chunk677777GHcjs.VECTOR_PROFILE).ok && _chunkPXDIAYB6cjs.isBrushstrokeBrush.call(void 0, _chunk677777GHcjs.resolveBrush.call(void 0, brush)) ? brush : null;
|
|
2544
2544
|
} catch (e4) {
|
|
2545
2545
|
return null;
|
|
2546
2546
|
}
|
|
@@ -2549,7 +2549,7 @@ function vectorBrushstrokeBrushes(user = []) {
|
|
|
2549
2549
|
const out = [...PRESETS];
|
|
2550
2550
|
for (const raw of user) {
|
|
2551
2551
|
const brush = admitted(raw);
|
|
2552
|
-
if (brush && !out.some((b) => b.id === brush.id)) out.push(
|
|
2552
|
+
if (brush && !out.some((b) => b.id === brush.id)) out.push(_chunk677777GHcjs.resolveBrush.call(void 0, brush));
|
|
2553
2553
|
}
|
|
2554
2554
|
return out;
|
|
2555
2555
|
}
|
|
@@ -2559,7 +2559,7 @@ function vectorBrushstrokeBrush(id) {
|
|
|
2559
2559
|
function vectorBrushstrokeBrushOf(brush) {
|
|
2560
2560
|
if (brush.spec) {
|
|
2561
2561
|
const saved = admitted(brush.spec);
|
|
2562
|
-
return saved && saved.id === brush.brushId ?
|
|
2562
|
+
return saved && saved.id === brush.brushId ? _chunk677777GHcjs.resolveBrush.call(void 0, saved) : null;
|
|
2563
2563
|
}
|
|
2564
2564
|
return vectorBrushstrokeBrush(brush.brushId);
|
|
2565
2565
|
}
|
|
@@ -2567,15 +2567,15 @@ function vectorBrushstrokeBrushError(id, user = []) {
|
|
|
2567
2567
|
if (vectorBrushstrokeBrush(id)) return null;
|
|
2568
2568
|
const saved = user.find((b) => b.id === id);
|
|
2569
2569
|
const ids = vectorBrushstrokeBrushes(user).map((b) => b.id);
|
|
2570
|
-
const reasons = (b) =>
|
|
2570
|
+
const reasons = (b) => _chunk677777GHcjs.checkBrush.call(void 0, b, _chunk677777GHcjs.VECTOR_PROFILE).issues.filter((i) => i.severity === "error").map((i) => `${i.reason} ${i.fix}`).join(" ") || "it is not a dry dab brush.";
|
|
2571
2571
|
if (saved) return admitted(saved) ? null : `Brush "${id}" (${saved.name}) can't paint a brushstroke: ${reasons(saved)} Use one of: ${ids.join(", ")}.`;
|
|
2572
|
-
const preset =
|
|
2572
|
+
const preset = _chunk677777GHcjs.BRUSH_PRESETS.find((b) => b.id === id);
|
|
2573
2573
|
if (preset) return `Brush "${id}" (${preset.name}) can't paint a brushstroke: ${reasons(preset)} Use one of: ${ids.join(", ")}.`;
|
|
2574
|
-
return `Unknown brush "${id}". ${
|
|
2574
|
+
return `Unknown brush "${id}". ${_chunk677777GHcjs.closest.call(void 0, id, ids)}Use one of: ${ids.join(", ")} (vector.listBrushes lists them).`;
|
|
2575
2575
|
}
|
|
2576
2576
|
function vectorBrushstrokeDefaultColour(id, user = [], scheme = "light") {
|
|
2577
|
-
const brush = _nullishCoalesce(
|
|
2578
|
-
return brush ?
|
|
2577
|
+
const brush = _nullishCoalesce(_chunk677777GHcjs.BRUSH_PRESETS.find((b) => b.id === id), () => ( user.find((b) => b.id === id)));
|
|
2578
|
+
return brush ? _chunkJBZRVLXVcjs.brushColourHex.call(void 0, _optionalChain([brush, 'access', _55 => _55.colour, 'optionalAccess', _56 => _56.default]), scheme) : null;
|
|
2579
2579
|
}
|
|
2580
2580
|
function sanitizeVectorBrushstroke(value, user = []) {
|
|
2581
2581
|
if (!value || typeof value !== "object") return null;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PAINT_PROFILE
|
|
3
|
+
} from "./chunk-J4SGJCPW.js";
|
|
4
|
+
import {
|
|
5
|
+
brushColourHex
|
|
6
|
+
} from "./chunk-DVPQFMH6.js";
|
|
7
|
+
import {
|
|
8
|
+
isDualColor
|
|
9
|
+
} from "./chunk-VR6OGHU5.js";
|
|
10
|
+
import {
|
|
11
|
+
formatHex,
|
|
12
|
+
toSrgbGamut
|
|
13
|
+
} from "./chunk-JC2SHA4A.js";
|
|
14
|
+
import {
|
|
15
|
+
contrastRatio,
|
|
16
|
+
oklabToOklch,
|
|
17
|
+
oklabToRgb,
|
|
18
|
+
oklchToOklab,
|
|
19
|
+
parseColor,
|
|
20
|
+
relativeLuminance,
|
|
21
|
+
rgbToOklab
|
|
22
|
+
} from "./chunk-MHLU6GRJ.js";
|
|
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 (brush.light?.amount ?? 0) > 0 && brush.tip?.blend !== "multiply";
|
|
37
|
+
}
|
|
38
|
+
var hexOf = (c) => brushColourHex(c, "light") ?? "#ffffff";
|
|
39
|
+
function brushPreviewStrength(brush) {
|
|
40
|
+
const opacity = brush.tip.opacity ?? 1;
|
|
41
|
+
const flow = brush.tip.flow ?? 1;
|
|
42
|
+
const grain = brush.behaviour?.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 = options.profile ?? PAINT_PROFILE;
|
|
48
|
+
let background = profile.light === "full" && brushPreviewsOnDark(brush) ? BRUSH_PREVIEW_DARK_PAPER : hexOf(options.paper ?? "#ffffff");
|
|
49
|
+
if (!options.keepPaper && brush.tip.blend === "multiply" && relativeLuminance(parseColor(background)) < 0.18) background = "#ffffff";
|
|
50
|
+
const bg = parseColor(background);
|
|
51
|
+
const scheme = relativeLuminance(bg) < 0.18 ? "dark" : "light";
|
|
52
|
+
const own = brush.kind === "mark" ? brush.colour?.default : void 0;
|
|
53
|
+
const ownHex = typeof own === "string" || isDualColor(own) ? brushColourHex(own, scheme) : null;
|
|
54
|
+
if (ownHex && brush.tip.blend === "multiply" && (brush.light?.amount ?? 0) > 0 && scheme === "light") return { background, color: ownHex, scheme };
|
|
55
|
+
const group = brush.kind === "tool" ? "tools" : brush.medium ?? "other";
|
|
56
|
+
const color = ownHex ?? brushColourHex(BRUSH_PREVIEW_FALLBACKS[group] ?? BRUSH_PREVIEW_FALLBACKS.other, scheme);
|
|
57
|
+
const alpha = brushPreviewStrength(brush);
|
|
58
|
+
const reads = (c) => contrastRatio(over(c, bg, alpha), bg) >= BRUSH_PREVIEW_MIN_CONTRAST;
|
|
59
|
+
const fg = parseColor(color);
|
|
60
|
+
if (reads(fg)) return { background, color, scheme };
|
|
61
|
+
const lch = oklabToOklch(rgbToOklab(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 = formatHex(toSrgbGamut(oklabToRgb(oklchToOklab({ ...lch, l }))));
|
|
65
|
+
if (reads(parseColor(hex))) return { background, color: hex, scheme };
|
|
66
|
+
}
|
|
67
|
+
return { background, color: scheme === "dark" ? "#ffffff" : "#000000", scheme };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
BRUSH_PREVIEW_DARK_PAPER,
|
|
72
|
+
BRUSH_PREVIEW_MIN_CONTRAST,
|
|
73
|
+
BRUSH_PREVIEW_FALLBACKS,
|
|
74
|
+
brushPreviewsOnDark,
|
|
75
|
+
brushPreviewStrength,
|
|
76
|
+
brushPreviewColours
|
|
77
|
+
};
|