@pixerate/editor 0.267.0 → 0.268.1
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 +198 -72
- package/dist/brushes/index.d.cts +4 -3
- package/dist/brushes/index.d.ts +4 -3
- package/dist/brushes/index.js +136 -10
- package/dist/brushes/library.d.cts +27 -1
- package/dist/brushes/library.d.ts +27 -1
- package/dist/brushes/profiles.d.cts +4 -0
- package/dist/brushes/profiles.d.ts +4 -0
- package/dist/brushes/schema.d.cts +4 -0
- package/dist/brushes/schema.d.ts +4 -0
- package/dist/brushes/sources.d.cts +114 -0
- package/dist/brushes/sources.d.ts +114 -0
- package/dist/brushes/types.d.cts +37 -5
- package/dist/brushes/types.d.ts +37 -5
- package/dist/brushes/ui.d.cts +40 -4
- package/dist/brushes/ui.d.ts +40 -4
- package/dist/{brushstrokeRender-NLFPEBGI.js → brushstrokeRender-A727TTNQ.js} +6 -6
- package/dist/{brushstrokeRender-L7JYRR2R.cjs → brushstrokeRender-WR2N5HHY.cjs} +22 -22
- package/dist/canvas/index.cjs +13 -13
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-J2TNIZ55.cjs → chunk-2WOGXEDX.cjs} +1 -1
- package/dist/{chunk-JGWVZPT6.js → chunk-3XDSNIGF.js} +72 -5
- package/dist/{chunk-EXB2EGBE.cjs → chunk-62MFUHSI.cjs} +16 -16
- package/dist/{chunk-GCVFEPJG.js → chunk-ACTHSQOI.js} +182 -0
- package/dist/{chunk-EF7LZAXQ.js → chunk-BAZMCFVL.js} +1 -1
- package/dist/{chunk-HIO6E7LC.cjs → chunk-BPJSI4NT.cjs} +2 -2
- package/dist/{chunk-XVOP3CGQ.cjs → chunk-EU2ZZA6L.cjs} +393 -62
- package/dist/{chunk-YIC6MAJ2.js → chunk-HFY5LG5J.js} +1 -1
- package/dist/{chunk-7UKFXXWL.js → chunk-HVO6XCI4.js} +1 -1
- package/dist/{chunk-LHPEG5AU.cjs → chunk-J4GXP53R.cjs} +140 -91
- package/dist/{chunk-OKHKA43L.cjs → chunk-JBB3GDBB.cjs} +330 -216
- package/dist/{chunk-AGNUD5BI.js → chunk-KZI3YWKW.js} +351 -20
- package/dist/{chunk-FGJHJIMN.js → chunk-LDOD7VCT.js} +59 -10
- package/dist/{chunk-EYSHTYLG.js → chunk-LETF75CA.js} +1 -1
- package/dist/{chunk-FQPUF2W2.cjs → chunk-NIBFKXMD.cjs} +217 -35
- package/dist/{chunk-G7NHE2VD.cjs → chunk-NPWWSCWT.cjs} +35 -35
- package/dist/{chunk-OSEXT7JL.js → chunk-QNY7BDFP.js} +1 -1
- package/dist/{chunk-PXDIAYB6.cjs → chunk-STLTOISW.cjs} +34 -214
- package/dist/{chunk-4IDUYB45.js → chunk-UVTO3D4E.js} +130 -16
- package/dist/{chunk-TXFWZ5ZJ.js → chunk-W6JDUXP3.js} +4 -184
- package/dist/{chunk-LA5Y4ETA.cjs → chunk-YOVXQHA3.cjs} +23 -23
- package/dist/{chunk-DT4YQUGT.cjs → chunk-YXP6X3SY.cjs} +101 -34
- package/dist/image-editor/adjustment-layers.d.cts +8 -0
- package/dist/image-editor/adjustment-layers.d.ts +8 -0
- package/dist/image-editor/index.cjs +857 -853
- package/dist/image-editor/index.js +30 -26
- package/dist/paint/index.cjs +5 -5
- package/dist/paint/index.js +11 -11
- package/dist/paint-editor/brush-library-tools.d.cts +12 -2
- package/dist/paint-editor/brush-library-tools.d.ts +12 -2
- package/dist/paint-editor/brush-model.d.cts +29 -1
- package/dist/paint-editor/brush-model.d.ts +29 -1
- package/dist/paint-editor/brush-source-art.d.cts +32 -0
- package/dist/paint-editor/brush-source-art.d.ts +32 -0
- package/dist/paint-editor/controller.d.cts +6 -1
- package/dist/paint-editor/controller.d.ts +6 -1
- package/dist/paint-editor/dab-stroke.d.cts +2 -0
- package/dist/paint-editor/dab-stroke.d.ts +2 -0
- package/dist/paint-editor/engine.d.cts +11 -2
- package/dist/paint-editor/engine.d.ts +11 -2
- package/dist/paint-editor/index.cjs +576 -481
- package/dist/paint-editor/index.d.cts +3 -1
- package/dist/paint-editor/index.d.ts +3 -1
- package/dist/paint-editor/index.js +127 -32
- package/dist/paint-editor/stamp-tip.d.cts +8 -5
- package/dist/paint-editor/stamp-tip.d.ts +8 -5
- package/dist/paint-editor/thumbnails.d.cts +6 -0
- package/dist/paint-editor/thumbnails.d.ts +6 -0
- package/dist/paint-editor/tip-grain.d.cts +34 -0
- package/dist/paint-editor/tip-grain.d.ts +34 -0
- package/dist/raster/index.cjs +2 -2
- package/dist/raster/index.js +9 -9
- package/dist/vector/index.cjs +1002 -1002
- package/dist/vector/index.js +7 -7
- package/package.json +110 -1
- package/skills/pixerate-brushes/SKILL.md +35 -8
- package/skills/pixerate-brushes-design/SKILL.md +8 -1
- package/skills/pixerate-image-editor/SKILL.md +1 -1
- package/skills/pixerate-paint-editor/SKILL.md +6 -0
- package/skills/pixerate-paint-editor/references/brush-facets.md +3 -1
- package/skills/pixerate-paint-sketch-to-finish/SKILL.md +1 -0
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkJBB3GDBBcjs = require('./chunk-JBB3GDBB.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 = _chunkJBB3GDBBcjs.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 = _chunkJBB3GDBBcjs.IDENTITY_MATRIX, closed = c.closed) {
|
|
71
|
+
const pts = _chunkJBB3GDBBcjs.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 = _chunkOKHKA43Lcjs.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 = _chunkJBB3GDBBcjs.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 = _chunkJBB3GDBBcjs.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 = _chunkJBB3GDBBcjs.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 = _chunkJBB3GDBBcjs.sortedVectorGradientStops.call(void 0, a);
|
|
471
|
+
let stopsB = _chunkJBB3GDBBcjs.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 = [..._chunkJBB3GDBBcjs.expandVectorGradientStops.call(void 0, a), ..._chunkJBB3GDBBcjs.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 = _chunkJBB3GDBBcjs.hasExplicitGradientGeometry.call(void 0, a);
|
|
502
|
+
const eb = _chunkJBB3GDBBcjs.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 = _chunkJBB3GDBBcjs.vectorGradientPoints.call(void 0, a);
|
|
516
|
+
const pb = _chunkJBB3GDBBcjs.vectorGradientPoints.call(void 0, b);
|
|
517
517
|
if (pa.units !== pb.units) {
|
|
518
|
-
const src =
|
|
518
|
+
const src = _chunkJBB3GDBBcjs.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 = _chunkJBB3GDBBcjs.hasPaint.call(void 0, a);
|
|
539
|
+
const pb = _chunkJBB3GDBBcjs.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 && _chunkJBB3GDBBcjs.isVectorGradient.call(void 0, a) ? a : null;
|
|
545
|
+
const gb = pb && _chunkJBB3GDBBcjs.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 = _chunkJBB3GDBBcjs.widthProfileAt.call(void 0, a, pos);
|
|
557
|
+
const y = _chunkJBB3GDBBcjs.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 = _chunkJBB3GDBBcjs.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 _chunkJBB3GDBBcjs.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 = _chunkJBB3GDBBcjs.nodeMatrix.call(void 0, a), mb = _chunkJBB3GDBBcjs.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 = !_chunkJBB3GDBBcjs.isIdentityMatrix.call(void 0, ma) || !_chunkJBB3GDBBcjs.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) : _chunkJBB3GDBBcjs.IDENTITY_MATRIX;
|
|
638
|
+
const back = rigid ? _chunkJBB3GDBBcjs.invertMatrix.call(void 0, m) : _chunkJBB3GDBBcjs.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 = _chunkOKHKA43Lcjs.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 && !_chunkJBB3GDBBcjs.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 = _chunkJBB3GDBBcjs.IDENTITY_MATRIX) {
|
|
651
|
+
const m = _chunkJBB3GDBBcjs.multiplyMatrices.call(void 0, _chunkJBB3GDBBcjs.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(_chunkJBB3GDBBcjs.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 = _chunkJBB3GDBBcjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
|
|
676
|
+
const bb = _chunkJBB3GDBBcjs.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, _chunkJBB3GDBBcjs.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, _chunkJBB3GDBBcjs.IDENTITY_MATRIX, y.m));
|
|
692
692
|
opacities.push([y.opacity, y.opacity]);
|
|
693
693
|
}
|
|
694
694
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var _chunkFQPUF2W2cjs = require('./chunk-FQPUF2W2.cjs');
|
|
14
13
|
|
|
15
14
|
|
|
15
|
+
var _chunkNIBFKXMDcjs = require('./chunk-NIBFKXMD.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
var _chunk3K6HWEXZcjs = require('./chunk-3K6HWEXZ.cjs');
|
|
@@ -34,180 +34,6 @@ var _chunkW5M3J7PVcjs = require('./chunk-W5M3J7PV.cjs');
|
|
|
34
34
|
|
|
35
35
|
var _chunk474IQG74cjs = require('./chunk-474IQG74.cjs');
|
|
36
36
|
|
|
37
|
-
// src/paint/grain.ts
|
|
38
|
-
var GRAIN_PATTERNS = ["smooth", "cold-pressed", "hot-pressed", "rough", "vellum", "laid", "ingres", "sanded", "canvas", "linen", "gesso"];
|
|
39
|
-
var GRAIN_TILE = 256;
|
|
40
|
-
var clamp01 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
|
|
41
|
-
function patternHeights(pattern, n, seed) {
|
|
42
|
-
const out = new Float32Array(n * n);
|
|
43
|
-
const salt = Math.imul(seed | 0, 2654435761) + 17;
|
|
44
|
-
if (pattern === "smooth") return out.fill(1);
|
|
45
|
-
const noise = (cx, cy, oct, s = 0) => new (0, _chunk3K6HWEXZcjs.TileableNoise)(n, cx, cy, oct, salt + s);
|
|
46
|
-
const k = n / GRAIN_TILE;
|
|
47
|
-
switch (pattern) {
|
|
48
|
-
case "cold-pressed": {
|
|
49
|
-
const base = noise(20 * k, 20 * k, 4);
|
|
50
|
-
const fine = noise(64 * k, 64 * k, 2, 3);
|
|
51
|
-
for (let y = 0; y < n; y++)
|
|
52
|
-
for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 1.8 + 0.5 + (fine.at(x, y) - 0.5) * 0.5 + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.12);
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
case "hot-pressed": {
|
|
56
|
-
const base = noise(40 * k, 40 * k, 3);
|
|
57
|
-
for (let y = 0; y < n; y++) for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 1.1 + 0.6 + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.08);
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
case "rough": {
|
|
61
|
-
const base = noise(10 * k, 10 * k, 5);
|
|
62
|
-
const blot = noise(28 * k, 28 * k, 2, 5);
|
|
63
|
-
for (let y = 0; y < n; y++)
|
|
64
|
-
for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 2.4 + 0.5 + (blot.at(x, y) - 0.5) * 0.7 + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.15);
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
case "vellum": {
|
|
68
|
-
const base = noise(40 * k, 40 * k, 3);
|
|
69
|
-
for (let y = 0; y < n; y++) for (let x = 0; x < n; x++) out[y * n + x] = clamp01((base.at(x, y) - 0.5) * 1.6 + 0.55 + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.2);
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
case "laid": {
|
|
73
|
-
const pulp = noise(32 * k, 32 * k, 3);
|
|
74
|
-
const chain = n / 8;
|
|
75
|
-
for (let y = 0; y < n; y++) {
|
|
76
|
-
const laid = 0.5 + 0.5 * Math.cos(2 * Math.PI * y / 4);
|
|
77
|
-
for (let x = 0; x < n; x++) {
|
|
78
|
-
const c = Math.abs((x + 0.5) % chain - chain / 2) / (chain / 2);
|
|
79
|
-
const chainLine = c > 0.94 ? -0.35 : 0;
|
|
80
|
-
out[y * n + x] = clamp01(0.3 + 0.5 * laid + chainLine + (pulp.at(x, y) - 0.5) * 0.6);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
case "ingres": {
|
|
86
|
-
const fibres = noise(64 * k, 12 * k, 3);
|
|
87
|
-
const base = noise(16 * k, 16 * k, 3, 7);
|
|
88
|
-
for (let y = 0; y < n; y++)
|
|
89
|
-
for (let x = 0; x < n; x++) {
|
|
90
|
-
const g = _chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt ^ 85);
|
|
91
|
-
out[y * n + x] = clamp01((fibres.at(x, y) - 0.5) * 1.5 + (base.at(x, y) - 0.5) * 0.7 + 0.55 + (g < 0.1 ? -0.3 : 0));
|
|
92
|
-
}
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case "sanded": {
|
|
96
|
-
const grit = noise(96 * k, 96 * k, 2);
|
|
97
|
-
for (let y = 0; y < n; y++)
|
|
98
|
-
for (let x = 0; x < n; x++) {
|
|
99
|
-
const h = _chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt);
|
|
100
|
-
out[y * n + x] = clamp01((grit.at(x, y) - 0.5) * 2.4 + 0.5 + (h - 0.5) * 0.7);
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
case "canvas":
|
|
105
|
-
case "linen": {
|
|
106
|
-
const period = (pattern === "canvas" ? 8 : 5) * k;
|
|
107
|
-
const threads = Math.max(2, 2 * Math.round(n / period / 2));
|
|
108
|
-
const p = n / threads;
|
|
109
|
-
const slub = noise(threads, threads, 2, 11);
|
|
110
|
-
for (let y = 0; y < n; y++)
|
|
111
|
-
for (let x = 0; x < n; x++) {
|
|
112
|
-
const fx = (x + 0.5) / p;
|
|
113
|
-
const fy = (y + 0.5) / p;
|
|
114
|
-
const cx = Math.floor(fx);
|
|
115
|
-
const cy = Math.floor(fy);
|
|
116
|
-
const warp = Math.sin(Math.PI * (fx - cx));
|
|
117
|
-
const weft = Math.sin(Math.PI * (fy - cy));
|
|
118
|
-
const top = (cx + cy) % 2 === 0 ? warp : weft;
|
|
119
|
-
const irregular = pattern === "linen" ? (slub.at(x, y) - 0.5) * 0.5 : 0;
|
|
120
|
-
out[y * n + x] = clamp01(0.2 + 0.7 * top + irregular + (_chunk3K6HWEXZcjs.hash2.call(void 0, x, y, salt) - 0.5) * 0.15);
|
|
121
|
-
}
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
case "gesso": {
|
|
125
|
-
const streaks = noise(2 * k, 28 * k, 3);
|
|
126
|
-
const tooth = noise(64 * k, 64 * k, 2, 13);
|
|
127
|
-
for (let y = 0; y < n; y++)
|
|
128
|
-
for (let x = 0; x < n; x++) out[y * n + x] = clamp01((streaks.at(x, y) - 0.5) * 1.8 + (tooth.at(x, y) - 0.5) * 0.9 + 0.55);
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return out;
|
|
133
|
-
}
|
|
134
|
-
var rawCache = /* @__PURE__ */ new Map();
|
|
135
|
-
function grainHeights(pattern, seed, size = GRAIN_TILE) {
|
|
136
|
-
const key = `${pattern}:${seed}:${size}`;
|
|
137
|
-
let h = rawCache.get(key);
|
|
138
|
-
if (!h) {
|
|
139
|
-
h = patternHeights(pattern, size, seed);
|
|
140
|
-
if (rawCache.size > 32) rawCache.delete(rawCache.keys().next().value);
|
|
141
|
-
rawCache.set(key, h);
|
|
142
|
-
}
|
|
143
|
-
return h;
|
|
144
|
-
}
|
|
145
|
-
var PaperGrain = (_class = class {
|
|
146
|
-
__init() {this.size = GRAIN_TILE}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
constructor(paper, media = "dry") {;_class.prototype.__init.call(this);
|
|
154
|
-
const raw = grainHeights(paper.pattern, paper.seed);
|
|
155
|
-
const t = paper[media];
|
|
156
|
-
this.flat = paper.pattern === "smooth";
|
|
157
|
-
if (t.contrast === 1 && !t.invert) this.heights = raw;
|
|
158
|
-
else {
|
|
159
|
-
const out = new Float32Array(raw.length);
|
|
160
|
-
for (let i = 0; i < raw.length; i++) {
|
|
161
|
-
const v = clamp01((raw[i] - 0.5) * t.contrast + 0.5);
|
|
162
|
-
out[i] = t.invert ? 1 - v : v;
|
|
163
|
-
}
|
|
164
|
-
this.heights = out;
|
|
165
|
-
}
|
|
166
|
-
this.scale = paper.scale;
|
|
167
|
-
this.mirror = paper.tiling === "mirror";
|
|
168
|
-
this.ox = _nullishCoalesce(_optionalChain([paper, 'access', _ => _.offset, 'optionalAccess', _2 => _2.x]), () => ( 0));
|
|
169
|
-
this.oy = _nullishCoalesce(_optionalChain([paper, 'access', _3 => _3.offset, 'optionalAccess', _4 => _4.y]), () => ( 0));
|
|
170
|
-
}
|
|
171
|
-
/** Tile cell index for a coordinate in grain pixels (mirrored on odd tiles when mirroring). */
|
|
172
|
-
wrap(v) {
|
|
173
|
-
const n = this.size;
|
|
174
|
-
if (!this.mirror) return (v % n + n) % n;
|
|
175
|
-
const p = (v % (2 * n) + 2 * n) % (2 * n);
|
|
176
|
-
return p < n ? p : 2 * n - 1 - p;
|
|
177
|
-
}
|
|
178
|
-
/** Height 0..1 at document position (x, y). */
|
|
179
|
-
at(x, y) {
|
|
180
|
-
const u = (x - this.ox) / this.scale - 0.5;
|
|
181
|
-
const v = (y - this.oy) / this.scale - 0.5;
|
|
182
|
-
const x0 = Math.floor(u);
|
|
183
|
-
const y0 = Math.floor(v);
|
|
184
|
-
const fx = u - x0;
|
|
185
|
-
const fy = v - y0;
|
|
186
|
-
const n = this.size;
|
|
187
|
-
const h = this.heights;
|
|
188
|
-
const a = this.wrap(x0);
|
|
189
|
-
const b = this.wrap(x0 + 1);
|
|
190
|
-
const c = this.wrap(y0) * n;
|
|
191
|
-
const d = this.wrap(y0 + 1) * n;
|
|
192
|
-
const top = h[c + a] + (h[c + b] - h[c + a]) * fx;
|
|
193
|
-
const bot = h[d + a] + (h[d + b] - h[d + a]) * fx;
|
|
194
|
-
return top + (bot - top) * fy;
|
|
195
|
-
}
|
|
196
|
-
}, _class);
|
|
197
|
-
function grainCatch(h, depth, pressure) {
|
|
198
|
-
if (depth <= 0) return 1;
|
|
199
|
-
const t = depth * (0.75 - 0.65 * Math.min(1, Math.max(0, pressure)));
|
|
200
|
-
const u = clamp01((h - t + 0.18) / 0.36);
|
|
201
|
-
return 1 - depth + depth * u * u * (3 - 2 * u);
|
|
202
|
-
}
|
|
203
|
-
function strokeGrainCatch(h, depth, pressure) {
|
|
204
|
-
if (depth <= 0) return 1;
|
|
205
|
-
const p = Math.min(1, Math.max(0, pressure));
|
|
206
|
-
const amount = Math.min(1, depth * (1.4 - 0.6 * p));
|
|
207
|
-
const u = clamp01((h - 0.2 - 0.25 * (1 - p)) / 0.5);
|
|
208
|
-
return 1 - amount + amount * u * u * (3 - 2 * u);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
37
|
// src/paint/path-stroke.ts
|
|
212
38
|
var JITTER_SIZE = 1;
|
|
213
39
|
var JITTER_ANGLE = 2;
|
|
@@ -228,16 +54,16 @@ function lean(s) {
|
|
|
228
54
|
return null;
|
|
229
55
|
}
|
|
230
56
|
function pathStrokeDabs(samples, options) {
|
|
231
|
-
const brush =
|
|
57
|
+
const brush = _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, options.brush);
|
|
232
58
|
const pts = options.closed && samples.length > 2 ? [...samples, samples[0]] : [...samples];
|
|
233
59
|
if (!pts.length) return [];
|
|
234
60
|
const tilt = _nullishCoalesce(options.tilt, () => ( {}));
|
|
235
61
|
const minSize = Math.min(1, Math.max(0, _nullishCoalesce(options.minSize, () => ( 0))));
|
|
236
62
|
let index = 0;
|
|
237
|
-
const t0 = _nullishCoalesce(_optionalChain([pts, 'access',
|
|
63
|
+
const t0 = _nullishCoalesce(_optionalChain([pts, 'access', _ => _.find, 'call', _2 => _2((s) => typeof s.t === "number" && Number.isFinite(s.t)), 'optionalAccess', _3 => _3.t]), () => ( null));
|
|
238
64
|
const dab = (x, y, p, l, dir, travel = 0, time = null, speed = null) => {
|
|
239
65
|
const pr = Math.min(1, Math.max(0, p));
|
|
240
|
-
const lean0 = _nullishCoalesce(_optionalChain([l, 'optionalAccess',
|
|
66
|
+
const lean0 = _nullishCoalesce(_optionalChain([l, 'optionalAccess', _4 => _4.amount]), () => ( 0));
|
|
241
67
|
const size = brush.size * (brush.pressureSize ? minSize + (1 - minSize) * pr : 1) * (1 + 1.5 * (_nullishCoalesce(tilt.size, () => ( 0))) * lean0);
|
|
242
68
|
let angle = brush.angle * Math.PI / 180;
|
|
243
69
|
if (options.followPath) angle += dir;
|
|
@@ -301,24 +127,24 @@ function pathStrokeDabs(samples, options) {
|
|
|
301
127
|
return out;
|
|
302
128
|
}
|
|
303
129
|
function pathStrokeCoverage(samples, options) {
|
|
304
|
-
const brush =
|
|
305
|
-
const coverage = new (0,
|
|
130
|
+
const brush = _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, options.brush);
|
|
131
|
+
const coverage = new (0, _chunkNIBFKXMDcjs.CoverageMap)();
|
|
306
132
|
const dabs = pathStrokeDabs(samples, options);
|
|
307
|
-
const g = _optionalChain([options, 'access',
|
|
308
|
-
const sampler = g ? new (0,
|
|
309
|
-
const tipTable = _optionalChain([sampler, 'optionalAccess',
|
|
133
|
+
const g = _optionalChain([options, 'access', _5 => _5.gradient, 'optionalAccess', _6 => _6.paint, 'access', _7 => _7.type]) === "gradient" ? options.gradient : null;
|
|
134
|
+
const sampler = g ? new (0, _chunkNIBFKXMDcjs.PaintGradientSampler)(_chunkNIBFKXMDcjs.resolvePaintGradient.call(void 0, g.paint, _nullishCoalesce(g.colors, () => ( { paint: "#000000", secondary: "#ffffff" }))), _nullishCoalesce(g.seed, () => ( 0))) : null;
|
|
135
|
+
const tipTable = _optionalChain([sampler, 'optionalAccess', _8 => _8.acrossTip]) ? sampler.tipTable(_chunkNIBFKXMDcjs.TIP_GRADIENT_STEPS) : null;
|
|
310
136
|
const scratch = { field: new Float32Array(0), sample: { rgb: [0, 0, 0], alpha: 1 } };
|
|
311
137
|
let buf = new Float32Array(0);
|
|
312
138
|
let bounds = null;
|
|
313
139
|
for (const d of dabs) {
|
|
314
|
-
const rect =
|
|
140
|
+
const rect = _chunkNIBFKXMDcjs.dabRect.call(void 0, d, brush.hardness);
|
|
315
141
|
const n = rect.width * rect.height;
|
|
316
142
|
if (n <= 0) continue;
|
|
317
143
|
if (buf.length < n) buf = new Float32Array(n);
|
|
318
144
|
const vals = buf.subarray(0, n);
|
|
319
|
-
|
|
145
|
+
_chunkNIBFKXMDcjs.rasterizeDab.call(void 0, d, brush.hardness, rect, vals);
|
|
320
146
|
if (sampler) {
|
|
321
|
-
const { color, field } =
|
|
147
|
+
const { color, field } = _chunkNIBFKXMDcjs.gradientDabColor.call(void 0, sampler, tipTable, d, d.params, rect, vals, scratch);
|
|
322
148
|
coverage.accumulate(rect, vals, d.opacity, color, field);
|
|
323
149
|
} else coverage.accumulate(rect, vals, d.opacity);
|
|
324
150
|
if (!bounds) bounds = { ...rect };
|
|
@@ -330,12 +156,12 @@ function pathStrokeCoverage(samples, options) {
|
|
|
330
156
|
}
|
|
331
157
|
const grain = options.grain;
|
|
332
158
|
if (grain && grain.depth > 0 && dabs.length) {
|
|
333
|
-
const pressure = dabs.reduce((sum, d) => sum + (_nullishCoalesce(_optionalChain([d, 'access',
|
|
159
|
+
const pressure = dabs.reduce((sum, d) => sum + (_nullishCoalesce(_optionalChain([d, 'access', _9 => _9.params, 'optionalAccess', _10 => _10.pressure]), () => ( 1))), 0) / dabs.length;
|
|
334
160
|
for (const [key, t] of coverage.tiles) {
|
|
335
161
|
const { tx, ty } = _chunk474IQG74cjs.tileCoord.call(void 0, key);
|
|
336
162
|
for (let y = 0, k = 0; y < _chunk474IQG74cjs.TILE; y++) {
|
|
337
163
|
const gy = ty * _chunk474IQG74cjs.TILE + y + 0.5;
|
|
338
|
-
for (let x = 0; x < _chunk474IQG74cjs.TILE; x++, k++) if (t[k] > 0) t[k] *= strokeGrainCatch(grain.at(tx * _chunk474IQG74cjs.TILE + x + 0.5, gy), grain.depth, pressure);
|
|
164
|
+
for (let x = 0; x < _chunk474IQG74cjs.TILE; x++, k++) if (t[k] > 0) t[k] *= _chunkNIBFKXMDcjs.strokeGrainCatch.call(void 0, grain.at(tx * _chunk474IQG74cjs.TILE + x + 0.5, gy), grain.depth, pressure);
|
|
339
165
|
}
|
|
340
166
|
}
|
|
341
167
|
}
|
|
@@ -343,14 +169,14 @@ function pathStrokeCoverage(samples, options) {
|
|
|
343
169
|
}
|
|
344
170
|
function paintPathStroke(surface, samples, options) {
|
|
345
171
|
if (surface.channels !== 4) throw new Error("paintPathStroke paints RGBA surfaces (4 channels).");
|
|
346
|
-
const brush =
|
|
172
|
+
const brush = _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, options.brush);
|
|
347
173
|
const hex = (c) => "#" + [0, 1, 2].map((i) => Math.round(Math.min(255, Math.max(0, c[i]))).toString(16).padStart(2, "0")).join("");
|
|
348
174
|
let color = options.color;
|
|
349
|
-
if (_optionalChain([options, 'access',
|
|
350
|
-
const rgb =
|
|
175
|
+
if (_optionalChain([options, 'access', _11 => _11.paint, 'optionalAccess', _12 => _12.paint, 'access', _13 => _13.type]) === "color") {
|
|
176
|
+
const rgb = _chunkNIBFKXMDcjs.hexToPaintRgb.call(void 0, options.paint.paint.color).map((v) => Math.round(v * 255));
|
|
351
177
|
color = [rgb[0], rgb[1], rgb[2], color[3]];
|
|
352
178
|
}
|
|
353
|
-
const gradient = _optionalChain([options, 'access',
|
|
179
|
+
const gradient = _optionalChain([options, 'access', _14 => _14.paint, 'optionalAccess', _15 => _15.paint, 'access', _16 => _16.type]) === "gradient" ? { ...options.paint, colors: _nullishCoalesce(options.paint.colors, () => ( { paint: hex(color), secondary: "#ffffff" })) } : null;
|
|
354
180
|
const { coverage, bounds, dabs } = pathStrokeCoverage(samples, { ...options, gradient });
|
|
355
181
|
if (!bounds) return { surface, bounds: null, dabs };
|
|
356
182
|
const offset = _nullishCoalesce(options.offset, () => ( { x: 0, y: 0 }));
|
|
@@ -367,9 +193,9 @@ function paintPathStroke(surface, samples, options) {
|
|
|
367
193
|
const tiles = new Map(surface.tiles);
|
|
368
194
|
for (const { tx, ty } of _chunk474IQG74cjs.tilesInRect.call(void 0, { x: bounds.x - offset.x, y: bounds.y - offset.y, width: bounds.width, height: bounds.height })) {
|
|
369
195
|
const key = _chunk474IQG74cjs.tileKey.call(void 0, tx, ty);
|
|
370
|
-
const src = _optionalChain([surface, 'access',
|
|
196
|
+
const src = _optionalChain([surface, 'access', _17 => _17.tiles, 'access', _18 => _18.get, 'call', _19 => _19(key), 'optionalAccess', _20 => _20.data]);
|
|
371
197
|
const base = src && src.length === _chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE * 4 ? src : new Uint8ClampedArray(_chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE * 4);
|
|
372
|
-
const t = _chunk474IQG74cjs.finishTile.call(void 0,
|
|
198
|
+
const t = _chunk474IQG74cjs.finishTile.call(void 0, _chunkNIBFKXMDcjs.applyStrokeToTile.call(void 0, coverage, base, 4, tx, ty, apply), 4, surface.defaultValue);
|
|
373
199
|
if (t) tiles.set(key, t);
|
|
374
200
|
else tiles.delete(key);
|
|
375
201
|
}
|
|
@@ -413,7 +239,7 @@ var REFUSED_ENGINES = {
|
|
|
413
239
|
};
|
|
414
240
|
function brushstrokeStrokeOptions(brush) {
|
|
415
241
|
if (!brush || typeof brush !== "object") throw new Error("A brushstroke needs a brush: tip settings ({ size, hardness, \u2026 }) or a paint brush preset.");
|
|
416
|
-
if (!("tip" in brush) || !brush.tip) return { brush:
|
|
242
|
+
if (!("tip" in brush) || !brush.tip) return { brush: _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, brush) };
|
|
417
243
|
const engine = _nullishCoalesce(brush.engine, () => ( "dab"));
|
|
418
244
|
if (engine !== "dab") {
|
|
419
245
|
const label = _nullishCoalesce(_nullishCoalesce(brush.name, () => ( brush.id)), () => ( "This brush"));
|
|
@@ -423,7 +249,7 @@ function brushstrokeStrokeOptions(brush) {
|
|
|
423
249
|
const d = _nullishCoalesce(brush.dynamics, () => ( {}));
|
|
424
250
|
const tilt = { size: _nullishCoalesce(d.tiltSize, () => ( 0)), roundness: _nullishCoalesce(d.tiltRoundness, () => ( 0)) };
|
|
425
251
|
return {
|
|
426
|
-
brush:
|
|
252
|
+
brush: _chunkNIBFKXMDcjs.normalizeBrush.call(void 0, brush.tip),
|
|
427
253
|
followPath: brush.rotation === "stroke",
|
|
428
254
|
minSize: _nullishCoalesce(d.minSize, () => ( 0)),
|
|
429
255
|
...tilt.size || tilt.roundness ? { tilt } : {}
|
|
@@ -447,7 +273,7 @@ function paperGrain(paper) {
|
|
|
447
273
|
const key = `${pattern}:${seed}:${scale}`;
|
|
448
274
|
let g = papers.get(key);
|
|
449
275
|
if (!g) {
|
|
450
|
-
g = new PaperGrain({ pattern, seed, scale, tiling: "mirror", dry: { contrast: 1, invert: false }, wet: { contrast: 1, invert: false } });
|
|
276
|
+
g = new (0, _chunkNIBFKXMDcjs.PaperGrain)({ pattern, seed, scale, tiling: "mirror", dry: { contrast: 1, invert: false }, wet: { contrast: 1, invert: false } });
|
|
451
277
|
if (papers.size > 16) papers.delete(papers.keys().next().value);
|
|
452
278
|
papers.set(key, g);
|
|
453
279
|
}
|
|
@@ -463,7 +289,7 @@ function renderBrushstroke(input, brush, options = {}) {
|
|
|
463
289
|
let scale = finite(options.scale) && options.scale > 0 ? Math.min(_chunkYQGCPL5Xcjs.BRUSHSTROKE_MAX_SCALE, Math.max(_chunkYQGCPL5Xcjs.BRUSHSTROKE_MIN_SCALE, options.scale)) : 1;
|
|
464
290
|
if (!samples.length) return { image: { width: 0, height: 0, data: new Uint8ClampedArray(0) }, bounds: null, scale, dabs: 0 };
|
|
465
291
|
const tip = strokeOptions.brush;
|
|
466
|
-
const reach = tip.size * (1 + 1.5 * (_nullishCoalesce(_optionalChain([strokeOptions, 'access',
|
|
292
|
+
const reach = tip.size * (1 + 1.5 * (_nullishCoalesce(_optionalChain([strokeOptions, 'access', _21 => _21.tilt, 'optionalAccess', _22 => _22.size]), () => ( 0)))) + 4;
|
|
467
293
|
let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
468
294
|
for (const s of samples) {
|
|
469
295
|
x0 = Math.min(x0, s.x);
|
|
@@ -486,8 +312,8 @@ function renderBrushstroke(input, brush, options = {}) {
|
|
|
486
312
|
let grain;
|
|
487
313
|
if (paper && depth > 0) {
|
|
488
314
|
const g = paperGrain(paper);
|
|
489
|
-
const ox = _nullishCoalesce(_optionalChain([ch, 'access',
|
|
490
|
-
const oy = _nullishCoalesce(_optionalChain([ch, 'access',
|
|
315
|
+
const ox = _nullishCoalesce(_optionalChain([ch, 'access', _23 => _23.origin, 'optionalAccess', _24 => _24.x]), () => ( 0));
|
|
316
|
+
const oy = _nullishCoalesce(_optionalChain([ch, 'access', _25 => _25.origin, 'optionalAccess', _26 => _26.y]), () => ( 0));
|
|
491
317
|
const k = (finite(ch.unit) && ch.unit > 0 ? ch.unit : 1) / scale;
|
|
492
318
|
grain = { depth, at: (x, y) => g.at(ox + x * k, oy + y * k) };
|
|
493
319
|
}
|
|
@@ -500,7 +326,7 @@ function renderBrushstroke(input, brush, options = {}) {
|
|
|
500
326
|
closed: _nullishCoalesce(options.closed, () => ( strokeOptions.closed)),
|
|
501
327
|
color,
|
|
502
328
|
// Gradient lengths are in path units: scale them with the image.
|
|
503
|
-
...source ? { paint: { paint: source.type === "gradient" ?
|
|
329
|
+
...source ? { paint: { paint: source.type === "gradient" ? _chunkNIBFKXMDcjs.scalePaintGradient.call(void 0, source, scale) : source, seed: _nullishCoalesce(options.seed, () => ( 0)) } } : {}
|
|
504
330
|
});
|
|
505
331
|
if (!bounds) return { image: { width: 0, height: 0, data: new Uint8ClampedArray(0) }, bounds: null, scale, dabs };
|
|
506
332
|
const rect = bounds;
|
|
@@ -542,14 +368,14 @@ function brushstrokeKey(input, brush, options = {}) {
|
|
|
542
368
|
const scale = finite(options.scale) ? options.scale : 1;
|
|
543
369
|
return `${hashString(path).toString(16)}:${path.length}:${hashString(rest2).toString(16)}:${scale}`;
|
|
544
370
|
}
|
|
545
|
-
var BrushstrokeCache = (
|
|
546
|
-
constructor(capacity = 64) {;
|
|
371
|
+
var BrushstrokeCache = (_class = class {
|
|
372
|
+
constructor(capacity = 64) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
547
373
|
this.capacity = capacity;
|
|
548
374
|
}
|
|
549
375
|
|
|
550
|
-
|
|
376
|
+
__init() {this.entries = /* @__PURE__ */ new Map()}
|
|
551
377
|
/** Renders that missed the cache (for tests and stats). */
|
|
552
|
-
|
|
378
|
+
__init2() {this.misses = 0}
|
|
553
379
|
get size() {
|
|
554
380
|
return this.entries.size;
|
|
555
381
|
}
|
|
@@ -571,13 +397,7 @@ var BrushstrokeCache = (_class2 = class {
|
|
|
571
397
|
clear() {
|
|
572
398
|
this.entries.clear();
|
|
573
399
|
}
|
|
574
|
-
},
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
400
|
+
}, _class);
|
|
581
401
|
|
|
582
402
|
|
|
583
403
|
|
|
@@ -591,4 +411,4 @@ var BrushstrokeCache = (_class2 = class {
|
|
|
591
411
|
|
|
592
412
|
|
|
593
413
|
|
|
594
|
-
exports.
|
|
414
|
+
exports.pathStrokeDabs = pathStrokeDabs; exports.pathStrokeCoverage = pathStrokeCoverage; exports.paintPathStroke = paintPathStroke; exports.brushstrokeSamples = brushstrokeSamples; exports.brushstrokeStrokeOptions = brushstrokeStrokeOptions; exports.isBrushstrokeBrush = isBrushstrokeBrush; exports.renderBrushstroke = renderBrushstroke; exports.brushstrokeDataUrl = brushstrokeDataUrl; exports.brushstrokeToCanvas = brushstrokeToCanvas; exports.brushstrokeKey = brushstrokeKey; exports.BrushstrokeCache = BrushstrokeCache;
|