@pixerate/editor 0.135.0 → 0.137.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 +63 -55
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +8 -5
- package/dist/animation-editor/index.d.ts +8 -5
- package/dist/animation-editor/index.js +10 -2
- package/dist/animation-editor/index.js.map +1 -1
- package/dist/{bezier-J8i4uqSH.d.cts → bezier-CZ2AhjID.d.cts} +1 -1
- package/dist/{bezier-lNEOp0Jx.d.ts → bezier-Dywv3Bw8.d.ts} +1 -1
- package/dist/blending-D7jCmjO6.d.cts +1026 -0
- package/dist/blending-NgF3qo3d.d.ts +1026 -0
- package/dist/brushes-CnvZSYYU.d.cts +744 -0
- package/dist/brushes-DJmUbIgz.d.ts +744 -0
- package/dist/{brushstrokeRender-SII6MG4R.js → brushstrokeRender-2FAXA3XC.js} +13 -16
- package/dist/{brushstrokeRender-SII6MG4R.js.map → brushstrokeRender-2FAXA3XC.js.map} +1 -1
- package/dist/{brushstrokeRender-JNHVEUFG.cjs → brushstrokeRender-IMFY3FF6.cjs} +16 -19
- package/dist/brushstrokeRender-IMFY3FF6.cjs.map +1 -0
- package/dist/canvas/index.cjs +10 -10
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +10 -7
- package/dist/canvas/index.d.ts +10 -7
- package/dist/canvas/index.js +4 -4
- package/dist/{chunk-W4LNKTHT.cjs → chunk-2XS6LTUP.cjs} +63 -63
- package/dist/{chunk-W4LNKTHT.cjs.map → chunk-2XS6LTUP.cjs.map} +1 -1
- package/dist/{chunk-HHTCDFZC.js → chunk-3D77LOBM.js} +234 -136
- package/dist/chunk-3D77LOBM.js.map +1 -0
- package/dist/{chunk-BR7EKQUP.js → chunk-3G6J7UFV.js} +322 -2
- package/dist/chunk-3G6J7UFV.js.map +1 -0
- package/dist/{chunk-62XUO5LB.js → chunk-3X6IAJUQ.js} +2 -2
- package/dist/{chunk-EM3FMJWE.js → chunk-5FSRTP6E.js} +320 -3
- package/dist/chunk-5FSRTP6E.js.map +1 -0
- package/dist/{chunk-Z2H7KECK.cjs → chunk-5OOIUXNJ.cjs} +345 -247
- package/dist/chunk-5OOIUXNJ.cjs.map +1 -0
- package/dist/{chunk-7RJ6P7MI.js → chunk-6S6362D2.js} +2 -2
- package/dist/chunk-A3BVTI3G.js +150 -0
- package/dist/chunk-A3BVTI3G.js.map +1 -0
- package/dist/{chunk-24ATT2PE.cjs → chunk-AEAAN4AD.cjs} +120 -120
- package/dist/{chunk-24ATT2PE.cjs.map → chunk-AEAAN4AD.cjs.map} +1 -1
- package/dist/chunk-ECCXGELC.cjs +727 -0
- package/dist/chunk-ECCXGELC.cjs.map +1 -0
- package/dist/{chunk-SVYE5HIM.js → chunk-EQQMGO42.js} +2 -2
- package/dist/{chunk-FHPVDTI2.cjs → chunk-F2Y4E4GU.cjs} +22 -22
- package/dist/{chunk-FHPVDTI2.cjs.map → chunk-F2Y4E4GU.cjs.map} +1 -1
- package/dist/{chunk-OXSV64JX.js → chunk-G6IKY6PL.js} +4 -4
- package/dist/{chunk-UYQUPUR6.js → chunk-HUO3TI4C.js} +3 -3
- package/dist/chunk-I52DRGGJ.js +727 -0
- package/dist/chunk-I52DRGGJ.js.map +1 -0
- package/dist/{chunk-DDSO4HS7.cjs → chunk-KEENUAFN.cjs} +2 -2
- package/dist/{chunk-DDSO4HS7.cjs.map → chunk-KEENUAFN.cjs.map} +1 -1
- package/dist/{chunk-2HC4DRF4.js → chunk-LLFHCSU2.js} +2 -2
- package/dist/{chunk-J5BA3BQ6.cjs → chunk-O7LUD7MH.cjs} +323 -3
- package/dist/chunk-O7LUD7MH.cjs.map +1 -0
- package/dist/{chunk-ILYFOJUN.js → chunk-OIBIRXRG.js} +3 -3
- package/dist/{chunk-FWEO3HSL.js → chunk-PQQF5KOW.js} +8 -8
- package/dist/{chunk-T6TV6HY6.cjs → chunk-PRSRYHQD.cjs} +36 -36
- package/dist/{chunk-T6TV6HY6.cjs.map → chunk-PRSRYHQD.cjs.map} +1 -1
- package/dist/chunk-Q6OUXEK3.cjs +150 -0
- package/dist/chunk-Q6OUXEK3.cjs.map +1 -0
- package/dist/{chunk-6GFRKLLS.cjs → chunk-QBWEH3IM.cjs} +429 -112
- package/dist/chunk-QBWEH3IM.cjs.map +1 -0
- package/dist/{chunk-ESIWZMMK.js → chunk-SYT2TLQF.js} +35 -37
- package/dist/{chunk-ESIWZMMK.js.map → chunk-SYT2TLQF.js.map} +1 -1
- package/dist/{chunk-YT3JL7YM.cjs → chunk-TLCTTQFF.cjs} +53 -53
- package/dist/{chunk-YT3JL7YM.cjs.map → chunk-TLCTTQFF.cjs.map} +1 -1
- package/dist/{chunk-P3RQ5UJE.cjs → chunk-UTQKC66X.cjs} +4 -4
- package/dist/{chunk-P3RQ5UJE.cjs.map → chunk-UTQKC66X.cjs.map} +1 -1
- package/dist/{chunk-J3B45HTA.cjs → chunk-XB25WOC2.cjs} +6 -6
- package/dist/{chunk-J3B45HTA.cjs.map → chunk-XB25WOC2.cjs.map} +1 -1
- package/dist/{chunk-YAFS2QFZ.cjs → chunk-XN2NBLV5.cjs} +313 -315
- package/dist/chunk-XN2NBLV5.cjs.map +1 -0
- package/dist/effects/index.d.cts +7 -4
- package/dist/effects/index.d.ts +7 -4
- package/dist/{export-DMeG6E06.d.ts → export-41rL6Cne.d.ts} +1 -1
- package/dist/{export-AZSwX087.d.cts → export-CyJdfP_Z.d.cts} +5 -4
- package/dist/{export-KzubBKo7.d.cts → export-D9mXp05Q.d.cts} +1 -1
- package/dist/{export-BDkyDNM8.d.ts → export-DwnZ_hvQ.d.ts} +5 -4
- package/dist/extensions/index.cjs +3 -3
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.js +2 -2
- package/dist/generation/index.cjs +150 -945
- package/dist/generation/index.cjs.map +1 -1
- package/dist/generation/index.d.cts +3 -423
- package/dist/generation/index.d.ts +3 -423
- package/dist/generation/index.js +59 -854
- package/dist/generation/index.js.map +1 -1
- package/dist/grammar/index.cjs +3 -3
- package/dist/grammar/index.cjs.map +1 -1
- package/dist/grammar/index.js +2 -2
- package/dist/{helpers-Coa4e2j_.d.ts → helpers-C-RgeyvH.d.ts} +25 -8
- package/dist/{helpers-DHl28yLO.d.cts → helpers-v6GMazzg.d.cts} +25 -8
- package/dist/image-editor/index.cjs +986 -986
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +15 -11
- package/dist/image-editor/index.d.ts +15 -11
- package/dist/image-editor/index.js +94 -94
- package/dist/index.cjs +28 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -36
- package/dist/{opentype-BWR7Qv8W.d.cts → opentype-KR_jj6b_.d.cts} +1 -1
- package/dist/{opentype-Dfcx6wFx.d.ts → opentype-a1KAW-qs.d.ts} +1 -1
- package/dist/paint/index.cjs +5 -8
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +4 -2
- package/dist/paint/index.d.ts +4 -2
- package/dist/paint/index.js +15 -18
- package/dist/paint-editor/index.cjs +405 -403
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +15 -748
- package/dist/paint-editor/index.d.ts +15 -748
- package/dist/paint-editor/index.js +79 -77
- package/dist/paint-editor/index.js.map +1 -1
- package/dist/{pathfinder-D8KQ6blQ.d.cts → pathfinder-BHS4vQNm.d.cts} +1 -1
- package/dist/{pathfinder-Celbi3e6.d.ts → pathfinder-BVvTIBMo.d.ts} +1 -1
- package/dist/{pool-8JZGWHvR.d.ts → pool-CZQOrSXZ.d.ts} +1 -1
- package/dist/{pool-BfuxBKTd.d.cts → pool-FjZZmZ80.d.cts} +1 -1
- package/dist/provenance-DmlcgdzT.d.cts +426 -0
- package/dist/provenance-uh5r2TQ8.d.ts +426 -0
- package/dist/rand-8xbUb6ur.d.ts +1118 -0
- package/dist/rand-Cw9VLrVC.d.cts +1118 -0
- package/dist/raster/index.cjs +17 -19
- package/dist/raster/index.cjs.map +1 -1
- package/dist/raster/index.js +9 -11
- package/dist/raster/index.js.map +1 -1
- package/dist/{svg-CxxqG3_W.d.ts → svg-CSz3mzkw.d.ts} +2 -2
- package/dist/{svg-pwXWq6s2.d.cts → svg-DTb40ICU.d.cts} +2 -2
- package/dist/{tools-y1M6O3UT.d.ts → tools-B0wXP5cF.d.ts} +1 -1
- package/dist/{tools-3EBjR91b.d.cts → tools-Ca0kI1qo.d.cts} +1 -1
- package/dist/vector/index.cjs +2698 -1674
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +390 -72
- package/dist/vector/index.d.ts +390 -72
- package/dist/vector/index.js +1665 -641
- package/dist/vector/index.js.map +1 -1
- package/dist/video-editor/index.d.cts +7 -4
- package/dist/video-editor/index.d.ts +7 -4
- package/dist/{warp-Ceqdz7kj.d.cts → warp-DTOp0lON.d.cts} +1 -1
- package/dist/{warp-C1gwu2G_.d.ts → warp-pd7hrH4T.d.ts} +1 -1
- package/package.json +1 -1
- package/skills/pixerate-vector/SKILL.md +22 -0
- package/dist/brushstrokeRender-JNHVEUFG.cjs.map +0 -1
- package/dist/chunk-64PYNEHJ.js +0 -340
- package/dist/chunk-64PYNEHJ.js.map +0 -1
- package/dist/chunk-6GFRKLLS.cjs.map +0 -1
- package/dist/chunk-7QN76ESJ.js +0 -323
- package/dist/chunk-7QN76ESJ.js.map +0 -1
- package/dist/chunk-BR7EKQUP.js.map +0 -1
- package/dist/chunk-DCLJNVZS.cjs +0 -323
- package/dist/chunk-DCLJNVZS.cjs.map +0 -1
- package/dist/chunk-EM3FMJWE.js.map +0 -1
- package/dist/chunk-HHTCDFZC.js.map +0 -1
- package/dist/chunk-J5BA3BQ6.cjs.map +0 -1
- package/dist/chunk-YAFS2QFZ.cjs.map +0 -1
- package/dist/chunk-Z2H7KECK.cjs.map +0 -1
- package/dist/chunk-Z6OUCS2K.cjs +0 -340
- package/dist/chunk-Z6OUCS2K.cjs.map +0 -1
- package/dist/rand-BszBST4s.d.ts +0 -2140
- package/dist/rand-DOH_aMvm.d.cts +0 -2140
- /package/dist/{chunk-62XUO5LB.js.map → chunk-3X6IAJUQ.js.map} +0 -0
- /package/dist/{chunk-7RJ6P7MI.js.map → chunk-6S6362D2.js.map} +0 -0
- /package/dist/{chunk-SVYE5HIM.js.map → chunk-EQQMGO42.js.map} +0 -0
- /package/dist/{chunk-OXSV64JX.js.map → chunk-G6IKY6PL.js.map} +0 -0
- /package/dist/{chunk-UYQUPUR6.js.map → chunk-HUO3TI4C.js.map} +0 -0
- /package/dist/{chunk-2HC4DRF4.js.map → chunk-LLFHCSU2.js.map} +0 -0
- /package/dist/{chunk-ILYFOJUN.js.map → chunk-OIBIRXRG.js.map} +0 -0
- /package/dist/{chunk-FWEO3HSL.js.map → chunk-PQQF5KOW.js.map} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
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; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7;
|
|
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; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
var _chunkSYPFUL5Bcjs = require('./chunk-SYPFUL5B.cjs');
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
@@ -12,7 +13,16 @@
|
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
var _chunkO7LUD7MHcjs = require('./chunk-O7LUD7MH.cjs');
|
|
16
26
|
|
|
17
27
|
// src/paint/rand.ts
|
|
18
28
|
function mix32(h) {
|
|
@@ -237,7 +247,7 @@ var PaintGradientSampler = class {
|
|
|
237
247
|
return out;
|
|
238
248
|
}
|
|
239
249
|
if (this.source.space === "pigment") {
|
|
240
|
-
|
|
250
|
+
_chunkO7LUD7MHcjs.mixPigment8.call(void 0, q8(ar[0]), q8(ar[1]), q8(ar[2]), q8(br[0]), q8(br[1]), q8(br[2]), v, mixScratch);
|
|
241
251
|
out.rgb = [mixScratch[0], mixScratch[1], mixScratch[2]];
|
|
242
252
|
} else if (this.source.space === "oklab") {
|
|
243
253
|
const la = a.lab;
|
|
@@ -721,7 +731,7 @@ function rasterizeDab(d, hardness, rect, out) {
|
|
|
721
731
|
}
|
|
722
732
|
}
|
|
723
733
|
}
|
|
724
|
-
var TILE_PIXELS =
|
|
734
|
+
var TILE_PIXELS = _chunkO7LUD7MHcjs.TILE * _chunkO7LUD7MHcjs.TILE;
|
|
725
735
|
var CoverageMap = (_class2 = class {constructor() { _class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_class2.prototype.__init13.call(this);_class2.prototype.__init14.call(this); }
|
|
726
736
|
__init11() {this.tiles = /* @__PURE__ */ new Map()}
|
|
727
737
|
/**
|
|
@@ -734,21 +744,21 @@ var CoverageMap = (_class2 = class {constructor() { _class2.prototype.__init11.c
|
|
|
734
744
|
__init14() {this.dirty = /* @__PURE__ */ new Set()}
|
|
735
745
|
/** The colour at a pixel (gradient paint), or `null` when the stroke has one colour there. */
|
|
736
746
|
colorAt(x, y, out) {
|
|
737
|
-
const tx = Math.floor(x /
|
|
738
|
-
const ty = Math.floor(y /
|
|
739
|
-
const t = this.colors.get(
|
|
747
|
+
const tx = Math.floor(x / _chunkO7LUD7MHcjs.TILE);
|
|
748
|
+
const ty = Math.floor(y / _chunkO7LUD7MHcjs.TILE);
|
|
749
|
+
const t = this.colors.get(_chunkO7LUD7MHcjs.tileKey.call(void 0, tx, ty));
|
|
740
750
|
if (!t) return null;
|
|
741
|
-
const i = ((y - ty *
|
|
751
|
+
const i = ((y - ty * _chunkO7LUD7MHcjs.TILE) * _chunkO7LUD7MHcjs.TILE + (x - tx * _chunkO7LUD7MHcjs.TILE)) * 3;
|
|
742
752
|
out[0] = t[i];
|
|
743
753
|
out[1] = t[i + 1];
|
|
744
754
|
out[2] = t[i + 2];
|
|
745
755
|
return out;
|
|
746
756
|
}
|
|
747
757
|
get(x, y) {
|
|
748
|
-
const tx = Math.floor(x /
|
|
749
|
-
const ty = Math.floor(y /
|
|
750
|
-
const t = this.tiles.get(
|
|
751
|
-
return t ? t[(y - ty *
|
|
758
|
+
const tx = Math.floor(x / _chunkO7LUD7MHcjs.TILE);
|
|
759
|
+
const ty = Math.floor(y / _chunkO7LUD7MHcjs.TILE);
|
|
760
|
+
const t = this.tiles.get(_chunkO7LUD7MHcjs.tileKey.call(void 0, tx, ty));
|
|
761
|
+
return t ? t[(y - ty * _chunkO7LUD7MHcjs.TILE) * _chunkO7LUD7MHcjs.TILE + (x - tx * _chunkO7LUD7MHcjs.TILE)] : 0;
|
|
752
762
|
}
|
|
753
763
|
/**
|
|
754
764
|
* Builds up `vals` (over `rect`) with flow towards `ceil`: `c ← c + v·(ceil − c)`. With `color`
|
|
@@ -758,26 +768,26 @@ var CoverageMap = (_class2 = class {constructor() { _class2.prototype.__init11.c
|
|
|
758
768
|
accumulate(rect, vals, ceil, color = null, field = null) {
|
|
759
769
|
if (rect.width <= 0 || rect.height <= 0) return;
|
|
760
770
|
const w = rect.width;
|
|
761
|
-
const tx0 = Math.floor(rect.x /
|
|
762
|
-
const ty0 = Math.floor(rect.y /
|
|
763
|
-
const tx1 = Math.floor((rect.x + rect.width - 1) /
|
|
764
|
-
const ty1 = Math.floor((rect.y + rect.height - 1) /
|
|
771
|
+
const tx0 = Math.floor(rect.x / _chunkO7LUD7MHcjs.TILE);
|
|
772
|
+
const ty0 = Math.floor(rect.y / _chunkO7LUD7MHcjs.TILE);
|
|
773
|
+
const tx1 = Math.floor((rect.x + rect.width - 1) / _chunkO7LUD7MHcjs.TILE);
|
|
774
|
+
const ty1 = Math.floor((rect.y + rect.height - 1) / _chunkO7LUD7MHcjs.TILE);
|
|
765
775
|
let touched = false;
|
|
766
776
|
for (let ty = ty0; ty <= ty1; ty++) {
|
|
767
777
|
for (let tx = tx0; tx <= tx1; tx++) {
|
|
768
|
-
const x0 = Math.max(rect.x, tx *
|
|
769
|
-
const y0 = Math.max(rect.y, ty *
|
|
770
|
-
const x1 = Math.min(rect.x + rect.width, tx *
|
|
771
|
-
const y1 = Math.min(rect.y + rect.height, ty *
|
|
778
|
+
const x0 = Math.max(rect.x, tx * _chunkO7LUD7MHcjs.TILE);
|
|
779
|
+
const y0 = Math.max(rect.y, ty * _chunkO7LUD7MHcjs.TILE);
|
|
780
|
+
const x1 = Math.min(rect.x + rect.width, tx * _chunkO7LUD7MHcjs.TILE + _chunkO7LUD7MHcjs.TILE);
|
|
781
|
+
const y1 = Math.min(rect.y + rect.height, ty * _chunkO7LUD7MHcjs.TILE + _chunkO7LUD7MHcjs.TILE);
|
|
772
782
|
let tile;
|
|
773
783
|
for (let y = y0; y < y1; y++) {
|
|
774
784
|
const row = (y - rect.y) * w;
|
|
775
|
-
const trow = (y - ty *
|
|
785
|
+
const trow = (y - ty * _chunkO7LUD7MHcjs.TILE) * _chunkO7LUD7MHcjs.TILE;
|
|
776
786
|
for (let x = x0; x < x1; x++) {
|
|
777
787
|
const v = vals[row + (x - rect.x)];
|
|
778
788
|
if (v <= 0) continue;
|
|
779
789
|
if (!tile) {
|
|
780
|
-
const key =
|
|
790
|
+
const key = _chunkO7LUD7MHcjs.tileKey.call(void 0, tx, ty);
|
|
781
791
|
tile = this.tiles.get(key);
|
|
782
792
|
if (!tile) {
|
|
783
793
|
tile = new Float32Array(TILE_PIXELS);
|
|
@@ -786,13 +796,13 @@ var CoverageMap = (_class2 = class {constructor() { _class2.prototype.__init11.c
|
|
|
786
796
|
this.dirty.add(key);
|
|
787
797
|
touched = true;
|
|
788
798
|
}
|
|
789
|
-
const ti = trow + (x - tx *
|
|
799
|
+
const ti = trow + (x - tx * _chunkO7LUD7MHcjs.TILE);
|
|
790
800
|
const c = tile[ti];
|
|
791
801
|
if (ceil > c) {
|
|
792
802
|
const next = c + v * (ceil - c);
|
|
793
803
|
tile[ti] = next;
|
|
794
804
|
if (color || field) {
|
|
795
|
-
const key =
|
|
805
|
+
const key = _chunkO7LUD7MHcjs.tileKey.call(void 0, tx, ty);
|
|
796
806
|
let ct = this.colors.get(key);
|
|
797
807
|
if (!ct) {
|
|
798
808
|
ct = new Float32Array(TILE_PIXELS * 3);
|
|
@@ -917,29 +927,29 @@ function gradientDabColor(sampler, tipTable, d, params, rect, vals, scratch) {
|
|
|
917
927
|
}
|
|
918
928
|
function applyStrokeToTile(coverage, tileData, channels, tx, ty, s, options = {}) {
|
|
919
929
|
const out = options.into ? new Uint8ClampedArray(options.into) : new Uint8ClampedArray(tileData);
|
|
920
|
-
const ox = tx *
|
|
921
|
-
const oy = ty *
|
|
930
|
+
const ox = tx * _chunkO7LUD7MHcjs.TILE + s.offset.x;
|
|
931
|
+
const oy = ty * _chunkO7LUD7MHcjs.TILE + s.offset.y;
|
|
922
932
|
let x0 = 0;
|
|
923
933
|
let y0 = 0;
|
|
924
|
-
let x1 =
|
|
925
|
-
let y1 =
|
|
934
|
+
let x1 = _chunkO7LUD7MHcjs.TILE;
|
|
935
|
+
let y1 = _chunkO7LUD7MHcjs.TILE;
|
|
926
936
|
if (options.region) {
|
|
927
937
|
const r = options.region;
|
|
928
938
|
x0 = Math.max(0, Math.floor(r.x) - ox);
|
|
929
939
|
y0 = Math.max(0, Math.floor(r.y) - oy);
|
|
930
|
-
x1 = Math.min(
|
|
931
|
-
y1 = Math.min(
|
|
940
|
+
x1 = Math.min(_chunkO7LUD7MHcjs.TILE, Math.ceil(r.x + r.width) - ox);
|
|
941
|
+
y1 = Math.min(_chunkO7LUD7MHcjs.TILE, Math.ceil(r.y + r.height) - oy);
|
|
932
942
|
if (x1 <= x0 || y1 <= y0) return out;
|
|
933
943
|
if (options.into) {
|
|
934
|
-
for (let y = y0; y < y1; y++) out.set(tileData.subarray((y *
|
|
944
|
+
for (let y = y0; y < y1; y++) out.set(tileData.subarray((y * _chunkO7LUD7MHcjs.TILE + x0) * channels, (y * _chunkO7LUD7MHcjs.TILE + x1) * channels), (y * _chunkO7LUD7MHcjs.TILE + x0) * channels);
|
|
935
945
|
}
|
|
936
946
|
}
|
|
937
947
|
const sel = s.selection;
|
|
938
948
|
const cb = [0, 0, 0, 0];
|
|
939
949
|
const cs = [s.color[0] / 255, s.color[1] / 255, s.color[2] / 255, s.color[3] / 255];
|
|
940
950
|
const bg = [s.background[0] / 255, s.background[1] / 255, s.background[2] / 255, s.background[3] / 255];
|
|
941
|
-
const aligned = s.offset.x %
|
|
942
|
-
const covTile = aligned ? coverage.tiles.get(
|
|
951
|
+
const aligned = s.offset.x % _chunkO7LUD7MHcjs.TILE === 0 && s.offset.y % _chunkO7LUD7MHcjs.TILE === 0;
|
|
952
|
+
const covTile = aligned ? coverage.tiles.get(_chunkO7LUD7MHcjs.tileKey.call(void 0, Math.floor(ox / _chunkO7LUD7MHcjs.TILE), Math.floor(oy / _chunkO7LUD7MHcjs.TILE))) : void 0;
|
|
943
953
|
if (aligned && !covTile) return out;
|
|
944
954
|
const colored = s.mode === "paint" && coverage.colors.size > 0;
|
|
945
955
|
const own = [0, 0, 0, cs[3]];
|
|
@@ -948,7 +958,7 @@ function applyStrokeToTile(coverage, tileData, channels, tx, ty, s, options = {}
|
|
|
948
958
|
const dy = oy + y;
|
|
949
959
|
for (let x = x0; x < x1; x++) {
|
|
950
960
|
const dx = ox + x;
|
|
951
|
-
const c = covTile ? covTile[y *
|
|
961
|
+
const c = covTile ? covTile[y * _chunkO7LUD7MHcjs.TILE + x] : coverage.get(dx, dy);
|
|
952
962
|
if (c <= 0) continue;
|
|
953
963
|
const pixelColor = colored ? coverage.colorAt(dx, dy, own) : null;
|
|
954
964
|
if (pixelColor) for (let ch = 0; ch < 3; ch++) ownBytes[ch] = Math.round(Math.min(1, Math.max(0, own[ch])) * 255);
|
|
@@ -959,7 +969,7 @@ function applyStrokeToTile(coverage, tileData, channels, tx, ty, s, options = {}
|
|
|
959
969
|
}
|
|
960
970
|
if (k > 1) k = 1;
|
|
961
971
|
if (k <= 0) continue;
|
|
962
|
-
const p = y *
|
|
972
|
+
const p = y * _chunkO7LUD7MHcjs.TILE + x;
|
|
963
973
|
if (channels === 1) {
|
|
964
974
|
const target = s.mode === "erase" ? s.background[0] : pixelColor ? Math.round(0.299 * ownBytes[0] + 0.587 * ownBytes[1] + 0.114 * ownBytes[2]) : s.color[0];
|
|
965
975
|
out[p] = Math.round(out[p] + (target - out[p]) * k);
|
|
@@ -977,7 +987,7 @@ function applyStrokeToTile(coverage, tileData, channels, tx, ty, s, options = {}
|
|
|
977
987
|
const as = src[3] * k;
|
|
978
988
|
if (!(as > 0)) continue;
|
|
979
989
|
const ao = as + out[i + 3] / 255 * (1 - as);
|
|
980
|
-
|
|
990
|
+
_chunkO7LUD7MHcjs.mixPigment8.call(void 0, out[i], out[i + 1], out[i + 2], bytes[0], bytes[1], bytes[2], as / ao, cb);
|
|
981
991
|
out[i] = Math.round(cb[0] * 255);
|
|
982
992
|
out[i + 1] = Math.round(cb[1] * 255);
|
|
983
993
|
out[i + 2] = Math.round(cb[2] * 255);
|
|
@@ -985,7 +995,7 @@ function applyStrokeToTile(coverage, tileData, channels, tx, ty, s, options = {}
|
|
|
985
995
|
continue;
|
|
986
996
|
}
|
|
987
997
|
for (let ch = 0; ch < 4; ch++) cb[ch] = out[i + ch] / 255;
|
|
988
|
-
const o =
|
|
998
|
+
const o = _chunkO7LUD7MHcjs.blendPixel.call(void 0, s.blend, cb, src, k);
|
|
989
999
|
out[i] = Math.round(o[0] * 255);
|
|
990
1000
|
out[i + 1] = Math.round(o[1] * 255);
|
|
991
1001
|
out[i + 2] = Math.round(o[2] * 255);
|
|
@@ -999,25 +1009,25 @@ function applyStrokeToDeepTile(coverage, samples, tx, ty, s, options = {}) {
|
|
|
999
1009
|
const scale = linear ? 1 : 65535;
|
|
1000
1010
|
const n = _nullishCoalesce(options.channels, () => ( 4));
|
|
1001
1011
|
const out = (_nullishCoalesce(options.into, () => ( samples))).slice();
|
|
1002
|
-
const ox = tx *
|
|
1003
|
-
const oy = ty *
|
|
1012
|
+
const ox = tx * _chunkO7LUD7MHcjs.TILE + s.offset.x;
|
|
1013
|
+
const oy = ty * _chunkO7LUD7MHcjs.TILE + s.offset.y;
|
|
1004
1014
|
let x0 = 0;
|
|
1005
1015
|
let y0 = 0;
|
|
1006
|
-
let x1 =
|
|
1007
|
-
let y1 =
|
|
1016
|
+
let x1 = _chunkO7LUD7MHcjs.TILE;
|
|
1017
|
+
let y1 = _chunkO7LUD7MHcjs.TILE;
|
|
1008
1018
|
if (options.region) {
|
|
1009
1019
|
const r = options.region;
|
|
1010
1020
|
x0 = Math.max(0, Math.floor(r.x) - ox);
|
|
1011
1021
|
y0 = Math.max(0, Math.floor(r.y) - oy);
|
|
1012
|
-
x1 = Math.min(
|
|
1013
|
-
y1 = Math.min(
|
|
1022
|
+
x1 = Math.min(_chunkO7LUD7MHcjs.TILE, Math.ceil(r.x + r.width) - ox);
|
|
1023
|
+
y1 = Math.min(_chunkO7LUD7MHcjs.TILE, Math.ceil(r.y + r.height) - oy);
|
|
1014
1024
|
if (x1 <= x0 || y1 <= y0) return out;
|
|
1015
|
-
if (options.into) for (let y = y0; y < y1; y++) out.set(samples.subarray((y *
|
|
1025
|
+
if (options.into) for (let y = y0; y < y1; y++) out.set(samples.subarray((y * _chunkO7LUD7MHcjs.TILE + x0) * n, (y * _chunkO7LUD7MHcjs.TILE + x1) * n), (y * _chunkO7LUD7MHcjs.TILE + x0) * n);
|
|
1016
1026
|
}
|
|
1017
1027
|
const grey = (s.mode === "erase" ? s.background[0] : s.color[0]) / 255 * scale;
|
|
1018
1028
|
const colour = (c) => {
|
|
1019
1029
|
const v = [c[0] / 255, c[1] / 255, c[2] / 255, c[3] / 255];
|
|
1020
|
-
if (linear) for (let k = 0; k < 3; k++) v[k] =
|
|
1030
|
+
if (linear) for (let k = 0; k < 3; k++) v[k] = _chunkO7LUD7MHcjs.srgbDecode.call(void 0, v[k]);
|
|
1021
1031
|
return v;
|
|
1022
1032
|
};
|
|
1023
1033
|
const src0 = colour(s.mode === "erase" ? s.background : s.color);
|
|
@@ -1029,7 +1039,7 @@ function applyStrokeToDeepTile(coverage, samples, tx, ty, s, options = {}) {
|
|
|
1029
1039
|
const cb = [0, 0, 0, 0];
|
|
1030
1040
|
const mix = [0, 0, 0];
|
|
1031
1041
|
const encCb = [0, 0, 0];
|
|
1032
|
-
const encSrc0 = linear ? [
|
|
1042
|
+
const encSrc0 = linear ? [_chunkO7LUD7MHcjs.srgbEncode.call(void 0, src0[0]), _chunkO7LUD7MHcjs.srgbEncode.call(void 0, src0[1]), _chunkO7LUD7MHcjs.srgbEncode.call(void 0, src0[2])] : src0;
|
|
1033
1043
|
const put = (i, v) => {
|
|
1034
1044
|
out[i] = linear ? v : v <= 0 ? 0 : v >= 1 ? 65535 : Math.round(v * 65535);
|
|
1035
1045
|
};
|
|
@@ -1049,17 +1059,17 @@ function applyStrokeToDeepTile(coverage, samples, tx, ty, s, options = {}) {
|
|
|
1049
1059
|
if (k <= 0) continue;
|
|
1050
1060
|
src = src0;
|
|
1051
1061
|
if (pixelColor) {
|
|
1052
|
-
for (let ch = 0; ch < 3; ch++) ownSrc[ch] = linear ?
|
|
1062
|
+
for (let ch = 0; ch < 3; ch++) ownSrc[ch] = linear ? _chunkO7LUD7MHcjs.srgbDecode.call(void 0, own[ch]) : own[ch];
|
|
1053
1063
|
src = ownSrc;
|
|
1054
1064
|
}
|
|
1055
1065
|
if (n === 1) {
|
|
1056
|
-
const p = y *
|
|
1066
|
+
const p = y * _chunkO7LUD7MHcjs.TILE + x;
|
|
1057
1067
|
const g = pixelColor ? (0.299 * own[0] + 0.587 * own[1] + 0.114 * own[2]) * scale : grey;
|
|
1058
1068
|
const v = out[p] + (g - out[p]) * k;
|
|
1059
1069
|
out[p] = linear ? v : Math.round(v);
|
|
1060
1070
|
continue;
|
|
1061
1071
|
}
|
|
1062
|
-
const i = (y *
|
|
1072
|
+
const i = (y * _chunkO7LUD7MHcjs.TILE + x) * 4;
|
|
1063
1073
|
if (s.mode === "erase" && !s.lockTransparency) {
|
|
1064
1074
|
put(i + 3, out[i + 3] / scale * (1 - k));
|
|
1065
1075
|
if (out[i + 3] === 0) out[i] = out[i + 1] = out[i + 2] = 0;
|
|
@@ -1071,13 +1081,13 @@ function applyStrokeToDeepTile(coverage, samples, tx, ty, s, options = {}) {
|
|
|
1071
1081
|
const as = src[3] * k;
|
|
1072
1082
|
if (!(as > 0)) continue;
|
|
1073
1083
|
const ao = as + cb[3] * (1 - as);
|
|
1074
|
-
for (let ch = 0; ch < 3; ch++) encCb[ch] = linear ?
|
|
1075
|
-
|
|
1076
|
-
for (let ch = 0; ch < 3; ch++) put(i + ch, linear ?
|
|
1084
|
+
for (let ch = 0; ch < 3; ch++) encCb[ch] = linear ? _chunkO7LUD7MHcjs.srgbEncode.call(void 0, cb[ch]) : cb[ch];
|
|
1085
|
+
_chunkO7LUD7MHcjs.mixPigmentRgb.call(void 0, encCb, pixelColor ? own : encSrc0, as / ao, mix);
|
|
1086
|
+
for (let ch = 0; ch < 3; ch++) put(i + ch, linear ? _chunkO7LUD7MHcjs.srgbDecode.call(void 0, mix[ch]) : mix[ch]);
|
|
1077
1087
|
if (!s.lockTransparency) put(i + 3, ao);
|
|
1078
1088
|
continue;
|
|
1079
1089
|
}
|
|
1080
|
-
const o =
|
|
1090
|
+
const o = _chunkO7LUD7MHcjs.blendPixel.call(void 0, s.blend, cb, src, k);
|
|
1081
1091
|
put(i, o[0]);
|
|
1082
1092
|
put(i + 1, o[1]);
|
|
1083
1093
|
put(i + 2, o[2]);
|
|
@@ -1087,9 +1097,305 @@ function applyStrokeToDeepTile(coverage, samples, tx, ty, s, options = {}) {
|
|
|
1087
1097
|
return out;
|
|
1088
1098
|
}
|
|
1089
1099
|
function coverageTileCoord(key) {
|
|
1090
|
-
return
|
|
1100
|
+
return _chunkO7LUD7MHcjs.tileCoord.call(void 0, key);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
// src/paint/path-stroke.ts
|
|
1104
|
+
function lean(s) {
|
|
1105
|
+
if (typeof s.altitude === "number" && Number.isFinite(s.altitude)) {
|
|
1106
|
+
return { amount: 1 - Math.min(1, Math.max(0, s.altitude / (Math.PI / 2))), azimuth: _nullishCoalesce(s.azimuth, () => ( 0)) };
|
|
1107
|
+
}
|
|
1108
|
+
if (typeof s.tiltX === "number" || typeof s.tiltY === "number") {
|
|
1109
|
+
const tx = (_nullishCoalesce(s.tiltX, () => ( 0))) * Math.PI / 180;
|
|
1110
|
+
const ty = (_nullishCoalesce(s.tiltY, () => ( 0))) * Math.PI / 180;
|
|
1111
|
+
if (tx === 0 && ty === 0) return { amount: 0, azimuth: 0 };
|
|
1112
|
+
const az = Math.atan2(Math.tan(ty), Math.tan(tx));
|
|
1113
|
+
const alt = Math.atan(1 / Math.hypot(Math.tan(tx), Math.tan(ty)));
|
|
1114
|
+
return { amount: 1 - alt / (Math.PI / 2), azimuth: az };
|
|
1115
|
+
}
|
|
1116
|
+
return null;
|
|
1117
|
+
}
|
|
1118
|
+
function pathStrokeDabs(samples, options) {
|
|
1119
|
+
const brush = normalizeBrush(options.brush);
|
|
1120
|
+
const pts = options.closed && samples.length > 2 ? [...samples, samples[0]] : [...samples];
|
|
1121
|
+
if (!pts.length) return [];
|
|
1122
|
+
const tilt = _nullishCoalesce(options.tilt, () => ( {}));
|
|
1123
|
+
const minSize = Math.min(1, Math.max(0, _nullishCoalesce(options.minSize, () => ( 0))));
|
|
1124
|
+
let index = 0;
|
|
1125
|
+
const t0 = _nullishCoalesce(_optionalChain([pts, 'access', _5 => _5.find, 'call', _6 => _6((s) => typeof s.t === "number" && Number.isFinite(s.t)), 'optionalAccess', _7 => _7.t]), () => ( null));
|
|
1126
|
+
const dab = (x, y, p, l, dir, travel = 0, time = null, speed = null) => {
|
|
1127
|
+
const pr = Math.min(1, Math.max(0, p));
|
|
1128
|
+
const lean0 = _nullishCoalesce(_optionalChain([l, 'optionalAccess', _8 => _8.amount]), () => ( 0));
|
|
1129
|
+
const size = brush.size * (brush.pressureSize ? minSize + (1 - minSize) * pr : 1) * (1 + 1.5 * (_nullishCoalesce(tilt.size, () => ( 0))) * lean0);
|
|
1130
|
+
let angle = brush.angle * Math.PI / 180;
|
|
1131
|
+
if (options.followPath) angle += dir;
|
|
1132
|
+
if (tilt.followAzimuth && l) angle = -l.azimuth;
|
|
1133
|
+
const roundness = Math.max(0.05, brush.roundness * (1 - 0.85 * (_nullishCoalesce(tilt.roundness, () => ( 0))) * lean0));
|
|
1134
|
+
const op = brush.pressureOpacity ? pr : 1;
|
|
1135
|
+
const params = { travel, index: index++, pressure: pr, lean: lean0, speed, direction: dir, time: time === null || t0 === null ? null : time - t0 };
|
|
1136
|
+
return { x, y, radius: Math.max(0.5, size / 2), alpha: brush.flow, opacity: brush.opacity * op, angle, roundness, params };
|
|
1137
|
+
};
|
|
1138
|
+
const out = [];
|
|
1139
|
+
const pressure = (s) => typeof s.pressure === "number" && Number.isFinite(s.pressure) ? s.pressure : 1;
|
|
1140
|
+
if (pts.length === 1) {
|
|
1141
|
+
out.push(dab(pts[0].x, pts[0].y, pressure(pts[0]), lean(pts[0]), 0));
|
|
1142
|
+
return out;
|
|
1143
|
+
}
|
|
1144
|
+
let carry = 0;
|
|
1145
|
+
let along = 0;
|
|
1146
|
+
const timeOf = (s) => typeof s.t === "number" && Number.isFinite(s.t) ? s.t : null;
|
|
1147
|
+
out.push(dab(pts[0].x, pts[0].y, pressure(pts[0]), lean(pts[0]), Math.atan2(-(pts[1].y - pts[0].y), pts[1].x - pts[0].x), 0, timeOf(pts[0])));
|
|
1148
|
+
for (let i = 0; i + 1 < pts.length; i++) {
|
|
1149
|
+
const a = pts[i];
|
|
1150
|
+
const b = pts[i + 1];
|
|
1151
|
+
const dx = b.x - a.x;
|
|
1152
|
+
const dy = b.y - a.y;
|
|
1153
|
+
const len = Math.hypot(dx, dy);
|
|
1154
|
+
if (len === 0) continue;
|
|
1155
|
+
const dir = Math.atan2(-dy, dx);
|
|
1156
|
+
const la = lean(a);
|
|
1157
|
+
const lb = lean(b);
|
|
1158
|
+
const ta = timeOf(a);
|
|
1159
|
+
const tb = timeOf(b);
|
|
1160
|
+
const speed = ta !== null && tb !== null && tb > ta ? len / (tb - ta) : null;
|
|
1161
|
+
let t = carry;
|
|
1162
|
+
for (; ; ) {
|
|
1163
|
+
const f = t / len;
|
|
1164
|
+
if (f > 1) break;
|
|
1165
|
+
const p = pressure(a) + (pressure(b) - pressure(a)) * f;
|
|
1166
|
+
const l = la && lb ? { amount: la.amount + (lb.amount - la.amount) * f, azimuth: la.azimuth + (lb.azimuth - la.azimuth) * f } : _nullishCoalesce(la, () => ( lb));
|
|
1167
|
+
const size = brush.size * (brush.pressureSize ? minSize + (1 - minSize) * p : 1);
|
|
1168
|
+
const step = Math.max(0.5, size * brush.spacing);
|
|
1169
|
+
if (t > 0 || i > 0) out.push(dab(a.x + dx * f, a.y + dy * f, p, l, dir, along + t, ta !== null && tb !== null ? ta + (tb - ta) * f : null, speed));
|
|
1170
|
+
t += step;
|
|
1171
|
+
}
|
|
1172
|
+
carry = t - len;
|
|
1173
|
+
along += len;
|
|
1174
|
+
}
|
|
1175
|
+
return out;
|
|
1176
|
+
}
|
|
1177
|
+
function pathStrokeCoverage(samples, options) {
|
|
1178
|
+
const brush = normalizeBrush(options.brush);
|
|
1179
|
+
const coverage = new CoverageMap();
|
|
1180
|
+
const dabs = pathStrokeDabs(samples, options);
|
|
1181
|
+
const g = _optionalChain([options, 'access', _9 => _9.gradient, 'optionalAccess', _10 => _10.paint, 'access', _11 => _11.type]) === "gradient" ? options.gradient : null;
|
|
1182
|
+
const sampler = g ? new PaintGradientSampler(resolvePaintGradient(g.paint, _nullishCoalesce(g.colors, () => ( { paint: "#000000", secondary: "#ffffff" }))), _nullishCoalesce(g.seed, () => ( 0))) : null;
|
|
1183
|
+
const tipTable = _optionalChain([sampler, 'optionalAccess', _12 => _12.acrossTip]) ? sampler.tipTable(TIP_GRADIENT_STEPS) : null;
|
|
1184
|
+
const scratch = { field: new Float32Array(0), sample: { rgb: [0, 0, 0], alpha: 1 } };
|
|
1185
|
+
let buf = new Float32Array(0);
|
|
1186
|
+
let bounds = null;
|
|
1187
|
+
for (const d of dabs) {
|
|
1188
|
+
const rect = dabRect(d, brush.hardness);
|
|
1189
|
+
const n = rect.width * rect.height;
|
|
1190
|
+
if (n <= 0) continue;
|
|
1191
|
+
if (buf.length < n) buf = new Float32Array(n);
|
|
1192
|
+
const vals = buf.subarray(0, n);
|
|
1193
|
+
rasterizeDab(d, brush.hardness, rect, vals);
|
|
1194
|
+
if (sampler) {
|
|
1195
|
+
const { color, field } = gradientDabColor(sampler, tipTable, d, d.params, rect, vals, scratch);
|
|
1196
|
+
coverage.accumulate(rect, vals, d.opacity, color, field);
|
|
1197
|
+
} else coverage.accumulate(rect, vals, d.opacity);
|
|
1198
|
+
if (!bounds) bounds = { ...rect };
|
|
1199
|
+
else {
|
|
1200
|
+
const x = Math.min(bounds.x, rect.x);
|
|
1201
|
+
const y = Math.min(bounds.y, rect.y);
|
|
1202
|
+
bounds = { x, y, width: Math.max(bounds.x + bounds.width, rect.x + rect.width) - x, height: Math.max(bounds.y + bounds.height, rect.y + rect.height) - y };
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
return { coverage, bounds, dabs: dabs.length };
|
|
1206
|
+
}
|
|
1207
|
+
function paintPathStroke(surface, samples, options) {
|
|
1208
|
+
if (surface.channels !== 4) throw new Error("paintPathStroke paints RGBA surfaces (4 channels).");
|
|
1209
|
+
const brush = normalizeBrush(options.brush);
|
|
1210
|
+
const hex = (c) => "#" + [0, 1, 2].map((i) => Math.round(Math.min(255, Math.max(0, c[i]))).toString(16).padStart(2, "0")).join("");
|
|
1211
|
+
let color = options.color;
|
|
1212
|
+
if (_optionalChain([options, 'access', _13 => _13.paint, 'optionalAccess', _14 => _14.paint, 'access', _15 => _15.type]) === "color") {
|
|
1213
|
+
const rgb = hexToPaintRgb(options.paint.paint.color).map((v) => Math.round(v * 255));
|
|
1214
|
+
color = [rgb[0], rgb[1], rgb[2], color[3]];
|
|
1215
|
+
}
|
|
1216
|
+
const gradient = _optionalChain([options, 'access', _16 => _16.paint, 'optionalAccess', _17 => _17.paint, 'access', _18 => _18.type]) === "gradient" ? { ...options.paint, colors: _nullishCoalesce(options.paint.colors, () => ( { paint: hex(color), secondary: "#ffffff" })) } : null;
|
|
1217
|
+
const { coverage, bounds, dabs } = pathStrokeCoverage(samples, { ...options, gradient });
|
|
1218
|
+
if (!bounds) return { surface, bounds: null, dabs };
|
|
1219
|
+
const offset = _nullishCoalesce(options.offset, () => ( { x: 0, y: 0 }));
|
|
1220
|
+
const apply = {
|
|
1221
|
+
mode: _nullishCoalesce(options.mode, () => ( "paint")),
|
|
1222
|
+
color,
|
|
1223
|
+
background: [0, 0, 0, 0],
|
|
1224
|
+
opacity: brush.opacity,
|
|
1225
|
+
blend: _nullishCoalesce(options.blend, () => ( brush.blend)),
|
|
1226
|
+
lockTransparency: _nullishCoalesce(options.lockTransparency, () => ( false)),
|
|
1227
|
+
selection: _nullishCoalesce(options.selection, () => ( null)),
|
|
1228
|
+
offset
|
|
1229
|
+
};
|
|
1230
|
+
const tiles = new Map(surface.tiles);
|
|
1231
|
+
for (const { tx, ty } of _chunkO7LUD7MHcjs.tilesInRect.call(void 0, { x: bounds.x - offset.x, y: bounds.y - offset.y, width: bounds.width, height: bounds.height })) {
|
|
1232
|
+
const key = _chunkO7LUD7MHcjs.tileKey.call(void 0, tx, ty);
|
|
1233
|
+
const src = _optionalChain([surface, 'access', _19 => _19.tiles, 'access', _20 => _20.get, 'call', _21 => _21(key), 'optionalAccess', _22 => _22.data]);
|
|
1234
|
+
const base = src && src.length === _chunkO7LUD7MHcjs.TILE * _chunkO7LUD7MHcjs.TILE * 4 ? src : new Uint8ClampedArray(_chunkO7LUD7MHcjs.TILE * _chunkO7LUD7MHcjs.TILE * 4);
|
|
1235
|
+
const t = _chunkO7LUD7MHcjs.finishTile.call(void 0, applyStrokeToTile(coverage, base, 4, tx, ty, apply), 4, surface.defaultValue);
|
|
1236
|
+
if (t) tiles.set(key, t);
|
|
1237
|
+
else tiles.delete(key);
|
|
1238
|
+
}
|
|
1239
|
+
return { surface: new (0, _chunkO7LUD7MHcjs.TiledSurface)(4, tiles, surface.defaultValue), bounds, dabs };
|
|
1091
1240
|
}
|
|
1092
1241
|
|
|
1242
|
+
// src/paint/brushstroke.ts
|
|
1243
|
+
var DEFAULT_MAX_PIXELS = 4096 * 4096;
|
|
1244
|
+
var isProfilePath = (input) => !Array.isArray(input) && typeof input === "object" && input !== null && "points" in input;
|
|
1245
|
+
function profileAt(profile, f) {
|
|
1246
|
+
if (!profile || !profile.length) return void 0;
|
|
1247
|
+
if (profile.length === 1) return profile[0];
|
|
1248
|
+
const u = Math.min(1, Math.max(0, f)) * (profile.length - 1);
|
|
1249
|
+
const i = Math.min(profile.length - 2, Math.floor(u));
|
|
1250
|
+
return profile[i] + (profile[i + 1] - profile[i]) * (u - i);
|
|
1251
|
+
}
|
|
1252
|
+
function brushstrokeSamples(input) {
|
|
1253
|
+
if (!isProfilePath(input)) return input.map((s) => ({ ...s }));
|
|
1254
|
+
const pts = input.points;
|
|
1255
|
+
const lengths = [0];
|
|
1256
|
+
for (let i = 1; i < pts.length; i++) lengths.push(lengths[i - 1] + Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y));
|
|
1257
|
+
const total = _nullishCoalesce(lengths.at(-1), () => ( 0));
|
|
1258
|
+
return pts.map((p, i) => {
|
|
1259
|
+
const f = total > 0 ? lengths[i] / total : pts.length > 1 ? i / (pts.length - 1) : 0;
|
|
1260
|
+
const s = { x: p.x, y: p.y };
|
|
1261
|
+
const pressure = profileAt(input.pressure, f);
|
|
1262
|
+
const tiltX = profileAt(input.tiltX, f);
|
|
1263
|
+
const tiltY = profileAt(input.tiltY, f);
|
|
1264
|
+
if (pressure !== void 0) s.pressure = pressure;
|
|
1265
|
+
if (tiltX !== void 0) s.tiltX = tiltX;
|
|
1266
|
+
if (tiltY !== void 0) s.tiltY = tiltY;
|
|
1267
|
+
return s;
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
var REFUSED_ENGINES = {
|
|
1271
|
+
wet: "is a wet brush, and wet paint needs an area to flow in (paint it on a wet layer in the paint editor)",
|
|
1272
|
+
mixer: "is a Mixer Brush, which picks up paint from under the tip and has none on a standalone stroke",
|
|
1273
|
+
blender: "is a blender, which only moves paint that is already there",
|
|
1274
|
+
smudge: "is a smudge brush, which only moves paint that is already there",
|
|
1275
|
+
eraser: "is an eraser, which has nothing to remove on a standalone stroke"
|
|
1276
|
+
};
|
|
1277
|
+
function brushstrokeStrokeOptions(brush) {
|
|
1278
|
+
if (!brush || typeof brush !== "object") throw new Error("A brushstroke needs a brush: tip settings ({ size, hardness, \u2026 }) or a paint brush preset.");
|
|
1279
|
+
if (!("tip" in brush) || !brush.tip) return { brush: normalizeBrush(brush) };
|
|
1280
|
+
const engine = _nullishCoalesce(brush.engine, () => ( "dab"));
|
|
1281
|
+
if (engine !== "dab") {
|
|
1282
|
+
const label = _nullishCoalesce(_nullishCoalesce(brush.name, () => ( brush.id)), () => ( "This brush"));
|
|
1283
|
+
const why = _nullishCoalesce(REFUSED_ENGINES[engine], () => ( `uses the '${engine}' engine, which renderBrushstroke does not draw`));
|
|
1284
|
+
throw new Error(`Brushstrokes render dry media only: '${label}' ${why}. Pick a dry brush (a dab-engine preset such as a pencil, pastel, charcoal, marker, ink or airbrush) or plain tip settings.`);
|
|
1285
|
+
}
|
|
1286
|
+
const d = _nullishCoalesce(brush.dynamics, () => ( {}));
|
|
1287
|
+
const tilt = { size: _nullishCoalesce(d.tiltSize, () => ( 0)), roundness: _nullishCoalesce(d.tiltRoundness, () => ( 0)) };
|
|
1288
|
+
return {
|
|
1289
|
+
brush: normalizeBrush(brush.tip),
|
|
1290
|
+
followPath: brush.rotation === "stroke",
|
|
1291
|
+
minSize: _nullishCoalesce(d.minSize, () => ( 0)),
|
|
1292
|
+
...tilt.size || tilt.roundness ? { tilt } : {}
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
function isBrushstrokeBrush(brush) {
|
|
1296
|
+
return !("tip" in brush) || !brush.tip || (_nullishCoalesce(brush.engine, () => ( "dab"))) === "dab";
|
|
1297
|
+
}
|
|
1298
|
+
var finite2 = (v) => typeof v === "number" && Number.isFinite(v);
|
|
1299
|
+
function renderBrushstroke(input, brush, options = {}) {
|
|
1300
|
+
const strokeOptions = brushstrokeStrokeOptions(brush);
|
|
1301
|
+
const samples = brushstrokeSamples(input);
|
|
1302
|
+
for (const s of samples) if (!finite2(s.x) || !finite2(s.y)) throw new Error("Brushstroke samples need finite x and y.");
|
|
1303
|
+
const solid = options.paint && !("type" in options.paint) ? options.paint.color : null;
|
|
1304
|
+
const source = options.paint && "type" in options.paint ? options.paint : null;
|
|
1305
|
+
const color = _nullishCoalesce(_nullishCoalesce(solid, () => ( options.color)), () => ( [0, 0, 0, 255]));
|
|
1306
|
+
let scale = finite2(options.scale) && options.scale > 0 ? Math.min(_chunkSYPFUL5Bcjs.BRUSHSTROKE_MAX_SCALE, Math.max(_chunkSYPFUL5Bcjs.BRUSHSTROKE_MIN_SCALE, options.scale)) : 1;
|
|
1307
|
+
if (!samples.length) return { image: { width: 0, height: 0, data: new Uint8ClampedArray(0) }, bounds: null, scale, dabs: 0 };
|
|
1308
|
+
const tip = strokeOptions.brush;
|
|
1309
|
+
const reach = tip.size * (1 + 1.5 * (_nullishCoalesce(_optionalChain([strokeOptions, 'access', _23 => _23.tilt, 'optionalAccess', _24 => _24.size]), () => ( 0)))) + 4;
|
|
1310
|
+
let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
1311
|
+
for (const s of samples) {
|
|
1312
|
+
x0 = Math.min(x0, s.x);
|
|
1313
|
+
y0 = Math.min(y0, s.y);
|
|
1314
|
+
x1 = Math.max(x1, s.x);
|
|
1315
|
+
y1 = Math.max(y1, s.y);
|
|
1316
|
+
}
|
|
1317
|
+
const maxPixels = finite2(options.maxPixels) && options.maxPixels > 0 ? options.maxPixels : DEFAULT_MAX_PIXELS;
|
|
1318
|
+
const area = (x1 - x0 + reach) * (y1 - y0 + reach);
|
|
1319
|
+
if (area * scale * scale > maxPixels) scale = Math.max(_chunkSYPFUL5Bcjs.BRUSHSTROKE_MIN_SCALE, Math.sqrt(maxPixels / area));
|
|
1320
|
+
const scaled = samples.map((s) => ({ ...s, x: s.x * scale, y: s.y * scale }));
|
|
1321
|
+
const { surface, bounds, dabs } = paintPathStroke(_chunkO7LUD7MHcjs.emptySurface.call(void 0, 4), scaled, {
|
|
1322
|
+
...strokeOptions,
|
|
1323
|
+
brush: { ...tip, size: tip.size * scale },
|
|
1324
|
+
closed: _nullishCoalesce(options.closed, () => ( strokeOptions.closed)),
|
|
1325
|
+
color,
|
|
1326
|
+
// Gradient lengths are in path units: scale them with the image.
|
|
1327
|
+
...source ? { paint: { paint: source.type === "gradient" ? scalePaintGradient(source, scale) : source, seed: _nullishCoalesce(options.seed, () => ( 0)) } } : {}
|
|
1328
|
+
});
|
|
1329
|
+
if (!bounds) return { image: { width: 0, height: 0, data: new Uint8ClampedArray(0) }, bounds: null, scale, dabs };
|
|
1330
|
+
const rect = bounds;
|
|
1331
|
+
const data = _chunkO7LUD7MHcjs.readRegion.call(void 0, surface, rect);
|
|
1332
|
+
return {
|
|
1333
|
+
image: { width: rect.width, height: rect.height, data },
|
|
1334
|
+
bounds: { x: rect.x / scale, y: rect.y / scale, width: rect.width / scale, height: rect.height / scale },
|
|
1335
|
+
scale,
|
|
1336
|
+
dabs
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
function brushstrokeDataUrl(stroke) {
|
|
1340
|
+
const { width, height, data } = stroke.image;
|
|
1341
|
+
return width && height ? _chunkO7LUD7MHcjs.pngDataUrl.call(void 0, width, height, data) : "";
|
|
1342
|
+
}
|
|
1343
|
+
function brushstrokeToCanvas(stroke, createCanvas) {
|
|
1344
|
+
const { width, height, data } = stroke.image;
|
|
1345
|
+
if (!width || !height) return null;
|
|
1346
|
+
const canvas = createCanvas(width, height);
|
|
1347
|
+
const ctx = canvas.getContext("2d");
|
|
1348
|
+
if (!ctx) return null;
|
|
1349
|
+
const img = ctx.createImageData(width, height);
|
|
1350
|
+
img.data.set(data);
|
|
1351
|
+
ctx.putImageData(img, 0, 0);
|
|
1352
|
+
return canvas;
|
|
1353
|
+
}
|
|
1354
|
+
function hashString(s, h = 2166136261) {
|
|
1355
|
+
for (let i = 0; i < s.length; i++) {
|
|
1356
|
+
h ^= s.charCodeAt(i);
|
|
1357
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
1358
|
+
}
|
|
1359
|
+
return h;
|
|
1360
|
+
}
|
|
1361
|
+
function brushstrokeKey(input, brush, options = {}) {
|
|
1362
|
+
const path = JSON.stringify(input);
|
|
1363
|
+
const { brush: tip, ...rest } = brushstrokeStrokeOptions(brush);
|
|
1364
|
+
const rest2 = JSON.stringify([tip, rest, _nullishCoalesce(_nullishCoalesce(options.paint, () => ( options.color)), () => ( null)), _nullishCoalesce(options.seed, () => ( 0)), _nullishCoalesce(options.closed, () => ( false)), _nullishCoalesce(options.maxPixels, () => ( null))]);
|
|
1365
|
+
const scale = finite2(options.scale) ? options.scale : 1;
|
|
1366
|
+
return `${hashString(path).toString(16)}:${path.length}:${hashString(rest2).toString(16)}:${scale}`;
|
|
1367
|
+
}
|
|
1368
|
+
var BrushstrokeCache = (_class4 = class {
|
|
1369
|
+
constructor(capacity = 64) {;_class4.prototype.__init21.call(this);_class4.prototype.__init22.call(this);
|
|
1370
|
+
this.capacity = capacity;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
__init21() {this.entries = /* @__PURE__ */ new Map()}
|
|
1374
|
+
/** Renders that missed the cache (for tests and stats). */
|
|
1375
|
+
__init22() {this.misses = 0}
|
|
1376
|
+
get size() {
|
|
1377
|
+
return this.entries.size;
|
|
1378
|
+
}
|
|
1379
|
+
/** The cached stroke for these arguments, rendering (and caching) it on a miss. */
|
|
1380
|
+
render(input, brush, options = {}) {
|
|
1381
|
+
const key = brushstrokeKey(input, brush, options);
|
|
1382
|
+
const hit = this.entries.get(key);
|
|
1383
|
+
if (hit) {
|
|
1384
|
+
this.entries.delete(key);
|
|
1385
|
+
this.entries.set(key, hit);
|
|
1386
|
+
return hit;
|
|
1387
|
+
}
|
|
1388
|
+
this.misses++;
|
|
1389
|
+
const out = renderBrushstroke(input, brush, options);
|
|
1390
|
+
this.entries.set(key, out);
|
|
1391
|
+
while (this.entries.size > Math.max(1, this.capacity)) this.entries.delete(this.entries.keys().next().value);
|
|
1392
|
+
return out;
|
|
1393
|
+
}
|
|
1394
|
+
clear() {
|
|
1395
|
+
this.entries.clear();
|
|
1396
|
+
}
|
|
1397
|
+
}, _class4);
|
|
1398
|
+
|
|
1093
1399
|
// src/paint/exchange.ts
|
|
1094
1400
|
var MIXING_MODELS = ["rgb", "pigment"];
|
|
1095
1401
|
var EMPTY_MIXER_LOAD = { reservoir: null, amount: 0, pickup: null };
|
|
@@ -1098,20 +1404,20 @@ var MIXER_DRAIN = 0.08;
|
|
|
1098
1404
|
function exchangeRates(pickup, mix, load, mixing) {
|
|
1099
1405
|
return { pickup: MIXER_PICKUP_RATE * pickup, mix: mix * pickup, drain: MIXER_DRAIN * (1 - load), mixing };
|
|
1100
1406
|
}
|
|
1101
|
-
var PaintExchange = (
|
|
1102
|
-
constructor(rates, load) {;
|
|
1407
|
+
var PaintExchange = (_class5 = class {
|
|
1408
|
+
constructor(rates, load) {;_class5.prototype.__init23.call(this);
|
|
1103
1409
|
this.rates = rates;
|
|
1104
1410
|
this.reservoir = load.reservoir ? [load.reservoir[0], load.reservoir[1], load.reservoir[2]] : null;
|
|
1105
1411
|
this.amount = this.reservoir ? Math.min(1, Math.max(0, load.amount)) : 0;
|
|
1106
1412
|
this.well = load.pickup ? [load.pickup[0], load.pickup[1], load.pickup[2]] : null;
|
|
1107
|
-
this.pig = rates.mixing === "pigment" ? { res:
|
|
1413
|
+
this.pig = rates.mixing === "pigment" ? { res: _chunkO7LUD7MHcjs.createPigment.call(void 0, _nullishCoalesce(this.reservoir, () => ( [0, 0, 0]))), well: _chunkO7LUD7MHcjs.createPigment.call(void 0, _nullishCoalesce(this.well, () => ( [0, 0, 0]))), paint: _chunkO7LUD7MHcjs.createPigment.call(void 0, [0, 0, 0]), canvas: _chunkO7LUD7MHcjs.createPigment.call(void 0, [0, 0, 0]) } : null;
|
|
1108
1414
|
}
|
|
1109
1415
|
|
|
1110
1416
|
|
|
1111
1417
|
|
|
1112
1418
|
|
|
1113
1419
|
|
|
1114
|
-
|
|
1420
|
+
__init23() {this.out = [0, 0, 0]}
|
|
1115
1421
|
/** What the brush carries now. */
|
|
1116
1422
|
get load() {
|
|
1117
1423
|
return { reservoir: this.reservoir ? [...this.reservoir] : null, amount: this.amount, pickup: this.well ? [...this.well] : null };
|
|
@@ -1122,7 +1428,7 @@ var PaintExchange = (_class4 = class {
|
|
|
1122
1428
|
}
|
|
1123
1429
|
/** The prepared pigment of the last `paint` colour (pigment mixing only), for `deposit`. */
|
|
1124
1430
|
get paintPigment() {
|
|
1125
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
1431
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _25 => _25.pig, 'optionalAccess', _26 => _26.paint]), () => ( null));
|
|
1126
1432
|
}
|
|
1127
1433
|
/** Recolours the reservoir without refilling it (a multi-coloured brush, per dab). */
|
|
1128
1434
|
setReservoirColor(r, g, b) {
|
|
@@ -1134,21 +1440,21 @@ var PaintExchange = (_class4 = class {
|
|
|
1134
1440
|
this.reservoir[1] = g;
|
|
1135
1441
|
this.reservoir[2] = b;
|
|
1136
1442
|
}
|
|
1137
|
-
if (this.pig)
|
|
1443
|
+
if (this.pig) _chunkO7LUD7MHcjs.setPigmentColor.call(void 0, this.pig.res, r, g, b);
|
|
1138
1444
|
}
|
|
1139
1445
|
/** `a` mixed `t` of the way to `b` into `this.out`, by the mixing model. */
|
|
1140
1446
|
mix(a, pa, b, pb, t) {
|
|
1141
1447
|
const o = this.out;
|
|
1142
|
-
if (pa && pb)
|
|
1448
|
+
if (pa && pb) _chunkO7LUD7MHcjs.lerpPigmentInto.call(void 0, pa, pb, t, o, 0);
|
|
1143
1449
|
else for (let c = 0; c < 3; c++) o[c] = a[c] + (b[c] - a[c]) * t;
|
|
1144
1450
|
return o;
|
|
1145
1451
|
}
|
|
1146
1452
|
/** `a` mixed `t` of the way to `b` (sRGB 0..1) by the mixing model, into `out`. */
|
|
1147
1453
|
mixColors(a, b, t, out) {
|
|
1148
1454
|
if (this.pig) {
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1455
|
+
_chunkO7LUD7MHcjs.setPigmentColor.call(void 0, this.pig.canvas, a[0], a[1], a[2]);
|
|
1456
|
+
_chunkO7LUD7MHcjs.setPigmentColor.call(void 0, this.pig.paint, b[0], b[1], b[2]);
|
|
1457
|
+
_chunkO7LUD7MHcjs.lerpPigmentInto.call(void 0, this.pig.canvas, this.pig.paint, t, out, 0);
|
|
1152
1458
|
} else for (let c = 0; c < 3; c++) out[c] = a[c] + (b[c] - a[c]) * t;
|
|
1153
1459
|
return out;
|
|
1154
1460
|
}
|
|
@@ -1158,11 +1464,11 @@ var PaintExchange = (_class4 = class {
|
|
|
1158
1464
|
const pig = this.pig;
|
|
1159
1465
|
if (!this.well) this.well = [sample.rgb[0], sample.rgb[1], sample.rgb[2]];
|
|
1160
1466
|
else {
|
|
1161
|
-
if (pig)
|
|
1162
|
-
const o = this.mix(this.well, _nullishCoalesce(_optionalChain([pig, 'optionalAccess',
|
|
1467
|
+
if (pig) _chunkO7LUD7MHcjs.setPigmentColor.call(void 0, pig.canvas, sample.rgb[0], sample.rgb[1], sample.rgb[2]);
|
|
1468
|
+
const o = this.mix(this.well, _nullishCoalesce(_optionalChain([pig, 'optionalAccess', _27 => _27.well]), () => ( null)), sample.rgb, _nullishCoalesce(_optionalChain([pig, 'optionalAccess', _28 => _28.canvas]), () => ( null)), this.rates.pickup * sample.contact);
|
|
1163
1469
|
this.well = [o[0], o[1], o[2]];
|
|
1164
1470
|
}
|
|
1165
|
-
if (pig)
|
|
1471
|
+
if (pig) _chunkO7LUD7MHcjs.setPigmentColor.call(void 0, pig.well, this.well[0], this.well[1], this.well[2]);
|
|
1166
1472
|
}
|
|
1167
1473
|
/**
|
|
1168
1474
|
* 2. The dab's paint: the reservoir mixed with the well, written to `out`. Returns the total
|
|
@@ -1177,7 +1483,7 @@ var PaintExchange = (_class4 = class {
|
|
|
1177
1483
|
if (!(total > 1e-6)) return 0;
|
|
1178
1484
|
const pig = this.pig;
|
|
1179
1485
|
if (res && this.well) {
|
|
1180
|
-
const m = this.mix(res, _nullishCoalesce(_optionalChain([pig, 'optionalAccess',
|
|
1486
|
+
const m = this.mix(res, _nullishCoalesce(_optionalChain([pig, 'optionalAccess', _29 => _29.res]), () => ( null)), this.well, _nullishCoalesce(_optionalChain([pig, 'optionalAccess', _30 => _30.well]), () => ( null)), wp / total);
|
|
1181
1487
|
out[0] = m[0];
|
|
1182
1488
|
out[1] = m[1];
|
|
1183
1489
|
out[2] = m[2];
|
|
@@ -1187,36 +1493,36 @@ var PaintExchange = (_class4 = class {
|
|
|
1187
1493
|
out[1] = c[1];
|
|
1188
1494
|
out[2] = c[2];
|
|
1189
1495
|
}
|
|
1190
|
-
if (pig)
|
|
1496
|
+
if (pig) _chunkO7LUD7MHcjs.setPigmentColor.call(void 0, pig.paint, out[0], out[1], out[2]);
|
|
1191
1497
|
return total;
|
|
1192
1498
|
}
|
|
1193
1499
|
/** 3. The reservoir drains. */
|
|
1194
1500
|
drain() {
|
|
1195
1501
|
this.amount *= 1 - this.rates.drain;
|
|
1196
1502
|
}
|
|
1197
|
-
},
|
|
1503
|
+
}, _class5);
|
|
1198
1504
|
function put255(px, i, v) {
|
|
1199
1505
|
if (px instanceof Float32Array) px[i] = v > 0 ? v * 255 : 0;
|
|
1200
1506
|
else px[i] = Math.round(v * 255);
|
|
1201
1507
|
}
|
|
1202
|
-
var TileMedium = (
|
|
1203
|
-
constructor(target, options = {}) {;
|
|
1508
|
+
var TileMedium = (_class6 = class {
|
|
1509
|
+
constructor(target, options = {}) {;_class6.prototype.__init24.call(this);_class6.prototype.__init25.call(this);_class6.prototype.__init26.call(this);_class6.prototype.__init27.call(this);_class6.prototype.__init28.call(this);_class6.prototype.__init29.call(this);_class6.prototype.__init30.call(this);_class6.prototype.__init31.call(this);_class6.prototype.__init32.call(this);_class6.prototype.__init33.call(this);
|
|
1204
1510
|
this.target = target;
|
|
1205
1511
|
this.options = options;
|
|
1206
1512
|
}
|
|
1207
1513
|
|
|
1208
1514
|
|
|
1209
1515
|
// The tile last looked up by `locate` (and whether it came from `writeTile`).
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1516
|
+
__init24() {this.tx = NaN}
|
|
1517
|
+
__init25() {this.ty = NaN}
|
|
1518
|
+
__init26() {this.tile = null}
|
|
1519
|
+
__init27() {this.writable = false}
|
|
1520
|
+
__init28() {this.canvasPig = _chunkO7LUD7MHcjs.createPigment.call(void 0, [0, 0, 0])}
|
|
1521
|
+
__init29() {this.paintPig = _chunkO7LUD7MHcjs.createPigment.call(void 0, [0, 0, 0])}
|
|
1522
|
+
__init30() {this.paintKey = -1}
|
|
1523
|
+
__init31() {this.cb = [0, 0, 0, 0]}
|
|
1524
|
+
__init32() {this.src = [0, 0, 0, 1]}
|
|
1525
|
+
__init33() {this.o = [0, 0, 0]}
|
|
1220
1526
|
/** Forgets the cached tile (call when another writer may have replaced tiles). */
|
|
1221
1527
|
reset() {
|
|
1222
1528
|
this.tx = NaN;
|
|
@@ -1229,15 +1535,15 @@ var TileMedium = (_class5 = class {
|
|
|
1229
1535
|
const t = this.target;
|
|
1230
1536
|
const lx = dx - t.offset.x;
|
|
1231
1537
|
const ly = dy - t.offset.y;
|
|
1232
|
-
const tx = Math.floor(lx /
|
|
1233
|
-
const ty = Math.floor(ly /
|
|
1538
|
+
const tx = Math.floor(lx / _chunkO7LUD7MHcjs.TILE);
|
|
1539
|
+
const ty = Math.floor(ly / _chunkO7LUD7MHcjs.TILE);
|
|
1234
1540
|
if (tx !== this.tx || ty !== this.ty || write && !this.writable) {
|
|
1235
1541
|
this.tx = tx;
|
|
1236
1542
|
this.ty = ty;
|
|
1237
1543
|
this.tile = write ? t.writeTile(tx, ty) : t.readTile(tx, ty);
|
|
1238
1544
|
this.writable = write;
|
|
1239
1545
|
}
|
|
1240
|
-
return this.tile ? ((ly - ty *
|
|
1546
|
+
return this.tile ? ((ly - ty * _chunkO7LUD7MHcjs.TILE) * _chunkO7LUD7MHcjs.TILE + (lx - tx * _chunkO7LUD7MHcjs.TILE)) * 4 : -1;
|
|
1241
1547
|
}
|
|
1242
1548
|
/** The tile `locate` last found. */
|
|
1243
1549
|
get pixels() {
|
|
@@ -1317,7 +1623,7 @@ var TileMedium = (_class5 = class {
|
|
|
1317
1623
|
src[0] = pr;
|
|
1318
1624
|
src[1] = pg;
|
|
1319
1625
|
src[2] = pb;
|
|
1320
|
-
const r =
|
|
1626
|
+
const r = _chunkO7LUD7MHcjs.blendPixel.call(void 0, blend, cb, src, k);
|
|
1321
1627
|
put255(px, i, r[0]);
|
|
1322
1628
|
put255(px, i + 1, r[1]);
|
|
1323
1629
|
put255(px, i + 2, r[2]);
|
|
@@ -1332,23 +1638,23 @@ var TileMedium = (_class5 = class {
|
|
|
1332
1638
|
o[1] = pg;
|
|
1333
1639
|
o[2] = pb;
|
|
1334
1640
|
} else if (pigment && field) {
|
|
1335
|
-
|
|
1641
|
+
_chunkO7LUD7MHcjs.mixPigment8.call(void 0, Math.round(px[i]), Math.round(px[i + 1]), Math.round(px[i + 2]), Math.round(pr * 255), Math.round(pg * 255), Math.round(pb * 255), share, o);
|
|
1336
1642
|
} else if (pigment) {
|
|
1337
1643
|
const key = px instanceof Float32Array ? -2 : px[i] << 16 | px[i + 1] << 8 | px[i + 2];
|
|
1338
1644
|
if (key !== lastKey || key === -2) {
|
|
1339
|
-
|
|
1645
|
+
_chunkO7LUD7MHcjs.setPigmentColor.call(void 0, this.canvasPig, px[i] / 255, px[i + 1] / 255, px[i + 2] / 255);
|
|
1340
1646
|
lastKey = key;
|
|
1341
1647
|
}
|
|
1342
1648
|
let pp = paintPigment;
|
|
1343
1649
|
if (!pp) {
|
|
1344
1650
|
const pkey = Math.round(pr * 255) << 16 | Math.round(pg * 255) << 8 | Math.round(pb * 255);
|
|
1345
1651
|
if (pkey !== this.paintKey) {
|
|
1346
|
-
|
|
1652
|
+
_chunkO7LUD7MHcjs.setPigmentColor.call(void 0, this.paintPig, pr, pg, pb);
|
|
1347
1653
|
this.paintKey = pkey;
|
|
1348
1654
|
}
|
|
1349
1655
|
pp = this.paintPig;
|
|
1350
1656
|
}
|
|
1351
|
-
|
|
1657
|
+
_chunkO7LUD7MHcjs.lerpPigmentInto.call(void 0, this.canvasPig, pp, share, o, 0);
|
|
1352
1658
|
} else {
|
|
1353
1659
|
o[0] = px[i] / 255 + (pr - px[i] / 255) * share;
|
|
1354
1660
|
o[1] = px[i + 1] / 255 + (pg - px[i + 1] / 255) * share;
|
|
@@ -1361,7 +1667,7 @@ var TileMedium = (_class5 = class {
|
|
|
1361
1667
|
}
|
|
1362
1668
|
}
|
|
1363
1669
|
}
|
|
1364
|
-
},
|
|
1670
|
+
}, _class6);
|
|
1365
1671
|
|
|
1366
1672
|
// src/paint/blending.ts
|
|
1367
1673
|
var DEFAULT_BLENDER = { strength: 0.5, distance: 0.35, mixing: "pigment" };
|
|
@@ -1377,9 +1683,9 @@ function blendRadius(settings, radius) {
|
|
|
1377
1683
|
return Math.max(1, Math.round(settings.distance * 2 * radius));
|
|
1378
1684
|
}
|
|
1379
1685
|
function createBlenderScratch() {
|
|
1380
|
-
return { sums: new Float64Array(0), mix: { rgb: [0, 0, 0], strength: 1, ks: new Float32Array(
|
|
1686
|
+
return { sums: new Float64Array(0), mix: { rgb: [0, 0, 0], strength: 1, ks: new Float32Array(_chunkO7LUD7MHcjs.PIGMENT_BANDS), scatter: 1 }, out: [0, 0, 0] };
|
|
1381
1687
|
}
|
|
1382
|
-
var N =
|
|
1688
|
+
var N = _chunkO7LUD7MHcjs.PIGMENT_BANDS;
|
|
1383
1689
|
function blenderDab(medium, rect, cov, opacity, radius, settings, scratch) {
|
|
1384
1690
|
const R = blendRadius(settings, radius);
|
|
1385
1691
|
const W = rect.width + 2 * R;
|
|
@@ -1404,7 +1710,7 @@ function blenderDab(medium, rect, cov, opacity, radius, settings, scratch) {
|
|
|
1404
1710
|
const a = px[i + 3] / 255;
|
|
1405
1711
|
if (a > 0) {
|
|
1406
1712
|
if (pigment) {
|
|
1407
|
-
const p =
|
|
1713
|
+
const p = _chunkO7LUD7MHcjs.pigment8.call(void 0, Math.round(px[i]), Math.round(px[i + 1]), Math.round(px[i + 2]));
|
|
1408
1714
|
const sa = p.scatter * p.strength * a;
|
|
1409
1715
|
for (let k = 0; k < N; k++) row[k] += sa * p.ks[k];
|
|
1410
1716
|
row[N] += sa;
|
|
@@ -1462,8 +1768,8 @@ function blenderDab(medium, rect, cov, opacity, radius, settings, scratch) {
|
|
|
1462
1768
|
const sa = sum(N, x1, y1, x2, y2);
|
|
1463
1769
|
for (let c = 0; c < N; c++) mixPig.ks[c] = sum(c, x1, y1, x2, y2) / sa;
|
|
1464
1770
|
mixPig.scatter = sa / asum;
|
|
1465
|
-
if (a <= 0 || share >= 1)
|
|
1466
|
-
else
|
|
1771
|
+
if (a <= 0 || share >= 1) _chunkO7LUD7MHcjs.lerpPigmentInto.call(void 0, mixPig, mixPig, 0, out, 0);
|
|
1772
|
+
else _chunkO7LUD7MHcjs.lerpPigmentInto.call(void 0, _chunkO7LUD7MHcjs.pigment8.call(void 0, Math.round(px[i]), Math.round(px[i + 1]), Math.round(px[i + 2])), mixPig, share, out, 0);
|
|
1467
1773
|
} else {
|
|
1468
1774
|
for (let c = 0; c < 3; c++) {
|
|
1469
1775
|
const m = sum(c, x1, y1, x2, y2) / asum;
|
|
@@ -1477,8 +1783,8 @@ function blenderDab(medium, rect, cov, opacity, radius, settings, scratch) {
|
|
|
1477
1783
|
}
|
|
1478
1784
|
}
|
|
1479
1785
|
}
|
|
1480
|
-
var SmudgeTip = (
|
|
1481
|
-
constructor(settings, diameter) {;
|
|
1786
|
+
var SmudgeTip = (_class7 = class {
|
|
1787
|
+
constructor(settings, diameter) {;_class7.prototype.__init34.call(this);_class7.prototype.__init35.call(this);
|
|
1482
1788
|
this.settings = settings;
|
|
1483
1789
|
this.size = Math.max(2, Math.min(512, Math.ceil(diameter)));
|
|
1484
1790
|
this.patch = new Float32Array(this.size * this.size * 4);
|
|
@@ -1486,8 +1792,8 @@ var SmudgeTip = (_class6 = class {
|
|
|
1486
1792
|
|
|
1487
1793
|
|
|
1488
1794
|
|
|
1489
|
-
|
|
1490
|
-
|
|
1795
|
+
__init34() {this.loaded = false}
|
|
1796
|
+
__init35() {this.out = [0, 0, 0]}
|
|
1491
1797
|
cell(d, px, py) {
|
|
1492
1798
|
const s = this.size;
|
|
1493
1799
|
const r = Math.max(0.5, d.radius);
|
|
@@ -1523,7 +1829,7 @@ var SmudgeTip = (_class6 = class {
|
|
|
1523
1829
|
mix(a0, a1, a2, b0, b1, b2, t) {
|
|
1524
1830
|
const o = this.out;
|
|
1525
1831
|
if (this.settings.mixing === "pigment") {
|
|
1526
|
-
|
|
1832
|
+
_chunkO7LUD7MHcjs.mixPigment8.call(void 0, Math.round(a0 * 255), Math.round(a1 * 255), Math.round(a2 * 255), Math.round(b0 * 255), Math.round(b1 * 255), Math.round(b2 * 255), t, o);
|
|
1527
1833
|
} else {
|
|
1528
1834
|
o[0] = a0 + (b0 - a0) * t;
|
|
1529
1835
|
o[1] = a1 + (b1 - a1) * t;
|
|
@@ -1598,7 +1904,7 @@ var SmudgeTip = (_class6 = class {
|
|
|
1598
1904
|
}
|
|
1599
1905
|
}
|
|
1600
1906
|
}
|
|
1601
|
-
},
|
|
1907
|
+
}, _class7);
|
|
1602
1908
|
|
|
1603
1909
|
// src/paint/mixer.ts
|
|
1604
1910
|
var DEFAULT_MIXER = {
|
|
@@ -1631,22 +1937,22 @@ function loadMixer(load, color) {
|
|
|
1631
1937
|
function cleanMixer(load) {
|
|
1632
1938
|
return { reservoir: load.reservoir, amount: load.amount, pickup: null };
|
|
1633
1939
|
}
|
|
1634
|
-
var MixerStroke = (
|
|
1635
|
-
constructor(brush, settings, load, target) {;
|
|
1940
|
+
var MixerStroke = (_class8 = class {
|
|
1941
|
+
constructor(brush, settings, load, target) {;_class8.prototype.__init36.call(this);_class8.prototype.__init37.call(this);_class8.prototype.__init38.call(this);_class8.prototype.__init39.call(this);_class8.prototype.__init40.call(this);
|
|
1636
1942
|
this.brush = brush;
|
|
1637
1943
|
this.walker = new DabWalker(brush);
|
|
1638
1944
|
this.exchange = new PaintExchange(mixerRates(normalizeMixer(settings)), load);
|
|
1639
1945
|
this.medium = new TileMedium(target);
|
|
1640
1946
|
}
|
|
1641
1947
|
|
|
1642
|
-
|
|
1643
|
-
|
|
1948
|
+
__init36() {this.dabCount = 0}
|
|
1949
|
+
__init37() {this.bounds = null}
|
|
1644
1950
|
|
|
1645
|
-
|
|
1646
|
-
|
|
1951
|
+
__init38() {this.smoothPos = null}
|
|
1952
|
+
__init39() {this.buf = new Float32Array(0)}
|
|
1647
1953
|
|
|
1648
1954
|
|
|
1649
|
-
|
|
1955
|
+
__init40() {this.paintColor = [0, 0, 0]}
|
|
1650
1956
|
/** The brush load after the dabs so far. */
|
|
1651
1957
|
get load() {
|
|
1652
1958
|
return this.exchange.load;
|
|
@@ -1694,7 +2000,7 @@ var MixerStroke = (_class7 = class {
|
|
|
1694
2000
|
}
|
|
1695
2001
|
ex.drain();
|
|
1696
2002
|
}
|
|
1697
|
-
},
|
|
2003
|
+
}, _class8);
|
|
1698
2004
|
function union(a, b) {
|
|
1699
2005
|
if (!a) return { ...b };
|
|
1700
2006
|
const x = Math.min(a.x, b.x);
|
|
@@ -1778,5 +2084,16 @@ function union(a, b) {
|
|
|
1778
2084
|
|
|
1779
2085
|
|
|
1780
2086
|
|
|
1781
|
-
|
|
1782
|
-
|
|
2087
|
+
|
|
2088
|
+
|
|
2089
|
+
|
|
2090
|
+
|
|
2091
|
+
|
|
2092
|
+
|
|
2093
|
+
|
|
2094
|
+
|
|
2095
|
+
|
|
2096
|
+
|
|
2097
|
+
|
|
2098
|
+
exports.mix32 = mix32; exports.hash2 = hash2; exports.rand01 = rand01; exports.PAINT_GRADIENT_SPACES = PAINT_GRADIENT_SPACES; exports.PAINT_GRADIENT_REPEATS = PAINT_GRADIENT_REPEATS; exports.PAINT_GRADIENT_MAPPINGS = PAINT_GRADIENT_MAPPINGS; exports.DEFAULT_PAINT_GRADIENT_MAPPING = DEFAULT_PAINT_GRADIENT_MAPPING; exports.PAINT_GRADIENT_FULL_SPEED = PAINT_GRADIENT_FULL_SPEED; exports.PaintSourceError = PaintSourceError; exports.normalizeHexColor = normalizeHexColor; exports.hexToPaintRgb = hexToPaintRgb; exports.parsePaintSource = parsePaintSource; exports.readPaintSource = readPaintSource; exports.resolvePaintGradient = resolvePaintGradient; exports.scalePaintGradient = scalePaintGradient; exports.solidPaint = solidPaint; exports.isGradientPaint = isGradientPaint; exports.paintSourceColor = paintSourceColor; exports.paintSourceCss = paintSourceCss; exports.PaintGradientSampler = PaintGradientSampler; exports.PAINT_GRADIENT_JSON_SCHEMA = PAINT_GRADIENT_JSON_SCHEMA; exports.PAINT_COLOR_JSON_SCHEMA = PAINT_COLOR_JSON_SCHEMA; exports.PAINT_SOURCE_JSON_SCHEMA = PAINT_SOURCE_JSON_SCHEMA; exports.PAINT_GRADIENT_MAPPING_LABELS = PAINT_GRADIENT_MAPPING_LABELS; exports.PAINT_GRADIENT_SPACE_LABELS = PAINT_GRADIENT_SPACE_LABELS; exports.PAINT_GRADIENT_REPEAT_LABELS = PAINT_GRADIENT_REPEAT_LABELS; exports.DEFAULT_PAINT_GRADIENT = DEFAULT_PAINT_GRADIENT; exports.PAINT_GRADIENT_PRESETS = PAINT_GRADIENT_PRESETS; exports.addPaintGradientStop = addPaintGradientStop; exports.removePaintGradientStop = removePaintGradientStop; exports.updatePaintGradientStop = updatePaintGradientStop; exports.reversePaintGradient = reversePaintGradient; exports.paintGradientMappingFor = paintGradientMappingFor; exports.PAINT_GRADIENT_KIT = PAINT_GRADIENT_KIT; exports.DEFAULT_BRUSH = DEFAULT_BRUSH; exports.MAX_BRUSH_SIZE = MAX_BRUSH_SIZE; exports.normalizeBrush = normalizeBrush; exports.tipShape = tipShape; exports.tipFalloff = tipFalloff; exports.tipReach = tipReach; exports.dabCoverage = dabCoverage; exports.smoothPoints = smoothPoints; exports.DabWalker = DabWalker; exports.walkDabs = walkDabs; exports.dabRect = dabRect; exports.rasterizeDab = rasterizeDab; exports.CoverageMap = CoverageMap; exports.StrokeCoverage = StrokeCoverage; exports.TIP_GRADIENT_STEPS = TIP_GRADIENT_STEPS; exports.gradientDabColor = gradientDabColor; exports.applyStrokeToTile = applyStrokeToTile; exports.applyStrokeToDeepTile = applyStrokeToDeepTile; exports.coverageTileCoord = coverageTileCoord; 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; exports.MIXING_MODELS = MIXING_MODELS; exports.EMPTY_MIXER_LOAD = EMPTY_MIXER_LOAD; exports.MIXER_PICKUP_RATE = MIXER_PICKUP_RATE; exports.MIXER_DRAIN = MIXER_DRAIN; exports.exchangeRates = exchangeRates; exports.PaintExchange = PaintExchange; exports.put255 = put255; exports.TileMedium = TileMedium; exports.DEFAULT_BLENDER = DEFAULT_BLENDER; exports.DEFAULT_SMUDGE = DEFAULT_SMUDGE; exports.normalizeBlender = normalizeBlender; exports.normalizeSmudge = normalizeSmudge; exports.blendRadius = blendRadius; exports.createBlenderScratch = createBlenderScratch; exports.blenderDab = blenderDab; exports.SmudgeTip = SmudgeTip; exports.DEFAULT_MIXER = DEFAULT_MIXER; exports.normalizeMixer = normalizeMixer; exports.mixerRates = mixerRates; exports.loadMixer = loadMixer; exports.cleanMixer = cleanMixer; exports.MixerStroke = MixerStroke;
|
|
2099
|
+
//# sourceMappingURL=chunk-QBWEH3IM.cjs.map
|