@pixerate/editor 0.275.1 → 0.277.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 +62 -62
- package/dist/animation-editor/index.js +6 -6
- package/dist/brushes/index.cjs +84 -71
- package/dist/brushes/index.js +20 -7
- package/dist/brushes/patch.d.cts +4 -4
- package/dist/brushes/patch.d.ts +4 -4
- package/dist/brushes/profiles.d.cts +4 -0
- package/dist/brushes/profiles.d.ts +4 -0
- package/dist/brushes/schema.d.cts +2 -0
- package/dist/brushes/schema.d.ts +2 -0
- package/dist/brushes/types.d.cts +32 -1
- package/dist/brushes/types.d.ts +32 -1
- package/dist/{brushstrokeRender-2RQL46WB.cjs → brushstrokeRender-7HOMKZNO.cjs} +21 -21
- package/dist/{brushstrokeRender-WGY4DZHF.js → brushstrokeRender-EIK3625T.js} +5 -5
- package/dist/canvas/index.cjs +13 -13
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-T6KNJVBP.cjs → chunk-4NZTK7LM.cjs} +35 -35
- package/dist/{chunk-LMG57L5A.js → chunk-CTHWXW5M.js} +121 -8
- package/dist/{chunk-43XJC3PP.js → chunk-DWPFGWW5.js} +1 -1
- package/dist/{chunk-MSWLJI4G.js → chunk-FNIWHSLI.js} +2 -2
- package/dist/{chunk-JDXWLCXF.cjs → chunk-H3EME3S5.cjs} +2 -2
- package/dist/{chunk-Y2ISSVPH.js → chunk-HHX7ST6Z.js} +167 -9
- package/dist/{chunk-6QNDGMK7.cjs → chunk-HRUK5TFW.cjs} +187 -45
- package/dist/{chunk-NIBFKXMD.cjs → chunk-IFWLZZCW.cjs} +619 -2
- package/dist/{chunk-W6JDUXP3.js → chunk-J23JOHPR.js} +1 -1
- package/dist/{chunk-HVO6XCI4.js → chunk-JPB65KQ6.js} +1 -1
- package/dist/{chunk-Y354ETAE.cjs → chunk-JVFGK3DK.cjs} +69 -58
- package/dist/{chunk-ACTHSQOI.js → chunk-LDZOXESA.js} +618 -1
- package/dist/{chunk-IEEY5RJV.js → chunk-LZE2QZCT.js} +1 -1
- package/dist/{chunk-DHC4E2DU.cjs → chunk-MITQGHN3.cjs} +121 -8
- package/dist/{chunk-75SYKUOT.js → chunk-N4MCWQZ7.js} +1 -1
- package/dist/{chunk-G5TCMKX5.js → chunk-NJLPW4MM.js} +17 -6
- package/dist/{chunk-STLTOISW.cjs → chunk-NPPMKMCU.cjs} +17 -17
- package/dist/{chunk-OLZXXAER.cjs → chunk-PEQWARCP.cjs} +408 -250
- package/dist/{chunk-ZM7IKQ4X.js → chunk-PPDUCZZV.js} +152 -10
- package/dist/{chunk-RAPNRK4R.cjs → chunk-QBZEC2JJ.cjs} +88 -88
- package/dist/{chunk-RJGW3RQS.js → chunk-ROURHJYT.js} +1 -1
- package/dist/{chunk-62MFUHSI.cjs → chunk-UQXULAMQ.cjs} +16 -16
- package/dist/{chunk-YYZC2EQO.cjs → chunk-VNF7A2JA.cjs} +23 -23
- package/dist/{chunk-C6VB7CPY.cjs → chunk-WFSYZO5Z.cjs} +1 -1
- package/dist/image-editor/index.cjs +880 -852
- package/dist/image-editor/index.js +36 -8
- package/dist/paint/index.cjs +33 -5
- package/dist/paint/index.d.cts +1 -0
- package/dist/paint/index.d.ts +1 -0
- package/dist/paint/index.js +32 -4
- package/dist/paint/live-patterns.d.cts +149 -0
- package/dist/paint/live-patterns.d.ts +149 -0
- package/dist/paint/wet/world.d.cts +13 -0
- package/dist/paint/wet/world.d.ts +13 -0
- package/dist/paint-editor/brush-model.d.cts +21 -1
- package/dist/paint-editor/brush-model.d.ts +21 -1
- package/dist/paint-editor/controller.d.cts +102 -1
- package/dist/paint-editor/controller.d.ts +102 -1
- package/dist/paint-editor/document.d.cts +8 -1
- package/dist/paint-editor/document.d.ts +8 -1
- package/dist/paint-editor/ferro-tools.d.cts +10 -0
- package/dist/paint-editor/ferro-tools.d.ts +10 -0
- package/dist/paint-editor/ferro.d.cts +134 -0
- package/dist/paint-editor/ferro.d.ts +134 -0
- package/dist/paint-editor/index.cjs +2291 -904
- package/dist/paint-editor/index.d.cts +2 -0
- package/dist/paint-editor/index.d.ts +2 -0
- package/dist/paint-editor/index.js +1533 -146
- package/dist/paint-editor/stroke.d.cts +14 -0
- package/dist/paint-editor/stroke.d.ts +14 -0
- package/dist/paint-editor/thick.d.cts +15 -2
- package/dist/paint-editor/thick.d.ts +15 -2
- package/dist/paint-editor/ui.d.cts +7 -1
- package/dist/paint-editor/ui.d.ts +7 -1
- package/dist/paint-editor/wet-tools.d.cts +42 -0
- package/dist/paint-editor/wet-tools.d.ts +42 -0
- package/dist/paint-editor/wet.d.cts +22 -1
- package/dist/paint-editor/wet.d.ts +22 -1
- package/dist/vector/index.cjs +1002 -1002
- package/dist/vector/index.js +7 -7
- package/package.json +1 -1
- package/skills/pixerate-brushes/SKILL.md +1 -0
- package/skills/pixerate-paint-editor/SKILL.md +11 -29
- package/skills/pixerate-paint-editor/references/brush-facets.md +1 -0
- package/skills/pixerate-paint-editor/references/ferrofluid.md +36 -0
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkPEQWARCPcjs = require('./chunk-PEQWARCP.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 = _chunkPEQWARCPcjs.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 = _chunkPEQWARCPcjs.IDENTITY_MATRIX, closed = c.closed) {
|
|
71
|
+
const pts = _chunkPEQWARCPcjs.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 = _chunkOLZXXAERcjs.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 = _chunkPEQWARCPcjs.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 = _chunkPEQWARCPcjs.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 = _chunkPEQWARCPcjs.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 = _chunkPEQWARCPcjs.sortedVectorGradientStops.call(void 0, a);
|
|
471
|
+
let stopsB = _chunkPEQWARCPcjs.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 = [..._chunkPEQWARCPcjs.expandVectorGradientStops.call(void 0, a), ..._chunkPEQWARCPcjs.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 = _chunkPEQWARCPcjs.hasExplicitGradientGeometry.call(void 0, a);
|
|
502
|
+
const eb = _chunkPEQWARCPcjs.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 = _chunkPEQWARCPcjs.vectorGradientPoints.call(void 0, a);
|
|
516
|
+
const pb = _chunkPEQWARCPcjs.vectorGradientPoints.call(void 0, b);
|
|
517
517
|
if (pa.units !== pb.units) {
|
|
518
|
-
const src =
|
|
518
|
+
const src = _chunkPEQWARCPcjs.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 = _chunkPEQWARCPcjs.hasPaint.call(void 0, a);
|
|
539
|
+
const pb = _chunkPEQWARCPcjs.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 && _chunkPEQWARCPcjs.isVectorGradient.call(void 0, a) ? a : null;
|
|
545
|
+
const gb = pb && _chunkPEQWARCPcjs.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 = _chunkPEQWARCPcjs.widthProfileAt.call(void 0, a, pos);
|
|
557
|
+
const y = _chunkPEQWARCPcjs.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 = _chunkPEQWARCPcjs.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 _chunkPEQWARCPcjs.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 = _chunkPEQWARCPcjs.nodeMatrix.call(void 0, a), mb = _chunkPEQWARCPcjs.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 = !_chunkPEQWARCPcjs.isIdentityMatrix.call(void 0, ma) || !_chunkPEQWARCPcjs.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) : _chunkPEQWARCPcjs.IDENTITY_MATRIX;
|
|
638
|
+
const back = rigid ? _chunkPEQWARCPcjs.invertMatrix.call(void 0, m) : _chunkPEQWARCPcjs.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 = _chunkOLZXXAERcjs.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 && !_chunkPEQWARCPcjs.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 = _chunkPEQWARCPcjs.IDENTITY_MATRIX) {
|
|
651
|
+
const m = _chunkPEQWARCPcjs.multiplyMatrices.call(void 0, _chunkPEQWARCPcjs.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(_chunkPEQWARCPcjs.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 = _chunkPEQWARCPcjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
|
|
676
|
+
const bb = _chunkPEQWARCPcjs.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, _chunkPEQWARCPcjs.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, _chunkPEQWARCPcjs.IDENTITY_MATRIX, y.m));
|
|
692
692
|
opacities.push([y.opacity, y.opacity]);
|
|
693
693
|
}
|
|
694
694
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LivePatternField,
|
|
3
|
+
moveLivePatternSnapshot
|
|
4
|
+
} from "./chunk-LDZOXESA.js";
|
|
1
5
|
import {
|
|
2
6
|
TILE,
|
|
3
7
|
TiledSurface,
|
|
@@ -852,10 +856,30 @@ var noLight = () => new TiledSurface(1, /* @__PURE__ */ new Map(), 0);
|
|
|
852
856
|
function cloneGhost(g) {
|
|
853
857
|
return g ? { pigment: [...g.pigment], remaining: g.remaining, total: g.total, linger: g.linger, ...g.trigger === "agent" ? { trigger: "agent" } : {} } : null;
|
|
854
858
|
}
|
|
855
|
-
function newLane(id, index, params, flow, flowStrength, base, light, ghost) {
|
|
859
|
+
function newLane(id, index, params, flow, flowStrength, base, light, width, height, ghost, livePatterns) {
|
|
856
860
|
const l = light ?? noLight();
|
|
857
861
|
const g = cloneGhost(ghost);
|
|
858
|
-
return {
|
|
862
|
+
return {
|
|
863
|
+
id,
|
|
864
|
+
index,
|
|
865
|
+
params,
|
|
866
|
+
flow,
|
|
867
|
+
flowStrength,
|
|
868
|
+
base,
|
|
869
|
+
shaded: /* @__PURE__ */ new Map(),
|
|
870
|
+
urgent: /* @__PURE__ */ new Set(),
|
|
871
|
+
stamp: 1,
|
|
872
|
+
display: null,
|
|
873
|
+
shadedVersion: 0,
|
|
874
|
+
displayKey: "",
|
|
875
|
+
light: l,
|
|
876
|
+
lit: !g && l.tiles.size > 0,
|
|
877
|
+
ghost: g,
|
|
878
|
+
lightShaded: /* @__PURE__ */ new Map(),
|
|
879
|
+
lightDisplay: null,
|
|
880
|
+
lightKey: "",
|
|
881
|
+
livePatterns: livePatterns ?? new LivePatternField(width, height)
|
|
882
|
+
};
|
|
859
883
|
}
|
|
860
884
|
var WetWorldError = class extends Error {
|
|
861
885
|
constructor(message) {
|
|
@@ -1016,12 +1040,28 @@ var WetWorld = class {
|
|
|
1016
1040
|
if (options.params) this.setParams(id, options.params);
|
|
1017
1041
|
if (options.base) this.setBase(id, options.base);
|
|
1018
1042
|
if (options.light) this.setLight(id, options.light);
|
|
1043
|
+
if (options.livePatterns && existing.livePatterns !== options.livePatterns) {
|
|
1044
|
+
existing.livePatterns = options.livePatterns;
|
|
1045
|
+
this.touchAll(existing);
|
|
1046
|
+
}
|
|
1019
1047
|
if (options.ghost !== void 0) this.setGhost(id, options.ghost);
|
|
1020
1048
|
return;
|
|
1021
1049
|
}
|
|
1022
1050
|
const index = this.lanes.indexOf(null);
|
|
1023
1051
|
if (index < 0) throw new WetWorldError(`At most ${MAX_WET_LANES} layers can hold wet paint at once; dry one (dry_paint) first.`);
|
|
1024
|
-
this.lanes[index] = newLane(
|
|
1052
|
+
this.lanes[index] = newLane(
|
|
1053
|
+
id,
|
|
1054
|
+
index,
|
|
1055
|
+
normalizeWetParams(options.params ?? {}, DEFAULT_WET_PARAMS),
|
|
1056
|
+
options.flow ?? null,
|
|
1057
|
+
options.flow ? options.flowStrength ?? 1 : 0,
|
|
1058
|
+
options.base ?? new TiledSurface(4, /* @__PURE__ */ new Map(), 0),
|
|
1059
|
+
options.light,
|
|
1060
|
+
this.width,
|
|
1061
|
+
this.height,
|
|
1062
|
+
options.ghost,
|
|
1063
|
+
options.livePatterns
|
|
1064
|
+
);
|
|
1025
1065
|
this.pack(this.lanes[index]);
|
|
1026
1066
|
}
|
|
1027
1067
|
/** Drops a wet layer and its wet paint (nothing is baked). */
|
|
@@ -1041,6 +1081,52 @@ var WetWorld = class {
|
|
|
1041
1081
|
this.pack(lane);
|
|
1042
1082
|
return { ...lane.params };
|
|
1043
1083
|
}
|
|
1084
|
+
getLivePatterns(id) {
|
|
1085
|
+
return { ...this.laneOf(id).livePatterns.settings };
|
|
1086
|
+
}
|
|
1087
|
+
hasLivePatterns(id) {
|
|
1088
|
+
const lane = this.laneOf(id);
|
|
1089
|
+
return lane.livePatterns.enabled;
|
|
1090
|
+
}
|
|
1091
|
+
livePatternField(id) {
|
|
1092
|
+
return this.laneOf(id).livePatterns;
|
|
1093
|
+
}
|
|
1094
|
+
setLivePatterns(id, settings) {
|
|
1095
|
+
this.requireIdle();
|
|
1096
|
+
const lane = this.laneOf(id);
|
|
1097
|
+
const next = lane.livePatterns.configure(settings);
|
|
1098
|
+
this.touchAll(lane);
|
|
1099
|
+
return next;
|
|
1100
|
+
}
|
|
1101
|
+
seedLivePatterns(id, cx, cy, radius, seed = 1, strength = 1, settings) {
|
|
1102
|
+
this.requireIdle();
|
|
1103
|
+
const lane = this.laneOf(id);
|
|
1104
|
+
if (settings) lane.livePatterns.configure(settings);
|
|
1105
|
+
const count = lane.livePatterns.seedDisc(cx, cy, radius, seed, strength);
|
|
1106
|
+
if (count > 0) this.touchAll(lane);
|
|
1107
|
+
return count;
|
|
1108
|
+
}
|
|
1109
|
+
livePatternStats(id) {
|
|
1110
|
+
const lane = this.laneOf(id);
|
|
1111
|
+
return lane.livePatterns.stats((tx, ty, lx, ly) => this.isPatternCellWet(lane, tx, ty, lx, ly));
|
|
1112
|
+
}
|
|
1113
|
+
isPatternCellWet(lane, tx, ty, lx, ly) {
|
|
1114
|
+
const { tilesX, tilesY, perLane } = this.layout;
|
|
1115
|
+
if (tx < 0 || ty < 0 || tx >= tilesX || ty >= tilesY) return false;
|
|
1116
|
+
const slot = this.slotOf(lane.index * perLane + ty * tilesX + tx);
|
|
1117
|
+
if (slot < 0) return false;
|
|
1118
|
+
const cur = this.slotBase(slot) + this.parity * SET_PLANES * PLANE;
|
|
1119
|
+
const x0 = lx * 2 + 1;
|
|
1120
|
+
const y0 = ly * 2 + 1;
|
|
1121
|
+
const c00 = y0 * S2 + x0;
|
|
1122
|
+
const c10 = c00 + 1;
|
|
1123
|
+
const c01 = c00 + S2;
|
|
1124
|
+
const c11 = c01 + 1;
|
|
1125
|
+
const rhoBase = cur + P_RHO * PLANE;
|
|
1126
|
+
const swBase = cur + P_SW * PLANE;
|
|
1127
|
+
const f = this.f32;
|
|
1128
|
+
return f[rhoBase + c00] + f[swBase + c00] > DRY_EPS || f[rhoBase + c10] + f[swBase + c10] > DRY_EPS || f[rhoBase + c01] + f[swBase + c01] > DRY_EPS || f[rhoBase + c11] + f[swBase + c11] > DRY_EPS;
|
|
1129
|
+
}
|
|
1044
1130
|
getTilt() {
|
|
1045
1131
|
return { ...this.tilt };
|
|
1046
1132
|
}
|
|
@@ -1378,6 +1464,14 @@ var WetWorld = class {
|
|
|
1378
1464
|
const flagsBase = l.flags >> 2;
|
|
1379
1465
|
const lastBase = l.last >> 2;
|
|
1380
1466
|
const { tilesX, tilesY, perLane } = l;
|
|
1467
|
+
for (const lane of this.lanes) {
|
|
1468
|
+
if (!lane || !lane.livePatterns.enabled || lane.livePatterns.tiles.size === 0) continue;
|
|
1469
|
+
lane.livePatterns.step(
|
|
1470
|
+
n,
|
|
1471
|
+
(tx, ty, lx, ly) => this.isPatternCellWet(lane, tx, ty, lx, ly),
|
|
1472
|
+
(tx, ty) => this.slotOf(lane.index * perLane + ty * tilesX + tx) >= 0
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1381
1475
|
const wakeups = [];
|
|
1382
1476
|
for (const key of this.active) {
|
|
1383
1477
|
const fl = this.u32[flagsBase + key];
|
|
@@ -2051,6 +2145,7 @@ var WetWorld = class {
|
|
|
2051
2145
|
}
|
|
2052
2146
|
const src = lane.base.tiles.get(tk)?.data ?? null;
|
|
2053
2147
|
const out = this.shadeSlot(key, src, all ? "bake-all" : "bake");
|
|
2148
|
+
if (lane.livePatterns.enabled) lane.livePatterns.markBaked(tx, ty);
|
|
2054
2149
|
if (!out) return lightChanged;
|
|
2055
2150
|
const tiles = new Map(lane.base.tiles);
|
|
2056
2151
|
const t = finishTile(out, 4, 0);
|
|
@@ -2086,7 +2181,7 @@ var WetWorld = class {
|
|
|
2086
2181
|
const h = Math.min(WET_TILE, this.height - ty * WET_TILE);
|
|
2087
2182
|
const lane = this.lanes[this.laneIndexOf(key)];
|
|
2088
2183
|
const lit = lane.lit && !lane.ghost;
|
|
2089
|
-
|
|
2184
|
+
let changed = shadeTile(
|
|
2090
2185
|
this.f32,
|
|
2091
2186
|
PLANE,
|
|
2092
2187
|
S2,
|
|
@@ -2103,6 +2198,9 @@ var WetWorld = class {
|
|
|
2103
2198
|
lit ? b + P_DL * PLANE : -1,
|
|
2104
2199
|
lit && mode !== "bake" ? cur + P_L * PLANE : -1
|
|
2105
2200
|
);
|
|
2201
|
+
if (lane.livePatterns.enabled && lane.livePatterns.tiles.size > 0) {
|
|
2202
|
+
changed = lane.livePatterns.shadeTile(tx, ty, out, w, h) || changed;
|
|
2203
|
+
}
|
|
2106
2204
|
return changed ? out : null;
|
|
2107
2205
|
}
|
|
2108
2206
|
/** The layer's pixels with all its wet paint dried where it is (the bake of "dry on save"); changes nothing. */
|
|
@@ -2550,7 +2648,11 @@ var WetWorld = class {
|
|
|
2550
2648
|
slots.set(key, { planes, last: this.u32[(this.layout.last >> 2) + key] });
|
|
2551
2649
|
bytes += planes.byteLength;
|
|
2552
2650
|
}
|
|
2553
|
-
const lanes = this.lanes.filter((l) => Boolean(l)).map((l) =>
|
|
2651
|
+
const lanes = this.lanes.filter((l) => Boolean(l)).map((l) => {
|
|
2652
|
+
const lp = l.livePatterns.snapshot();
|
|
2653
|
+
bytes += lp.bytes;
|
|
2654
|
+
return { id: l.id, index: l.index, params: { ...l.params }, flow: l.flow, flowStrength: l.flowStrength, base: l.base, light: l.light, lit: l.lit, ghost: cloneGhost(l.ghost), livePatterns: lp };
|
|
2655
|
+
});
|
|
2554
2656
|
return { clock: this.clock, tilt: { ...this.tilt }, lanes, slots, bytes };
|
|
2555
2657
|
}
|
|
2556
2658
|
/** Puts a snapshot back exactly (the simulation then continues as it would have). */
|
|
@@ -2560,8 +2662,9 @@ var WetWorld = class {
|
|
|
2560
2662
|
this.lanes.fill(null);
|
|
2561
2663
|
this.tilt = { ...snap.tilt };
|
|
2562
2664
|
for (const l of snap.lanes) {
|
|
2563
|
-
const lane = newLane(l.id, l.index, { ...l.params }, l.flow, l.flowStrength, l.base, l.light, l.ghost);
|
|
2665
|
+
const lane = newLane(l.id, l.index, { ...l.params }, l.flow, l.flowStrength, l.base, l.light, this.width, this.height, l.ghost);
|
|
2564
2666
|
lane.lit = !lane.ghost && (lane.lit || Boolean(l.lit));
|
|
2667
|
+
if (l.livePatterns) lane.livePatterns.restore(l.livePatterns);
|
|
2565
2668
|
this.lanes[l.index] = lane;
|
|
2566
2669
|
this.pack(this.lanes[l.index]);
|
|
2567
2670
|
}
|
|
@@ -2619,9 +2722,19 @@ function moveWetSnapshot(snap, from, to, dx, dy, lane = () => ({})) {
|
|
|
2619
2722
|
}
|
|
2620
2723
|
const lanes = snap.lanes.map((l) => {
|
|
2621
2724
|
const moved = lane(l);
|
|
2622
|
-
|
|
2725
|
+
const lp = l.livePatterns ? moveLivePatternSnapshot(l.livePatterns, to, tx0, ty0) : void 0;
|
|
2726
|
+
if (lp) bytes += lp.bytes;
|
|
2727
|
+
return { ...l, base: moved.base ?? l.base, light: moved.light ?? l.light, flow: moved.flow === void 0 ? l.flow : moved.flow, ...lp ? { livePatterns: lp } : {} };
|
|
2623
2728
|
});
|
|
2624
|
-
|
|
2729
|
+
let patterns;
|
|
2730
|
+
if (snap.patterns) {
|
|
2731
|
+
patterns = /* @__PURE__ */ new Map();
|
|
2732
|
+
for (const [id, p] of snap.patterns) {
|
|
2733
|
+
const mp = moveLivePatternSnapshot(p, to, tx0, ty0);
|
|
2734
|
+
patterns.set(id, mp);
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
return { clock: snap.clock, tilt: { ...snap.tilt }, lanes, slots, ...patterns ? { patterns } : {}, bytes };
|
|
2625
2738
|
}
|
|
2626
2739
|
function unionRect(a, b) {
|
|
2627
2740
|
if (!a) return { ...b };
|
|
@@ -115,7 +115,7 @@ import {
|
|
|
115
115
|
transformTextRect,
|
|
116
116
|
translateMatrix,
|
|
117
117
|
warpPresetMesh
|
|
118
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-HHX7ST6Z.js";
|
|
119
119
|
import {
|
|
120
120
|
bezierPathBounds,
|
|
121
121
|
outlineStroke,
|
|
@@ -129,7 +129,7 @@ import {
|
|
|
129
129
|
} from "./chunk-DVPQFMH6.js";
|
|
130
130
|
import {
|
|
131
131
|
MAX_BRUSH_SIZE
|
|
132
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-LDZOXESA.js";
|
|
133
133
|
import {
|
|
134
134
|
BLEND_MODES,
|
|
135
135
|
blendRgb,
|
|
@@ -1,6 +1,6 @@
|
|
|
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
|
|
3
|
+
var _chunkHRUK5TFWcjs = require('./chunk-HRUK5TFW.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkJBZRVLXVcjs = require('./chunk-JBZRVLXV.cjs');
|
|
@@ -44,7 +44,7 @@ function brushPreviewStrength(brush) {
|
|
|
44
44
|
}
|
|
45
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
46
|
function brushPreviewColours(brush, options = {}) {
|
|
47
|
-
const profile = _nullishCoalesce(options.profile, () => (
|
|
47
|
+
const profile = _nullishCoalesce(options.profile, () => ( _chunkHRUK5TFWcjs.PAINT_PROFILE));
|
|
48
48
|
let background = profile.light === "full" && brushPreviewsOnDark(brush) ? BRUSH_PREVIEW_DARK_PAPER : hexOf(_nullishCoalesce(options.paper, () => ( "#ffffff")));
|
|
49
49
|
if (!options.keepPaper && brush.tip.blend === "multiply" && _chunk5UEFBM2Mcjs.relativeLuminance.call(void 0, _chunk5UEFBM2Mcjs.parseColor.call(void 0, background)) < 0.18) background = "#ffffff";
|
|
50
50
|
const bg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, background);
|