@pixerate/editor 0.116.0 → 0.118.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/THIRD_PARTY_NOTICES.md +2 -0
- package/dist/{chunk-ZYZGEILO.cjs → chunk-2J3LS7JZ.cjs} +203 -203
- package/dist/{chunk-ZYZGEILO.cjs.map → chunk-2J3LS7JZ.cjs.map} +1 -1
- package/dist/{chunk-TFOPHZ3U.cjs → chunk-7ISPWEJA.cjs} +302 -5
- package/dist/chunk-7ISPWEJA.cjs.map +1 -0
- package/dist/{chunk-2UT4GXYA.cjs → chunk-BYAWOAST.cjs} +109 -41
- package/dist/chunk-BYAWOAST.cjs.map +1 -0
- package/dist/{chunk-PAOWHJ5O.cjs → chunk-EBSYZRSW.cjs} +217 -400
- package/dist/chunk-EBSYZRSW.cjs.map +1 -0
- package/dist/{chunk-XK5LZKBD.js → chunk-HKDTM6VC.js} +298 -1
- package/dist/chunk-HKDTM6VC.js.map +1 -0
- package/dist/{chunk-D53VQGEJ.js → chunk-IVSNUXW7.js} +79 -2
- package/dist/chunk-IVSNUXW7.js.map +1 -0
- package/dist/{chunk-ARQ7PQ6Q.js → chunk-JHXMNOMF.js} +71 -3
- package/dist/chunk-JHXMNOMF.js.map +1 -0
- package/dist/{chunk-HOCPSFGA.cjs → chunk-L2T6EJ5S.cjs} +154 -77
- package/dist/chunk-L2T6EJ5S.cjs.map +1 -0
- package/dist/{chunk-SEBYNBHW.js → chunk-R2JE6SA7.js} +9 -9
- package/dist/{chunk-D53KSJUV.js → chunk-VD2UDVF7.js} +100 -283
- package/dist/chunk-VD2UDVF7.js.map +1 -0
- package/dist/{export-BXxSGBCq.d.cts → export-DMOuzgZZ.d.cts} +8 -3
- package/dist/{export-Dm44YUvS.d.ts → export-Dul1SbPv.d.ts} +8 -3
- package/dist/{flow-COCB42TP.d.cts → flow-4-OC-UkQ.d.cts} +22 -1
- package/dist/{flow-BMtHAmg4.d.ts → flow-Cb7lkPm8.d.ts} +22 -1
- package/dist/image-editor/index.cjs +1112 -1024
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +6 -6
- package/dist/image-editor/index.d.ts +6 -6
- package/dist/image-editor/index.js +124 -36
- package/dist/image-editor/index.js.map +1 -1
- package/dist/paint/index.cjs +8 -4
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +2 -2
- package/dist/paint/index.d.ts +2 -2
- package/dist/paint/index.js +7 -3
- package/dist/paint-editor/index.cjs +242 -242
- package/dist/paint-editor/index.d.cts +4 -4
- package/dist/paint-editor/index.d.ts +4 -4
- package/dist/paint-editor/index.js +4 -4
- package/dist/raster/index.cjs +6 -4
- package/dist/raster/index.cjs.map +1 -1
- package/dist/raster/index.d.cts +2 -2
- package/dist/raster/index.d.ts +2 -2
- package/dist/raster/index.js +27 -25
- package/dist/{render-CrmHOgpo.d.ts → render-B05K68_h.d.ts} +9 -1
- package/dist/{render-B1K_OoLy.d.cts → render-DnAbIKcs.d.cts} +9 -1
- package/dist/vector/index.cjs +11335 -10178
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +159 -5
- package/dist/vector/index.d.ts +159 -5
- package/dist/vector/index.js +11242 -10085
- package/dist/vector/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/pixerate-image-editor/references/photoshop-files.md +6 -7
- package/dist/chunk-2UT4GXYA.cjs.map +0 -1
- package/dist/chunk-ARQ7PQ6Q.js.map +0 -1
- package/dist/chunk-D53KSJUV.js.map +0 -1
- package/dist/chunk-D53VQGEJ.js.map +0 -1
- package/dist/chunk-HOCPSFGA.cjs.map +0 -1
- package/dist/chunk-PAOWHJ5O.cjs.map +0 -1
- package/dist/chunk-TFOPHZ3U.cjs.map +0 -1
- package/dist/chunk-XK5LZKBD.js.map +0 -1
- /package/dist/{chunk-SEBYNBHW.js.map → chunk-R2JE6SA7.js.map} +0 -0
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkL2T6EJ5Scjs = require('./chunk-L2T6EJ5S.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -15,7 +15,9 @@ var _chunkHOCPSFGAcjs = require('./chunk-HOCPSFGA.cjs');
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
var _chunk7ISPWEJAcjs = require('./chunk-7ISPWEJA.cjs');
|
|
19
21
|
|
|
20
22
|
// src/paint/heal.ts
|
|
21
23
|
var TOL = 2e-3;
|
|
@@ -375,9 +377,9 @@ var TilePixelSource = (_class = class {
|
|
|
375
377
|
sample(x, y, out) {
|
|
376
378
|
const lx = x - this.offset.x;
|
|
377
379
|
const ly = y - this.offset.y;
|
|
378
|
-
const tx = Math.floor(lx /
|
|
379
|
-
const ty = Math.floor(ly /
|
|
380
|
-
const key =
|
|
380
|
+
const tx = Math.floor(lx / _chunk7ISPWEJAcjs.TILE);
|
|
381
|
+
const ty = Math.floor(ly / _chunk7ISPWEJAcjs.TILE);
|
|
382
|
+
const key = _chunk7ISPWEJAcjs.tileKey.call(void 0, tx, ty);
|
|
381
383
|
if (key !== this.lastKey) {
|
|
382
384
|
let t2 = this.cache.get(key);
|
|
383
385
|
if (t2 === void 0) {
|
|
@@ -392,7 +394,7 @@ var TilePixelSource = (_class = class {
|
|
|
392
394
|
out[0] = out[1] = out[2] = out[3] = 0;
|
|
393
395
|
return false;
|
|
394
396
|
}
|
|
395
|
-
const p = (ly - ty *
|
|
397
|
+
const p = (ly - ty * _chunk7ISPWEJAcjs.TILE) * _chunk7ISPWEJAcjs.TILE + (lx - tx * _chunk7ISPWEJAcjs.TILE);
|
|
396
398
|
if (this.channels === 1) {
|
|
397
399
|
out[0] = out[1] = out[2] = t[p];
|
|
398
400
|
out[3] = 255;
|
|
@@ -446,21 +448,21 @@ function readSourceRegion(source, rect, dx = 0, dy = 0) {
|
|
|
446
448
|
}
|
|
447
449
|
function applyRetouchToTile(coverage, tileData, channels, tx, ty, paint, s, options = {}) {
|
|
448
450
|
const out = options.into ? new Uint8ClampedArray(options.into) : new Uint8ClampedArray(tileData);
|
|
449
|
-
const ox = tx *
|
|
450
|
-
const oy = ty *
|
|
451
|
+
const ox = tx * _chunk7ISPWEJAcjs.TILE + s.offset.x;
|
|
452
|
+
const oy = ty * _chunk7ISPWEJAcjs.TILE + s.offset.y;
|
|
451
453
|
let x0 = 0;
|
|
452
454
|
let y0 = 0;
|
|
453
|
-
let x1 =
|
|
454
|
-
let y1 =
|
|
455
|
+
let x1 = _chunk7ISPWEJAcjs.TILE;
|
|
456
|
+
let y1 = _chunk7ISPWEJAcjs.TILE;
|
|
455
457
|
if (options.region) {
|
|
456
458
|
const r = options.region;
|
|
457
459
|
x0 = Math.max(0, Math.floor(r.x) - ox);
|
|
458
460
|
y0 = Math.max(0, Math.floor(r.y) - oy);
|
|
459
|
-
x1 = Math.min(
|
|
460
|
-
y1 = Math.min(
|
|
461
|
+
x1 = Math.min(_chunk7ISPWEJAcjs.TILE, Math.ceil(r.x + r.width) - ox);
|
|
462
|
+
y1 = Math.min(_chunk7ISPWEJAcjs.TILE, Math.ceil(r.y + r.height) - oy);
|
|
461
463
|
if (x1 <= x0 || y1 <= y0) return out;
|
|
462
464
|
if (options.into) {
|
|
463
|
-
for (let y = y0; y < y1; y++) out.set(tileData.subarray((y *
|
|
465
|
+
for (let y = y0; y < y1; y++) out.set(tileData.subarray((y * _chunk7ISPWEJAcjs.TILE + x0) * channels, (y * _chunk7ISPWEJAcjs.TILE + x1) * channels), (y * _chunk7ISPWEJAcjs.TILE + x0) * channels);
|
|
464
466
|
}
|
|
465
467
|
}
|
|
466
468
|
const sel = s.selection;
|
|
@@ -473,17 +475,17 @@ function applyRetouchToTile(coverage, tileData, channels, tx, ty, paint, s, opti
|
|
|
473
475
|
let covTile;
|
|
474
476
|
for (let y = y0; y < y1; y++) {
|
|
475
477
|
const dy = oy + y;
|
|
476
|
-
const cty = Math.floor(dy /
|
|
478
|
+
const cty = Math.floor(dy / _chunk7ISPWEJAcjs.TILE);
|
|
477
479
|
for (let x = x0; x < x1; x++) {
|
|
478
480
|
const dx = ox + x;
|
|
479
|
-
const ctx = Math.floor(dx /
|
|
480
|
-
const key =
|
|
481
|
+
const ctx = Math.floor(dx / _chunk7ISPWEJAcjs.TILE);
|
|
482
|
+
const key = _chunk7ISPWEJAcjs.tileKey.call(void 0, ctx, cty);
|
|
481
483
|
if (key !== covKey) {
|
|
482
484
|
covKey = key;
|
|
483
485
|
covTile = coverage.tiles.get(key);
|
|
484
486
|
}
|
|
485
487
|
if (!covTile) continue;
|
|
486
|
-
const c = covTile[(dy - cty *
|
|
488
|
+
const c = covTile[(dy - cty * _chunk7ISPWEJAcjs.TILE) * _chunk7ISPWEJAcjs.TILE + (dx - ctx * _chunk7ISPWEJAcjs.TILE)];
|
|
487
489
|
if (c <= 0) continue;
|
|
488
490
|
let k = c * s.opacity;
|
|
489
491
|
if (sel) {
|
|
@@ -492,7 +494,7 @@ function applyRetouchToTile(coverage, tileData, channels, tx, ty, paint, s, opti
|
|
|
492
494
|
}
|
|
493
495
|
if (k > 1) k = 1;
|
|
494
496
|
if (k <= 0) continue;
|
|
495
|
-
const p = y *
|
|
497
|
+
const p = y * _chunk7ISPWEJAcjs.TILE + x;
|
|
496
498
|
if (channels === 1) {
|
|
497
499
|
const g = out[p];
|
|
498
500
|
let t;
|
|
@@ -536,7 +538,7 @@ function applyRetouchToTile(coverage, tileData, channels, tx, ty, paint, s, opti
|
|
|
536
538
|
cb[ch] = out[i + ch] / 255;
|
|
537
539
|
cs[ch] = src[ch] / 255;
|
|
538
540
|
}
|
|
539
|
-
const o =
|
|
541
|
+
const o = _chunk7ISPWEJAcjs.blendPixel.call(void 0, blend, cb, cs, k);
|
|
540
542
|
out[i] = Math.round(o[0] * 255);
|
|
541
543
|
out[i + 1] = Math.round(o[1] * 255);
|
|
542
544
|
out[i + 2] = Math.round(o[2] * 255);
|
|
@@ -545,6 +547,71 @@ function applyRetouchToTile(coverage, tileData, channels, tx, ty, paint, s, opti
|
|
|
545
547
|
}
|
|
546
548
|
return out;
|
|
547
549
|
}
|
|
550
|
+
function applyToneToDeepTile(coverage, samples, tx, ty, tone, s, options = {}) {
|
|
551
|
+
const linear = samples instanceof Float32Array;
|
|
552
|
+
const out = (_nullishCoalesce(options.into, () => ( samples))).slice();
|
|
553
|
+
const ox = tx * _chunk7ISPWEJAcjs.TILE + s.offset.x;
|
|
554
|
+
const oy = ty * _chunk7ISPWEJAcjs.TILE + s.offset.y;
|
|
555
|
+
let x0 = 0;
|
|
556
|
+
let y0 = 0;
|
|
557
|
+
let x1 = _chunk7ISPWEJAcjs.TILE;
|
|
558
|
+
let y1 = _chunk7ISPWEJAcjs.TILE;
|
|
559
|
+
if (options.region) {
|
|
560
|
+
const r = options.region;
|
|
561
|
+
x0 = Math.max(0, Math.floor(r.x) - ox);
|
|
562
|
+
y0 = Math.max(0, Math.floor(r.y) - oy);
|
|
563
|
+
x1 = Math.min(_chunk7ISPWEJAcjs.TILE, Math.ceil(r.x + r.width) - ox);
|
|
564
|
+
y1 = Math.min(_chunk7ISPWEJAcjs.TILE, Math.ceil(r.y + r.height) - oy);
|
|
565
|
+
if (x1 <= x0 || y1 <= y0) return out;
|
|
566
|
+
if (options.into) for (let y = y0; y < y1; y++) out.set(samples.subarray((y * _chunk7ISPWEJAcjs.TILE + x0) * 4, (y * _chunk7ISPWEJAcjs.TILE + x1) * 4), (y * _chunk7ISPWEJAcjs.TILE + x0) * 4);
|
|
567
|
+
}
|
|
568
|
+
const sel = s.selection;
|
|
569
|
+
const rgb = [0, 0, 0];
|
|
570
|
+
const before = [0, 0, 0];
|
|
571
|
+
const excess = [0, 0, 0];
|
|
572
|
+
let covKey = NaN;
|
|
573
|
+
let covTile;
|
|
574
|
+
for (let y = y0; y < y1; y++) {
|
|
575
|
+
const dy = oy + y;
|
|
576
|
+
const cty = Math.floor(dy / _chunk7ISPWEJAcjs.TILE);
|
|
577
|
+
for (let x = x0; x < x1; x++) {
|
|
578
|
+
const dx = ox + x;
|
|
579
|
+
const ctx = Math.floor(dx / _chunk7ISPWEJAcjs.TILE);
|
|
580
|
+
const key = _chunk7ISPWEJAcjs.tileKey.call(void 0, ctx, cty);
|
|
581
|
+
if (key !== covKey) {
|
|
582
|
+
covKey = key;
|
|
583
|
+
covTile = coverage.tiles.get(key);
|
|
584
|
+
}
|
|
585
|
+
if (!covTile) continue;
|
|
586
|
+
const c = covTile[(dy - cty * _chunk7ISPWEJAcjs.TILE) * _chunk7ISPWEJAcjs.TILE + (dx - ctx * _chunk7ISPWEJAcjs.TILE)];
|
|
587
|
+
if (c <= 0) continue;
|
|
588
|
+
let k = c * s.opacity;
|
|
589
|
+
if (sel) {
|
|
590
|
+
if (dx < 0 || dy < 0 || dx >= sel.width || dy >= sel.height) continue;
|
|
591
|
+
k *= sel.data[dy * sel.width + dx] / 255;
|
|
592
|
+
}
|
|
593
|
+
if (k > 1) k = 1;
|
|
594
|
+
if (k <= 0) continue;
|
|
595
|
+
const i = (y * _chunk7ISPWEJAcjs.TILE + x) * 4;
|
|
596
|
+
if (out[i + 3] === 0) continue;
|
|
597
|
+
for (let ch = 0; ch < 3; ch++) {
|
|
598
|
+
const v = out[i + ch];
|
|
599
|
+
if (linear) {
|
|
600
|
+
excess[ch] = v > 1 ? v - 1 : 0;
|
|
601
|
+
rgb[ch] = _chunk7ISPWEJAcjs.srgbEncode.call(void 0, v > 1 ? 1 : v < 0 ? 0 : v);
|
|
602
|
+
} else rgb[ch] = v / 65535;
|
|
603
|
+
before[ch] = rgb[ch];
|
|
604
|
+
}
|
|
605
|
+
tone(rgb);
|
|
606
|
+
for (let ch = 0; ch < 3; ch++) {
|
|
607
|
+
const e = before[ch] + (rgb[ch] - before[ch]) * k;
|
|
608
|
+
if (linear) out[i + ch] = _chunk7ISPWEJAcjs.srgbDecode.call(void 0, e) + excess[ch];
|
|
609
|
+
else out[i + ch] = e <= 0 ? 0 : e >= 1 ? 65535 : Math.round(e * 65535);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
return out;
|
|
614
|
+
}
|
|
548
615
|
function toneOf(tool, settings) {
|
|
549
616
|
const burn = tool === "burn";
|
|
550
617
|
return (rgb) => {
|
|
@@ -622,8 +689,8 @@ var RetouchDabStroke = (_class2 = class {
|
|
|
622
689
|
constructor(brush, target, effect) {;_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);
|
|
623
690
|
this.brush = brush;
|
|
624
691
|
this.effect = effect;
|
|
625
|
-
this.walker = new (0,
|
|
626
|
-
this.medium = new (0,
|
|
692
|
+
this.walker = new (0, _chunkL2T6EJ5Scjs.DabWalker)(brush);
|
|
693
|
+
this.medium = new (0, _chunkL2T6EJ5Scjs.TileMedium)(target);
|
|
627
694
|
}
|
|
628
695
|
|
|
629
696
|
|
|
@@ -654,11 +721,11 @@ var RetouchDabStroke = (_class2 = class {
|
|
|
654
721
|
paint(dabs) {
|
|
655
722
|
const rects = [];
|
|
656
723
|
for (const d of dabs) {
|
|
657
|
-
const rect =
|
|
724
|
+
const rect = _chunkL2T6EJ5Scjs.dabRect.call(void 0, d, this.brush.hardness);
|
|
658
725
|
const n = rect.width * rect.height;
|
|
659
726
|
if (this.buf.length < n) this.buf = new Float32Array(n);
|
|
660
727
|
const cov = this.buf.subarray(0, n);
|
|
661
|
-
|
|
728
|
+
_chunkL2T6EJ5Scjs.rasterizeDab.call(void 0, { ...d, alpha: 1 }, this.brush.hardness, rect, cov);
|
|
662
729
|
this.medium.reset();
|
|
663
730
|
this.effect(this.medium, d, rect, cov);
|
|
664
731
|
rects.push(rect);
|
|
@@ -670,7 +737,7 @@ var RetouchDabStroke = (_class2 = class {
|
|
|
670
737
|
}, _class2);
|
|
671
738
|
function smudgeEffect(brush, strength, mixing = "rgb") {
|
|
672
739
|
const s = Math.min(1, Math.max(0, strength));
|
|
673
|
-
const tip = new (0,
|
|
740
|
+
const tip = new (0, _chunkL2T6EJ5Scjs.SmudgeTip)({ strength: s, length: s, mixing }, brush.size);
|
|
674
741
|
return (medium, d, rect, cov) => tip.dab(medium, { x: d.x, y: d.y, radius: d.radius, opacity: d.opacity * d.alpha }, rect, cov);
|
|
675
742
|
}
|
|
676
743
|
function spongeEffect(brush, saturate, vibrance) {
|
|
@@ -716,19 +783,19 @@ function rgbaViewOfGrey(target) {
|
|
|
716
783
|
lockTransparency: true,
|
|
717
784
|
selection: target.selection,
|
|
718
785
|
readTile: (tx, ty) => {
|
|
719
|
-
const key =
|
|
786
|
+
const key = _chunk7ISPWEJAcjs.tileKey.call(void 0, tx, ty);
|
|
720
787
|
let v = views.get(key);
|
|
721
788
|
if (!v) {
|
|
722
|
-
v = expand(_nullishCoalesce(target.readTile(tx, ty), () => ( new Uint8ClampedArray(
|
|
789
|
+
v = expand(_nullishCoalesce(target.readTile(tx, ty), () => ( new Uint8ClampedArray(_chunk7ISPWEJAcjs.TILE * _chunk7ISPWEJAcjs.TILE))));
|
|
723
790
|
views.set(key, v);
|
|
724
791
|
}
|
|
725
792
|
return v;
|
|
726
793
|
},
|
|
727
794
|
writeTile: (tx, ty) => {
|
|
728
|
-
const key =
|
|
795
|
+
const key = _chunk7ISPWEJAcjs.tileKey.call(void 0, tx, ty);
|
|
729
796
|
let v = views.get(key);
|
|
730
797
|
if (!v) {
|
|
731
|
-
v = expand(_nullishCoalesce(target.readTile(tx, ty), () => ( new Uint8ClampedArray(
|
|
798
|
+
v = expand(_nullishCoalesce(target.readTile(tx, ty), () => ( new Uint8ClampedArray(_chunk7ISPWEJAcjs.TILE * _chunk7ISPWEJAcjs.TILE))));
|
|
732
799
|
views.set(key, v);
|
|
733
800
|
}
|
|
734
801
|
dirty.set(key, { tx, ty, data: v });
|
|
@@ -769,7 +836,7 @@ function lean(s) {
|
|
|
769
836
|
return null;
|
|
770
837
|
}
|
|
771
838
|
function pathStrokeDabs(samples, options) {
|
|
772
|
-
const brush =
|
|
839
|
+
const brush = _chunkL2T6EJ5Scjs.normalizeBrush.call(void 0, options.brush);
|
|
773
840
|
const pts = options.closed && samples.length > 2 ? [...samples, samples[0]] : [...samples];
|
|
774
841
|
if (!pts.length) return [];
|
|
775
842
|
const tilt = _nullishCoalesce(options.tilt, () => ( {}));
|
|
@@ -819,18 +886,18 @@ function pathStrokeDabs(samples, options) {
|
|
|
819
886
|
return out;
|
|
820
887
|
}
|
|
821
888
|
function pathStrokeCoverage(samples, options) {
|
|
822
|
-
const brush =
|
|
823
|
-
const coverage = new (0,
|
|
889
|
+
const brush = _chunkL2T6EJ5Scjs.normalizeBrush.call(void 0, options.brush);
|
|
890
|
+
const coverage = new (0, _chunkL2T6EJ5Scjs.CoverageMap)();
|
|
824
891
|
const dabs = pathStrokeDabs(samples, options);
|
|
825
892
|
let buf = new Float32Array(0);
|
|
826
893
|
let bounds = null;
|
|
827
894
|
for (const d of dabs) {
|
|
828
|
-
const rect =
|
|
895
|
+
const rect = _chunkL2T6EJ5Scjs.dabRect.call(void 0, d, brush.hardness);
|
|
829
896
|
const n = rect.width * rect.height;
|
|
830
897
|
if (n <= 0) continue;
|
|
831
898
|
if (buf.length < n) buf = new Float32Array(n);
|
|
832
899
|
const vals = buf.subarray(0, n);
|
|
833
|
-
|
|
900
|
+
_chunkL2T6EJ5Scjs.rasterizeDab.call(void 0, d, brush.hardness, rect, vals);
|
|
834
901
|
coverage.accumulate(rect, vals, d.opacity);
|
|
835
902
|
if (!bounds) bounds = { ...rect };
|
|
836
903
|
else {
|
|
@@ -843,7 +910,7 @@ function pathStrokeCoverage(samples, options) {
|
|
|
843
910
|
}
|
|
844
911
|
function paintPathStroke(surface, samples, options) {
|
|
845
912
|
if (surface.channels !== 4) throw new Error("paintPathStroke paints RGBA surfaces (4 channels).");
|
|
846
|
-
const brush =
|
|
913
|
+
const brush = _chunkL2T6EJ5Scjs.normalizeBrush.call(void 0, options.brush);
|
|
847
914
|
const { coverage, bounds, dabs } = pathStrokeCoverage(samples, options);
|
|
848
915
|
if (!bounds) return { surface, bounds: null, dabs };
|
|
849
916
|
const offset = _nullishCoalesce(options.offset, () => ( { x: 0, y: 0 }));
|
|
@@ -858,15 +925,15 @@ function paintPathStroke(surface, samples, options) {
|
|
|
858
925
|
offset
|
|
859
926
|
};
|
|
860
927
|
const tiles = new Map(surface.tiles);
|
|
861
|
-
for (const { tx, ty } of
|
|
862
|
-
const key =
|
|
928
|
+
for (const { tx, ty } of _chunk7ISPWEJAcjs.tilesInRect.call(void 0, { x: bounds.x - offset.x, y: bounds.y - offset.y, width: bounds.width, height: bounds.height })) {
|
|
929
|
+
const key = _chunk7ISPWEJAcjs.tileKey.call(void 0, tx, ty);
|
|
863
930
|
const src = _optionalChain([surface, 'access', _3 => _3.tiles, 'access', _4 => _4.get, 'call', _5 => _5(key), 'optionalAccess', _6 => _6.data]);
|
|
864
|
-
const base = src && src.length ===
|
|
865
|
-
const t =
|
|
931
|
+
const base = src && src.length === _chunk7ISPWEJAcjs.TILE * _chunk7ISPWEJAcjs.TILE * 4 ? src : new Uint8ClampedArray(_chunk7ISPWEJAcjs.TILE * _chunk7ISPWEJAcjs.TILE * 4);
|
|
932
|
+
const t = _chunk7ISPWEJAcjs.finishTile.call(void 0, _chunkL2T6EJ5Scjs.applyStrokeToTile.call(void 0, coverage, base, 4, tx, ty, apply), 4, surface.defaultValue);
|
|
866
933
|
if (t) tiles.set(key, t);
|
|
867
934
|
else tiles.delete(key);
|
|
868
935
|
}
|
|
869
|
-
return { surface: new (0,
|
|
936
|
+
return { surface: new (0, _chunk7ISPWEJAcjs.TiledSurface)(4, tiles, surface.defaultValue), bounds, dabs };
|
|
870
937
|
}
|
|
871
938
|
|
|
872
939
|
|
|
@@ -902,5 +969,6 @@ function paintPathStroke(surface, samples, options) {
|
|
|
902
969
|
|
|
903
970
|
|
|
904
971
|
|
|
905
|
-
|
|
906
|
-
|
|
972
|
+
|
|
973
|
+
exports.solveMembrane = solveMembrane; exports.seamlessClone = seamlessClone; exports.membraneFill = membraneFill; exports.dilateMask = dilateMask; exports.maskBounds = maskBounds; exports.bestOffset = bestOffset; exports.TONE_RANGES = TONE_RANGES; exports.luma = luma; exports.dodgeBurnCurve = dodgeBurnCurve; exports.dodgeBurn = dodgeBurn; exports.saturationOf = saturationOf; exports.sponge = sponge; exports.perDabStrength = perDabStrength; exports.RETOUCH_SAMPLES = RETOUCH_SAMPLES; exports.SPOT_HEAL_TYPES = SPOT_HEAL_TYPES; exports.DEFAULT_RETOUCH = DEFAULT_RETOUCH; exports.normalizeRetouch = normalizeRetouch; exports.TilePixelSource = TilePixelSource; exports.RegionPixelSource = RegionPixelSource; exports.readSourceRegion = readSourceRegion; exports.applyRetouchToTile = applyRetouchToTile; exports.applyToneToDeepTile = applyToneToDeepTile; exports.toneOf = toneOf; exports.healPixels = healPixels; exports.spotHealPixels = spotHealPixels; exports.spotHealWindow = spotHealWindow; exports.RetouchDabStroke = RetouchDabStroke; exports.smudgeEffect = smudgeEffect; exports.spongeEffect = spongeEffect; exports.rgbaViewOfGrey = rgbaViewOfGrey; exports.pathStrokeDabs = pathStrokeDabs; exports.pathStrokeCoverage = pathStrokeCoverage; exports.paintPathStroke = paintPathStroke;
|
|
974
|
+
//# sourceMappingURL=chunk-BYAWOAST.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/chunk-BYAWOAST.cjs","../src/paint/heal.ts","../src/paint/retouch.ts","../src/paint/path-stroke.ts"],"names":["w","t"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACDA,IAAM,IAAA,EAAM,IAAA;AAEZ,IAAM,WAAA,EAAa,EAAA;AACnB,IAAM,WAAA,EAA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,MAAA,CAAO,EAAA,EAAI,MAAA,CAAO,CAAA,EAAG,KAAA,EAAO,MAAA,CAAO,KAAA,EAAO,MAAA,EAAQ,MAAA,CAAO,OAAO,CAAC,CAAA,EAAG;AACpI,IAAA,MAAM,IAAA,EAAM,uCAAA,EAAQ,EAAI,EAAE,CAAA;AAC1B,IAAA,MAAM,IAAA,kBAAM,OAAA,qBAAQ,KAAA,qBAAM,GAAA,mBAAI,GAAG,CAAA,6BAAG,MAAA;AACpC,IAAA,MAAM,KAAA,EAAO,IAAA,GAAO,GAAA,CAAI,OAAA,IAAW,uBAAA,EAAO,uBAAA,EAAO,EAAA,EAAI,IAAA,EAAM,IAAI,iBAAA,CAAkB,uBAAA,EAAO,uBAAA,EAAO,CAAC,CAAA;AAChG,IAAA,MAAM,EAAA,EAAI,0CAAA,iDAAW,QAAkB,EAAU,IAAA,EAAM,CAAA,EAAG,EAAA,EAAI,EAAA,EAAI,KAAK,CAAA,EAAG,CAAA,EAAG,OAAA,CAAQ,YAAY,CAAA;AACjG,IAAA,GAAA,CAAI,CAAA,EAAG,KAAA,CAAM,GAAA,CAAI,GAAA,EAAK,CAAC,CAAA;AAAA,IAAA,KAClB,KAAA,CAAM,MAAA,CAAO,GAAG,CAAA;AAAA,EACvB;AACA,EAAA,OAAO,EAAE,OAAA,EAAS,IAAI,mCAAA,CAAa,CAAA,EAAG,KAAA,EAAO,OAAA,CAAQ,YAAY,CAAA,EAAG,MAAA,EAAQ,KAAK,CAAA;AACnF;AHgvBA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,swCAAC","file":"/home/runner/work/editor/editor/packages/core/dist/chunk-BYAWOAST.cjs","sourcesContent":[null,"// Portions ported from photocraft/crates/algo/src/poisson.rs and inpaint.rs (MIT OR Apache-2.0, © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.\n\n/**\n * Gradient-domain (\"Poisson\") blending for the Healing Brush and the Spot Healing Brush.\n *\n * Method: P. Pérez, M. Gangnet, A. Blake, *Poisson Image Editing*, SIGGRAPH 2003. Seamless cloning\n * looks for `f` over a region Ω with `f = f*` (the destination) on its boundary and `∇f` as close\n * as possible to the source's `∇g`. The answer is `f = g + h`, where `h` is the membrane: the\n * harmonic function (`Δh = 0`) that equals `f* − g` on the boundary. So healed pixels keep the\n * source's texture while their colour and lighting are pulled to the pixels around the stroke.\n *\n * The Laplace equation is solved on the 4-connected grid by successive over-relaxation, started\n * from a recursively solved half-resolution grid (cascadic multigrid). Harmonic functions are\n * smooth, so the coarse guess is close and a few sweeps per level remove the rest.\n *\n * Buffers are interleaved `w × h × ch` floats in any units (the callers use 0..255). Pure maths:\n * no DOM, no framework.\n */\n\n/** Largest per-sweep update below which a solve has converged. */\nconst TOL = 2e-3;\n/** Sweeps (cap) and relaxation on every level above the coarsest. */\nconst FINE_ITERS = 30;\nconst FINE_OMEGA = 1.7;\n\n/**\n * Solves `Δv = 0` on the `unknown` pixels, with the known pixels of `v` as Dirichlet values\n * (neighbours off the grid are ignored: a free boundary). `v` holds the known values on entry and\n * the solution on exit.\n */\nexport function solveMembrane(w: number, h: number, unknown: ArrayLike<boolean | number>, v: Float32Array): void {\n if (unknown.length !== w * h || v.length !== w * h) throw new RangeError(`solveMembrane: expected ${w * h} cells, got ${unknown.length} and ${v.length}.`);\n const u = new Uint8Array(w * h);\n for (let i = 0; i < u.length; i++) u[i] = unknown[i] ? 1 : 0;\n solveLevel(w, h, u, v, 0);\n}\n\nfunction solveLevel(w: number, h: number, unknown: Uint8Array, v: Float32Array, depth: number): void {\n let nUnknown = 0;\n let knownSum = 0;\n let nKnown = 0;\n for (let i = 0; i < unknown.length; i++) {\n if (unknown[i]) nUnknown++;\n else {\n knownSum += v[i];\n nKnown++;\n }\n }\n if (nUnknown === 0 || nKnown === 0) return;\n if (w >= 8 && h >= 8 && nUnknown > 64 && depth < 16) {\n // Restrict: a coarse cell is known when any of its children is (the mean of those).\n const cw = Math.ceil(w / 2);\n const chh = Math.ceil(h / 2);\n const cu = new Uint8Array(cw * chh).fill(1);\n const cv = new Float32Array(cw * chh);\n for (let cy = 0; cy < chh; cy++) {\n for (let cx = 0; cx < cw; cx++) {\n let s = 0;\n let n = 0;\n for (let k = 0; k < 4; k++) {\n const x = cx * 2 + (k & 1);\n const y = cy * 2 + (k >> 1);\n if (x < w && y < h && !unknown[y * w + x]) {\n s += v[y * w + x];\n n++;\n }\n }\n if (n > 0) {\n cu[cy * cw + cx] = 0;\n cv[cy * cw + cx] = s / n;\n }\n }\n }\n solveLevel(cw, chh, cu, cv, depth + 1);\n // Prolong: a bilinear sample of the coarse solution is the starting guess.\n for (let y = 0; y < h; y++) {\n const fy = Math.min(chh - 1, Math.max(0, (y + 0.5) / 2 - 0.5));\n const y0 = Math.floor(fy);\n const y1 = Math.min(chh - 1, y0 + 1);\n const ty = fy - y0;\n for (let x = 0; x < w; x++) {\n if (!unknown[y * w + x]) continue;\n const fx = Math.min(cw - 1, Math.max(0, (x + 0.5) / 2 - 0.5));\n const x0 = Math.floor(fx);\n const x1 = Math.min(cw - 1, x0 + 1);\n const tx = fx - x0;\n const a = cv[y0 * cw + x0] + (cv[y0 * cw + x1] - cv[y0 * cw + x0]) * tx;\n const b = cv[y1 * cw + x0] + (cv[y1 * cw + x1] - cv[y1 * cw + x0]) * tx;\n v[y * w + x] = a + (b - a) * ty;\n }\n }\n sor(w, h, unknown, v, FINE_ITERS, FINE_OMEGA);\n } else {\n const mean = knownSum / nKnown;\n for (let i = 0; i < v.length; i++) if (unknown[i]) v[i] = mean;\n sor(w, h, unknown, v, 2000, 1.85);\n }\n}\n\n/** Over-relaxed Gauss-Seidel sweeps over the unknown cells until the largest update is below `TOL`. */\nfunction sor(w: number, h: number, unknown: Uint8Array, v: Float32Array, maxIter: number, omega: number): void {\n let n = 0;\n for (let i = 0; i < unknown.length; i++) if (unknown[i]) n++;\n const cells = new Uint32Array(n);\n const masks = new Uint8Array(n);\n for (let i = 0, k = 0; i < unknown.length; i++) {\n if (!unknown[i]) continue;\n const x = i % w;\n const y = (i - x) / w;\n cells[k] = i;\n masks[k++] = (x > 0 ? 1 : 0) | (x + 1 < w ? 2 : 0) | (y > 0 ? 4 : 0) | (y + 1 < h ? 8 : 0);\n }\n for (let it = 0; it < maxIter; it++) {\n let maxD = 0;\n for (let k = 0; k < n; k++) {\n const i = cells[k];\n const m = masks[k];\n let s: number;\n let c: number;\n if (m === 15) {\n s = v[i - 1] + v[i + 1] + v[i - w] + v[i + w];\n c = 4;\n } else {\n s = 0;\n c = 0;\n if (m & 1) (s += v[i - 1]), c++;\n if (m & 2) (s += v[i + 1]), c++;\n if (m & 4) (s += v[i - w]), c++;\n if (m & 8) (s += v[i + w]), c++;\n if (c === 0) continue;\n }\n const d = omega * (s / c - v[i]);\n v[i] += d;\n const ad = d < 0 ? -d : d;\n if (ad > maxD) maxD = ad;\n }\n if (maxD < TOL) break;\n }\n}\n\n/**\n * Seamless cloning: `dst` outside `mask`; inside, `src` plus the membrane that removes the\n * mismatch at the mask's edge. So the result keeps the source's texture and takes the\n * destination's colour and light. `src` and `dst` are interleaved `w × h × ch`; leave a one-pixel\n * unmasked margin for a fully fixed boundary.\n */\nexport function seamlessClone(w: number, h: number, ch: number, src: ArrayLike<number>, dst: ArrayLike<number>, mask: ArrayLike<boolean | number>): Float32Array {\n const n = w * h;\n if (src.length !== n * ch || dst.length !== n * ch || mask.length !== n) throw new RangeError('seamlessClone: src, dst and mask must cover w × h pixels.');\n const out = new Float32Array(n * ch);\n const hv = new Float32Array(n);\n for (let c = 0; c < ch; c++) {\n for (let i = 0; i < n; i++) hv[i] = mask[i] ? 0 : dst[i * ch + c] - src[i * ch + c];\n solveMembrane(w, h, mask, hv);\n for (let i = 0; i < n; i++) out[i * ch + c] = mask[i] ? src[i * ch + c] + hv[i] : dst[i * ch + c];\n }\n return out;\n}\n\n/** Membrane fill (no source texture): the known pixels interpolated smoothly into `hole`. */\nexport function membraneFill(w: number, h: number, ch: number, img: ArrayLike<number>, hole: ArrayLike<boolean | number>): Float32Array {\n const n = w * h;\n const out = new Float32Array(n * ch);\n const v = new Float32Array(n);\n for (let c = 0; c < ch; c++) {\n for (let i = 0; i < n; i++) v[i] = hole[i] ? 0 : img[i * ch + c];\n solveMembrane(w, h, hole, v);\n for (let i = 0; i < n; i++) out[i * ch + c] = v[i];\n }\n return out;\n}\n\n/** A mask grown by `r` pixels (square structuring element). */\nexport function dilateMask(w: number, h: number, mask: ArrayLike<boolean | number>, r: number): Uint8Array {\n const tmp = new Uint8Array(w * h);\n for (let y = 0; y < h; y++) {\n for (let x = 0; x < w; x++) {\n if (!mask[y * w + x]) continue;\n for (let xx = Math.max(0, x - r); xx <= Math.min(w - 1, x + r); xx++) tmp[y * w + xx] = 1;\n }\n }\n const out = new Uint8Array(w * h);\n for (let y = 0; y < h; y++) {\n for (let x = 0; x < w; x++) {\n if (!tmp[y * w + x]) continue;\n for (let yy = Math.max(0, y - r); yy <= Math.min(h - 1, y + r); yy++) out[yy * w + x] = 1;\n }\n }\n return out;\n}\n\n/** A summed-area table over a mask, for \"how many masked cells in this window\". */\nclass MaskIntegral {\n private readonly s: Uint32Array;\n constructor(\n private readonly w: number,\n private readonly h: number,\n mask: ArrayLike<boolean | number>\n ) {\n const W = w + 1;\n this.s = new Uint32Array(W * (h + 1));\n for (let y = 0; y < h; y++) {\n let row = 0;\n for (let x = 0; x < w; x++) {\n row += mask[y * w + x] ? 1 : 0;\n this.s[(y + 1) * W + x + 1] = this.s[y * W + x + 1] + row;\n }\n }\n }\n /** Masked cells in [x0, x1) × [y0, y1) (clipped to the grid). */\n count(x0: number, y0: number, x1: number, y1: number): number {\n const W = this.w + 1;\n const a = Math.max(0, Math.min(this.w, x0));\n const b = Math.max(0, Math.min(this.h, y0));\n const c = Math.max(0, Math.min(this.w, x1));\n const d = Math.max(0, Math.min(this.h, y1));\n if (c <= a || d <= b) return 0;\n return this.s[d * W + c] - this.s[b * W + c] - this.s[d * W + a] + this.s[b * W + a];\n }\n}\n\n/** Bounding box [x0, y0, x1, y1) of the set cells, or null. */\nexport function maskBounds(w: number, h: number, mask: ArrayLike<boolean | number>): [number, number, number, number] | null {\n let x0 = w;\n let y0 = h;\n let x1 = -1;\n let y1 = -1;\n for (let y = 0; y < h; y++) {\n for (let x = 0; x < w; x++) {\n if (!mask[y * w + x]) continue;\n if (x < x0) x0 = x;\n if (x > x1) x1 = x;\n if (y < y0) y0 = y;\n if (y > y1) y1 = y;\n }\n }\n return x1 < 0 ? null : [x0, y0, x1 + 1, y1 + 1];\n}\n\n/**\n * Proximity match: the translation `(dx, dy)` (within `maxRadius`) whose pixels best match the\n * ring of `ring` pixels around the hole (sum of squared differences), so `img[p + (dx, dy)]` can\n * fill `p` in the hole. The source window must lie on the grid and hold no hole pixels. Nearer\n * sources win ties. Returns null when no translation fits.\n */\nexport function bestOffset(w: number, h: number, ch: number, img: ArrayLike<number>, hole: ArrayLike<boolean | number>, ring: number, maxRadius: number): [number, number] | null {\n const bb = maskBounds(w, h, hole);\n if (!bb) return null;\n const extent = Math.max(w, h);\n const R = Math.max(0, Math.min(extent, Math.floor(maxRadius)));\n if (R === 0) return null;\n const rg = Math.max(1, Math.min(extent, Math.floor(ring)));\n const hs = new MaskIntegral(w, h, hole);\n const x0 = bb[0] - rg;\n const y0 = bb[1] - rg;\n const x1 = bb[2] + rg;\n const y1 = bb[3] + rg;\n // Sample points: the ring around the hole, subsampled to about 2000.\n const pts: number[] = [];\n for (let y = Math.max(0, y0); y < Math.min(h, y1); y++) {\n for (let x = Math.max(0, x0); x < Math.min(w, x1); x++) {\n if (hole[y * w + x]) continue;\n if (hs.count(x - rg, y - rg, x + rg + 1, y + rg + 1) > 0) pts.push(x, y);\n }\n }\n const stride = Math.max(1, Math.floor(pts.length / 2 / 2000));\n const sx: number[] = [];\n const sy: number[] = [];\n for (let i = 0; i < pts.length; i += 2 * stride) {\n sx.push(pts[i]);\n sy.push(pts[i + 1]);\n }\n const n = Math.max(1, sx.length);\n const evalAt = (dx: number, dy: number, cutoff: number): number | null => {\n if (dx === 0 && dy === 0) return null;\n const hx0 = x0 + dx;\n const hy0 = y0 + dy;\n const hx1 = x1 + dx;\n const hy1 = y1 + dy;\n if (hx0 < 0 || hy0 < 0 || hx1 > w || hy1 > h) return null;\n if (hs.count(hx0, hy0, hx1, hy1) !== 0) return null;\n const penalty = 1 + 1e-3 * (Math.hypot(dx, dy) / R);\n let e = 0;\n for (let i = 0; i < sx.length; i++) {\n const a = (sy[i] * w + sx[i]) * ch;\n const b = ((sy[i] + dy) * w + sx[i] + dx) * ch;\n for (let c = 0; c < ch; c++) {\n const d = img[a + c] - img[b + c];\n e += d * d;\n }\n if ((i & 31) === 31 && (e / n) * penalty >= cutoff) return null;\n }\n return (e / n) * penalty;\n };\n const found: { best: [number, number] | null; e: number } = { best: null, e: Infinity };\n const consider = (dx: number, dy: number) => {\n const e = evalAt(dx, dy, found.e);\n if (e !== null && e < found.e) {\n found.e = e;\n found.best = [dx, dy];\n }\n };\n // A coarse grid over the search window, then every offset around the winner.\n const step = Math.max(1, Math.floor(R / 24));\n for (let dy = -R; dy <= R; dy += step) for (let dx = -R; dx <= R; dx += step) consider(dx, dy);\n if (step > 1 && found.best) {\n const [bx, by] = found.best;\n for (let dy = by - step; dy <= by + step; dy++) for (let dx = bx - step; dx <= bx + step; dx++) consider(dx, dy);\n }\n return found.best;\n}\n","// Portions ported from photocraft/crates/paint/src/retouch.rs, crates/algo/src/retouch.rs and crates/engine/src/retouch_cmds.rs (MIT OR Apache-2.0, © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.\n\n/**\n * The retouching tools on the shared brush engine: Clone Stamp, Healing Brush, Spot Healing\n * Brush, Smudge, Dodge, Burn and Sponge. Two stroke shapes cover them all:\n *\n * - **Accumulate, then composite** (Clone Stamp, Dodge, Burn; the Healing tools' result): the\n * stroke's dabs build up one `CoverageMap` (flow builds towards the dab's opacity ceiling), and\n * per-pixel paint taken from the pre-stroke state (a cloned source, a toned copy of the pixel,\n * a healed patch) is composited through it with `applyRetouchToTile`. Pixels painted earlier in\n * the stroke are never sampled again, and overlapping dabs never exceed the stroke's opacity.\n * - **Sequential dabs** (Smudge, Sponge): `RetouchDabStroke` runs each dab in order over live\n * tiles, so dab n sees what dab n − 1 did.\n *\n * The Healing Brush clones while it is drawn and, when the stroke ends, replaces the clone with a\n * seamless clone (`healPixels`, Poisson blending): the source's texture with the colour and light\n * of the pixels around the stroke. The Spot Healing Brush finds its own source (`spotHealPixels`).\n *\n * Tone curves (`dodgeBurnCurve`, `dodgeBurn`, `sponge`) are photocraft's, made to behave like\n * Photoshop's tools: the chosen range moves most, black and white stay put for midtones, and\n * Protect Tones works on luma so hue and saturation are kept. Data in, pixels out; no DOM.\n */\n\nimport { blendPixel, type BlendMode } from '../raster/blend';\nimport type { RasterRect } from '../raster/surface';\nimport { TILE, tileKey } from '../raster/surface';\nimport { srgbDecode, srgbEncode } from '../raster/deep';\nimport { DabWalker, dabRect, rasterizeDab, type BrushSettings, type CoverageMap, type Dab, type StrokePoint } from './brush';\nimport { SmudgeTip, type SmudgeSettings } from './blending';\nimport { TileMedium, type PaintTileTarget } from './exchange';\nimport { bestOffset, dilateMask, maskBounds, membraneFill, seamlessClone } from './heal';\n\n// ---------------------------------------------------------------------------\n// Tone kernels\n// ---------------------------------------------------------------------------\n\n/** The tonal range Dodge and Burn work on most. */\nexport type ToneRange = 'shadows' | 'midtones' | 'highlights';\n\nexport const TONE_RANGES: readonly ToneRange[] = ['shadows', 'midtones', 'highlights'];\n\n/** Rec. 601 luma of straight RGB (0..1). */\nexport function luma(r: number, g: number, b: number): number {\n return 0.299 * r + 0.587 * g + 0.114 * b;\n}\n\n/** The dodge (or burn) transfer of one value `v` (0..1) at exposure `e` (0..1). */\nexport function dodgeBurnCurve(v: number, e: number, range: ToneRange, burn: boolean): number {\n const x = Math.max(0, v);\n const k = Math.min(1, Math.max(0, e));\n const c = Math.min(1, x);\n if (range === 'midtones') {\n // A gamma bend weighted to peak at mid-grey: 0 and 1 stay where they are.\n const w = Math.min(1, Math.max(0, 4 * x * (1 - x)));\n return x + w * (Math.pow(c, burn ? 1 + k : 1 / (1 + k)) - x);\n }\n // Shadows / highlights: `v + e·w·(target − v)`, weighted (1 − v)² or v², so that end moves most.\n const w = range === 'shadows' ? (1 - c) * (1 - c) : c * c;\n return burn ? x - k * w * x : x + k * w * (1 - c);\n}\n\n/** Brings RGB back into 0..1 keeping its luma (mixing towards grey) rather than clipping each channel. */\nfunction compressGamut(c: number[], l: number): void {\n const L = Math.min(1, Math.max(0, l));\n const lo = Math.min(c[0], c[1], c[2]);\n const hi = Math.max(c[0], c[1], c[2]);\n let t = 1;\n if (hi > 1 && hi - L > 1e-9) t = Math.min(t, (1 - L) / (hi - L));\n if (lo < 0 && L - lo > 1e-9) t = Math.min(t, L / (L - lo));\n for (let i = 0; i < 3; i++) c[i] = L + (c[i] - L) * t;\n}\n\n/**\n * Dodge (or burn) straight RGB `c` (0..1, written in place) at exposure `e`. With `protectTones`\n * the curve moves luma and the colour is scaled to it (hue and saturation kept); otherwise each\n * channel goes through the curve.\n */\nexport function dodgeBurn(c: number[], e: number, range: ToneRange, burn: boolean, protectTones: boolean): number[] {\n if (!(e > 0)) return c;\n if (protectTones) {\n const l = luma(c[0], c[1], c[2]);\n const nl = dodgeBurnCurve(l, e, range, burn);\n if (l > 1e-6) for (let i = 0; i < 3; i++) c[i] *= nl / l;\n else c[0] = c[1] = c[2] = nl;\n compressGamut(c, nl);\n } else for (let i = 0; i < 3; i++) c[i] = dodgeBurnCurve(c[i], e, range, burn);\n return c;\n}\n\n/** HSV saturation (chroma / max) of straight RGB. */\nexport function saturationOf(r: number, g: number, b: number): number {\n const lo = Math.min(r, g, b);\n const hi = Math.max(r, g, b);\n return hi <= 1e-6 ? 0 : Math.min(1, Math.max(0, (hi - lo) / hi));\n}\n\n/**\n * Sponge: moves straight RGB `c` (written in place) away from (`saturate`) or towards its luma\n * grey by `amount` (0..1). `vibrance` damps it where it would clip: saturating touches already\n * saturated colours less, desaturating touches near-greys less. Gamut-compressed, never clipped.\n */\nexport function sponge(c: number[], amount: number, saturate: boolean, vibrance: boolean): number[] {\n let a = Math.min(1, Math.max(0, amount));\n if (!(a > 0)) return c;\n if (vibrance) {\n const s = saturationOf(c[0], c[1], c[2]);\n a *= saturate ? 1 - s : 0.25 + 0.75 * s;\n }\n const l = luma(c[0], c[1], c[2]);\n const k = saturate ? 1 + a : 1 - a;\n for (let i = 0; i < 3; i++) c[i] = l + (c[i] - l) * k;\n compressGamut(c, l);\n return c;\n}\n\n/** Per-dab strength so that one pass over a point totals about `e`, whatever the spacing. */\nexport function perDabStrength(e: number, spacing: number): number {\n return 1 - Math.pow(1 - Math.min(1, Math.max(0, e)), Math.min(1, Math.max(0.01, spacing)));\n}\n\n// ---------------------------------------------------------------------------\n// Settings\n// ---------------------------------------------------------------------------\n\n/** Which pixels the Clone Stamp and the Healing tools sample. */\nexport type RetouchSample = 'current' | 'current-below' | 'all';\n\nexport const RETOUCH_SAMPLES: readonly RetouchSample[] = ['current', 'current-below', 'all'];\n\n/** How the Spot Healing Brush finds its source. */\nexport type SpotHealType = 'proximity-match' | 'smooth';\n\nexport const SPOT_HEAL_TYPES: readonly SpotHealType[] = ['proximity-match', 'smooth'];\n\n/** The retouching tools' options. */\nexport interface RetouchSettings {\n /** Clone / heal: keep the source offset from stroke to stroke (default true); off, every stroke starts at the source point. */\n aligned: boolean;\n /** Clone / heal / spot heal: what is sampled (default `current`: the target layer). */\n sample: RetouchSample;\n /** Spot heal: `proximity-match` (default: the best matching patch nearby) or `smooth` (a smooth fill from the edges). */\n spotType: SpotHealType;\n /** Dodge / burn: the tonal range (default `midtones`). */\n range: ToneRange;\n /** Dodge / burn: exposure 0..1 (default 0.5). */\n exposure: number;\n /** Dodge / burn: tone luma only, keeping hue and saturation (default true). */\n protectTones: boolean;\n /** Sponge: `desaturate` (default) or `saturate`. */\n spongeMode: 'desaturate' | 'saturate';\n /** Sponge: damp the change where colours would clip (default true). */\n vibrance: boolean;\n /** Smudge: how strongly the finger carries and lays paint, 0..1 (default 0.5). */\n strength: number;\n}\n\nexport const DEFAULT_RETOUCH: Readonly<RetouchSettings> = {\n aligned: true,\n sample: 'current',\n spotType: 'proximity-match',\n range: 'midtones',\n exposure: 0.5,\n protectTones: true,\n spongeMode: 'desaturate',\n vibrance: true,\n strength: 0.5,\n};\n\n/** Retouch settings with every field valid (missing or invalid fields from `base`). */\nexport function normalizeRetouch(raw: Partial<RetouchSettings> = {}, base: RetouchSettings = DEFAULT_RETOUCH): RetouchSettings {\n const unit = (v: unknown, d: number) => (typeof v === 'number' && Number.isFinite(v) ? Math.min(1, Math.max(0, v)) : d);\n const bool = (v: unknown, d: boolean) => (typeof v === 'boolean' ? v : d);\n const pick = <T extends string>(v: unknown, all: readonly T[], d: T): T => (all.includes(v as T) ? (v as T) : d);\n return {\n aligned: bool(raw.aligned, base.aligned),\n sample: pick(raw.sample, RETOUCH_SAMPLES, base.sample),\n spotType: pick(raw.spotType, SPOT_HEAL_TYPES, base.spotType),\n range: pick(raw.range, TONE_RANGES, base.range),\n exposure: unit(raw.exposure, base.exposure),\n protectTones: bool(raw.protectTones, base.protectTones),\n spongeMode: pick(raw.spongeMode, ['desaturate', 'saturate'] as const, base.spongeMode),\n vibrance: bool(raw.vibrance, base.vibrance),\n strength: unit(raw.strength, base.strength),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Pixel sources\n// ---------------------------------------------------------------------------\n\n/** Pixels a retouching stroke samples, by document pixel. */\nexport interface PixelSource {\n /** Straight RGBA 0..255 of document pixel (x, y) into `out`; false (and `out` zeroed) where there is nothing. */\n sample(x: number, y: number, out: number[]): boolean;\n}\n\n/**\n * A source over raster tiles (layer pixels, a mask, or composite tiles): `readTile` gives tile\n * (tx, ty) in source space or `null` when it is empty; source pixel = document pixel − `offset`.\n * One-channel tiles read as grey (alpha 255). Tiles are cached, so make one per stroke.\n */\nexport class TilePixelSource implements PixelSource {\n private readonly cache = new Map<number, Uint8ClampedArray | null>();\n private lastKey = NaN;\n private last: Uint8ClampedArray | null = null;\n\n constructor(\n private readonly readTile: (tx: number, ty: number) => Uint8ClampedArray | null,\n readonly channels: 1 | 4,\n readonly offset: { x: number; y: number } = { x: 0, y: 0 }\n ) {}\n\n sample(x: number, y: number, out: number[]): boolean {\n const lx = x - this.offset.x;\n const ly = y - this.offset.y;\n const tx = Math.floor(lx / TILE);\n const ty = Math.floor(ly / TILE);\n const key = tileKey(tx, ty);\n if (key !== this.lastKey) {\n let t = this.cache.get(key);\n if (t === undefined) {\n t = this.readTile(tx, ty);\n this.cache.set(key, t);\n }\n this.last = t;\n this.lastKey = key;\n }\n const t = this.last;\n if (!t) {\n out[0] = out[1] = out[2] = out[3] = 0;\n return false;\n }\n const p = (ly - ty * TILE) * TILE + (lx - tx * TILE);\n if (this.channels === 1) {\n out[0] = out[1] = out[2] = t[p];\n out[3] = 255;\n return true;\n }\n const i = p * 4;\n out[0] = t[i];\n out[1] = t[i + 1];\n out[2] = t[i + 2];\n out[3] = t[i + 3];\n return out[3] > 0;\n }\n}\n\n/** A source over a region of float RGBA pixels (0..255), e.g. a healed patch. */\nexport class RegionPixelSource implements PixelSource {\n constructor(\n readonly rect: RasterRect,\n readonly data: Float32Array\n ) {}\n\n sample(x: number, y: number, out: number[]): boolean {\n const r = this.rect;\n const lx = x - r.x;\n const ly = y - r.y;\n if (lx < 0 || ly < 0 || lx >= r.width || ly >= r.height) {\n out[0] = out[1] = out[2] = out[3] = 0;\n return false;\n }\n const i = (ly * r.width + lx) * 4;\n out[0] = this.data[i];\n out[1] = this.data[i + 1];\n out[2] = this.data[i + 2];\n out[3] = this.data[i + 3];\n return out[3] > 0;\n }\n}\n\n/** `rect` of a source, shifted by (dx, dy), as float RGBA 0..255 (`rect.width × rect.height × 4`). */\nexport function readSourceRegion(source: PixelSource, rect: RasterRect, dx = 0, dy = 0): Float32Array {\n const out = new Float32Array(rect.width * rect.height * 4);\n const px = [0, 0, 0, 0];\n for (let y = 0; y < rect.height; y++) {\n for (let x = 0; x < rect.width; x++) {\n source.sample(rect.x + x + dx, rect.y + y + dy, px);\n const i = (y * rect.width + x) * 4;\n out[i] = px[0];\n out[i + 1] = px[1];\n out[i + 2] = px[2];\n out[i + 3] = px[3];\n }\n }\n return out;\n}\n\n// ---------------------------------------------------------------------------\n// Accumulate, then composite\n// ---------------------------------------------------------------------------\n\n/** What a coverage-based retouching stroke lays through its coverage. */\nexport type RetouchPaint =\n /** Source pixels at document pixel + (dx, dy) (Clone Stamp, a healed patch). */\n | { kind: 'source'; source: PixelSource; dx: number; dy: number }\n /** The target pixel itself, toned (Dodge, Burn): `tone` edits straight RGB 0..1 in place. */\n | { kind: 'tone'; tone: (rgb: number[]) => void }\n /** A flat colour (the Spot Healing Brush's trail while it is drawn), RGBA 0..255. */\n | { kind: 'color'; color: readonly [number, number, number, number] };\n\n/** How a coverage-based retouching stroke composites. */\nexport interface RetouchApply {\n /** Stroke opacity 0..1. */\n opacity: number;\n /** Blend mode for source paint (default normal). */\n blend?: BlendMode;\n lockTransparency: boolean;\n /** Selection coverage (document space, canvas-sized), or `null`. */\n selection: { width: number; height: number; data: ArrayLike<number> } | null;\n /** Layer offset (target pixels are in layer space). */\n offset: { x: number; y: number };\n}\n\n/**\n * Composites `paint` through the stroke's coverage over `tileData` (target tile (tx, ty) as it was\n * before the stroke, layer space; RGBA, or one byte per pixel for masks) and returns the new tile.\n * With `into` (the previous result) and `region` (document space), only `region` is recomputed.\n * Tone paint keeps alpha; source and colour paint composite with `blend` (source-over by\n * default), keeping alpha on a locked layer.\n */\nexport function applyRetouchToTile(\n coverage: CoverageMap,\n tileData: Uint8ClampedArray,\n channels: 1 | 4,\n tx: number,\n ty: number,\n paint: RetouchPaint,\n s: RetouchApply,\n options: { into?: Uint8ClampedArray; region?: RasterRect } = {}\n): Uint8ClampedArray {\n const out = options.into ? new Uint8ClampedArray(options.into) : new Uint8ClampedArray(tileData);\n const ox = tx * TILE + s.offset.x;\n const oy = ty * TILE + s.offset.y;\n let x0 = 0;\n let y0 = 0;\n let x1 = TILE;\n let y1 = TILE;\n if (options.region) {\n const r = options.region;\n x0 = Math.max(0, Math.floor(r.x) - ox);\n y0 = Math.max(0, Math.floor(r.y) - oy);\n x1 = Math.min(TILE, Math.ceil(r.x + r.width) - ox);\n y1 = Math.min(TILE, Math.ceil(r.y + r.height) - oy);\n if (x1 <= x0 || y1 <= y0) return out;\n if (options.into) {\n for (let y = y0; y < y1; y++) out.set(tileData.subarray((y * TILE + x0) * channels, (y * TILE + x1) * channels), (y * TILE + x0) * channels);\n }\n }\n const sel = s.selection;\n const blend = s.blend ?? 'normal';\n const src = [0, 0, 0, 0];\n const rgb = [0, 0, 0];\n const cb = [0, 0, 0, 0];\n const cs = [0, 0, 0, 0];\n // The coverage tile under the pixel, looked up once per tile it crosses.\n let covKey = NaN;\n let covTile: Float32Array | undefined;\n for (let y = y0; y < y1; y++) {\n const dy = oy + y;\n const cty = Math.floor(dy / TILE);\n for (let x = x0; x < x1; x++) {\n const dx = ox + x;\n const ctx = Math.floor(dx / TILE);\n const key = tileKey(ctx, cty);\n if (key !== covKey) {\n covKey = key;\n covTile = coverage.tiles.get(key);\n }\n if (!covTile) continue;\n const c = covTile[(dy - cty * TILE) * TILE + (dx - ctx * TILE)];\n if (c <= 0) continue;\n let k = c * s.opacity;\n if (sel) {\n if (dx < 0 || dy < 0 || dx >= sel.width || dy >= sel.height) continue;\n k *= sel.data[dy * sel.width + dx] / 255;\n }\n if (k > 1) k = 1;\n if (k <= 0) continue;\n const p = y * TILE + x;\n if (channels === 1) {\n // Masks: grey values; the source's grey is its red channel.\n const g = out[p];\n let t: number;\n if (paint.kind === 'tone') {\n rgb[0] = rgb[1] = rgb[2] = g / 255;\n paint.tone(rgb);\n t = luma(rgb[0], rgb[1], rgb[2]) * 255;\n } else if (paint.kind === 'color') t = paint.color[0];\n else {\n if (!paint.source.sample(dx + paint.dx, dy + paint.dy, src)) continue;\n t = src[0];\n k *= src[3] / 255;\n }\n out[p] = Math.round(g + (t - g) * k);\n continue;\n }\n const i = p * 4;\n const a = out[i + 3];\n if (paint.kind === 'tone') {\n if (a === 0) continue;\n rgb[0] = out[i] / 255;\n rgb[1] = out[i + 1] / 255;\n rgb[2] = out[i + 2] / 255;\n const r0 = rgb[0];\n const g0 = rgb[1];\n const b0 = rgb[2];\n paint.tone(rgb);\n out[i] = Math.round((r0 + (rgb[0] - r0) * k) * 255);\n out[i + 1] = Math.round((g0 + (rgb[1] - g0) * k) * 255);\n out[i + 2] = Math.round((b0 + (rgb[2] - b0) * k) * 255);\n continue;\n }\n if (s.lockTransparency && a === 0) continue;\n if (paint.kind === 'color') {\n src[0] = paint.color[0];\n src[1] = paint.color[1];\n src[2] = paint.color[2];\n src[3] = paint.color[3];\n } else if (!paint.source.sample(dx + paint.dx, dy + paint.dy, src)) continue;\n for (let ch = 0; ch < 4; ch++) {\n cb[ch] = out[i + ch] / 255;\n cs[ch] = src[ch] / 255;\n }\n // Source-over, as a brush lays paint: cloning transparency paints nothing.\n const o = blendPixel(blend, cb, cs, k);\n out[i] = Math.round(o[0] * 255);\n out[i + 1] = Math.round(o[1] * 255);\n out[i + 2] = Math.round(o[2] * 255);\n if (!s.lockTransparency) out[i + 3] = Math.round(o[3] * 255);\n }\n }\n return out;\n}\n\n/**\n * Dodge / Burn at 16 or 32 bits: `applyRetouchToTile`'s tone paint on a layer tile's deep samples\n * (`Uint16Array` sRGB-encoded, or `Float32Array` linear light, RGBA). The tone curves work on\n * encoded values as at 8 bits, so 32-bit samples are encoded, toned and decoded (colour above 1 is\n * toned at 1 and keeps its excess). Returns the new samples.\n */\nexport function applyToneToDeepTile(\n coverage: CoverageMap,\n samples: Uint16Array | Float32Array,\n tx: number,\n ty: number,\n tone: (rgb: number[]) => void,\n s: RetouchApply,\n options: { into?: Uint16Array | Float32Array; region?: RasterRect } = {}\n): Uint16Array | Float32Array {\n const linear = samples instanceof Float32Array;\n const out = (options.into ?? samples).slice() as Uint16Array | Float32Array;\n const ox = tx * TILE + s.offset.x;\n const oy = ty * TILE + s.offset.y;\n let x0 = 0;\n let y0 = 0;\n let x1 = TILE;\n let y1 = TILE;\n if (options.region) {\n const r = options.region;\n x0 = Math.max(0, Math.floor(r.x) - ox);\n y0 = Math.max(0, Math.floor(r.y) - oy);\n x1 = Math.min(TILE, Math.ceil(r.x + r.width) - ox);\n y1 = Math.min(TILE, Math.ceil(r.y + r.height) - oy);\n if (x1 <= x0 || y1 <= y0) return out;\n if (options.into) for (let y = y0; y < y1; y++) out.set(samples.subarray((y * TILE + x0) * 4, (y * TILE + x1) * 4), (y * TILE + x0) * 4);\n }\n const sel = s.selection;\n const rgb = [0, 0, 0];\n const before = [0, 0, 0];\n const excess = [0, 0, 0];\n let covKey = NaN;\n let covTile: Float32Array | undefined;\n for (let y = y0; y < y1; y++) {\n const dy = oy + y;\n const cty = Math.floor(dy / TILE);\n for (let x = x0; x < x1; x++) {\n const dx = ox + x;\n const ctx = Math.floor(dx / TILE);\n const key = tileKey(ctx, cty);\n if (key !== covKey) {\n covKey = key;\n covTile = coverage.tiles.get(key);\n }\n if (!covTile) continue;\n const c = covTile[(dy - cty * TILE) * TILE + (dx - ctx * TILE)];\n if (c <= 0) continue;\n let k = c * s.opacity;\n if (sel) {\n if (dx < 0 || dy < 0 || dx >= sel.width || dy >= sel.height) continue;\n k *= sel.data[dy * sel.width + dx] / 255;\n }\n if (k > 1) k = 1;\n if (k <= 0) continue;\n const i = (y * TILE + x) * 4;\n if (out[i + 3] === 0) continue;\n for (let ch = 0; ch < 3; ch++) {\n const v = out[i + ch];\n if (linear) {\n excess[ch] = v > 1 ? v - 1 : 0;\n rgb[ch] = srgbEncode(v > 1 ? 1 : v < 0 ? 0 : v);\n } else rgb[ch] = v / 65535;\n before[ch] = rgb[ch];\n }\n tone(rgb);\n for (let ch = 0; ch < 3; ch++) {\n const e = before[ch] + (rgb[ch] - before[ch]) * k;\n if (linear) out[i + ch] = srgbDecode(e) + excess[ch];\n else out[i + ch] = e <= 0 ? 0 : e >= 1 ? 65535 : Math.round(e * 65535);\n }\n }\n }\n return out;\n}\n\n/** The tone function of a Dodge or Burn stroke. */\nexport function toneOf(tool: 'dodge' | 'burn', settings: Pick<RetouchSettings, 'exposure' | 'range' | 'protectTones'>): (rgb: number[]) => void {\n const burn = tool === 'burn';\n return (rgb) => {\n dodgeBurn(rgb, settings.exposure, settings.range, burn, settings.protectTones);\n };\n}\n\n// ---------------------------------------------------------------------------\n// Healing\n// ---------------------------------------------------------------------------\n\n/**\n * Heals `src` into `dst` over `mask` (all `w × h`, RGBA floats 0..255): a seamless clone solved\n * only over the mask's bounds plus a one-pixel fixed ring; elsewhere the result is `dst`.\n */\nexport function healPixels(w: number, h: number, src: Float32Array, dst: Float32Array, mask: ArrayLike<boolean | number>): Float32Array {\n const out = new Float32Array(dst);\n const bb = maskBounds(w, h, mask);\n if (!bb) return out;\n const x0 = Math.max(0, bb[0] - 1);\n const y0 = Math.max(0, bb[1] - 1);\n const x1 = Math.min(w, bb[2] + 1);\n const y1 = Math.min(h, bb[3] + 1);\n const rw = x1 - x0;\n const rh = y1 - y0;\n const s = new Float32Array(rw * rh * 4);\n const d = new Float32Array(rw * rh * 4);\n const m = new Uint8Array(rw * rh);\n for (let y = 0; y < rh; y++) {\n for (let x = 0; x < rw; x++) {\n const gi = (y + y0) * w + x + x0;\n const li = y * rw + x;\n m[li] = mask[gi] ? 1 : 0;\n for (let c = 0; c < 4; c++) {\n s[li * 4 + c] = src[gi * 4 + c];\n d[li * 4 + c] = dst[gi * 4 + c];\n }\n }\n }\n const healed = seamlessClone(rw, rh, 4, s, d, m);\n for (let y = 0; y < rh; y++) {\n for (let x = 0; x < rw; x++) {\n const gi = ((y + y0) * w + x + x0) * 4;\n const li = (y * rw + x) * 4;\n for (let c = 0; c < 4; c++) out[gi + c] = Math.min(255, Math.max(0, healed[li + c]));\n }\n }\n return out;\n}\n\n/**\n * Spot healing: fills `hole` (`w × h`) of `img` (RGBA floats 0..255) with no given source, then\n * heals the fill into its surroundings. `proximity-match` copies the best matching nearby patch\n * (falling back to `smooth` when none fits); `smooth` interpolates the edges inwards. `size` is\n * the brush diameter in pixels. Returns the healed pixels over the whole grid.\n */\nexport function spotHealPixels(\n w: number,\n h: number,\n img: Float32Array,\n hole: ArrayLike<boolean | number>,\n size: number,\n type: SpotHealType,\n /** Told the patch offset it copied (`null`: a smooth fill). */\n onOffset?: (offset: [number, number] | null) => void\n): Float32Array {\n // Fill a slightly larger domain than the healed area, so the solve's boundary sees filled values\n // that differ from the untouched pixels: that mismatch is what the membrane corrects.\n const domain = dilateMask(w, h, hole, 2);\n const healMask = dilateMask(w, h, hole, 1);\n let filled: Float32Array | null = null;\n let bestFound: [number, number] | null = null;\n if (type === 'proximity-match') {\n const ring = Math.min(16, Math.max(3, Math.floor(size / 8)));\n const off = bestOffset(w, h, 4, img, domain, ring, Math.floor(Math.max(w, h) / 2));\n if (off) {\n bestFound = off;\n // Copy from the pre-healing pixels, never from what this loop already wrote.\n filled = new Float32Array(img);\n const [ddx, ddy] = off;\n for (let i = 0; i < w * h; i++) {\n if (!domain[i]) continue;\n const x = (i % w) + ddx;\n const y = Math.floor(i / w) + ddy;\n const j = (y * w + x) * 4;\n for (let c = 0; c < 4; c++) filled[i * 4 + c] = img[j + c];\n }\n }\n }\n onOffset?.(filled ? (bestFound as [number, number]) : null);\n if (!filled) filled = membraneFill(w, h, 4, img, domain);\n return healPixels(w, h, filled, img, healMask);\n}\n\n/** The window a Spot Healing stroke over `bounds` looks for texture in: the bounds grown by their size, on the canvas. */\nexport function spotHealWindow(bounds: RasterRect, canvas: { width: number; height: number }): RasterRect {\n const g = Math.max(8, Math.ceil(Math.max(bounds.width, bounds.height)));\n const x0 = Math.max(0, bounds.x - g);\n const y0 = Math.max(0, bounds.y - g);\n const x1 = Math.min(canvas.width, bounds.x + bounds.width + g);\n const y1 = Math.min(canvas.height, bounds.y + bounds.height + g);\n return { x: x0, y: y0, width: Math.max(0, x1 - x0), height: Math.max(0, y1 - y0) };\n}\n\n// ---------------------------------------------------------------------------\n// Sequential dabs\n// ---------------------------------------------------------------------------\n\n/**\n * One dab of a sequential retouching stroke: `cov` is the tip's pure coverage over `rect`\n * (document space, 0..1); `d.alpha` is the flow and `d.opacity` the pressure opacity.\n */\nexport type RetouchDabEffect = (medium: TileMedium, d: Dab, rect: RasterRect, cov: Float32Array) => void;\n\n/**\n * A stroke whose dabs edit live tiles in order (Smudge, Sponge). Feed points with `push` (any\n * chunks give the same dabs), end with `finish`; each returns the document rectangles it touched.\n */\nexport class RetouchDabStroke {\n dabCount = 0;\n bounds: RasterRect | null = null;\n private readonly walker: DabWalker;\n private readonly medium: TileMedium;\n private smoothPos: StrokePoint | null = null;\n private buf = new Float32Array(0);\n\n constructor(\n readonly brush: BrushSettings,\n target: PaintTileTarget,\n private readonly effect: RetouchDabEffect\n ) {\n this.walker = new DabWalker(brush);\n this.medium = new TileMedium(target);\n }\n\n push(points: readonly StrokePoint[]): RasterRect[] {\n const dabs: Dab[] = [];\n for (const p of points) this.walker.push(this.smooth(p), dabs);\n return this.paint(dabs);\n }\n\n finish(last?: StrokePoint): RasterRect[] {\n const dabs: Dab[] = [];\n if (last && this.smoothPos && (this.smoothPos.x !== last.x || this.smoothPos.y !== last.y)) this.walker.push(last, dabs);\n this.walker.finish(dabs);\n return this.paint(dabs);\n }\n\n private smooth(p: StrokePoint): StrokePoint {\n const a = 1 - Math.min(0.95, Math.max(0, this.brush.smoothing));\n const cur = this.smoothPos;\n const n = cur && a < 1 ? { ...p, x: cur.x + (p.x - cur.x) * a, y: cur.y + (p.y - cur.y) * a } : p;\n this.smoothPos = n;\n return n;\n }\n\n private paint(dabs: Dab[]): RasterRect[] {\n const rects: RasterRect[] = [];\n for (const d of dabs) {\n const rect = dabRect(d, this.brush.hardness);\n const n = rect.width * rect.height;\n if (this.buf.length < n) this.buf = new Float32Array(n);\n const cov = this.buf.subarray(0, n);\n rasterizeDab({ ...d, alpha: 1 }, this.brush.hardness, rect, cov);\n this.medium.reset();\n this.effect(this.medium, d, rect, cov);\n rects.push(rect);\n this.bounds = unionRect(this.bounds, rect);\n this.dabCount++;\n }\n return rects;\n }\n}\n\n/** The Smudge's per-dab effect: a `SmudgeTip` whose strength carries and lays the paint. */\nexport function smudgeEffect(brush: BrushSettings, strength: number, mixing: SmudgeSettings['mixing'] = 'rgb'): RetouchDabEffect {\n const s = Math.min(1, Math.max(0, strength));\n const tip = new SmudgeTip({ strength: s, length: s, mixing }, brush.size);\n return (medium, d, rect, cov) => tip.dab(medium, { x: d.x, y: d.y, radius: d.radius, opacity: d.opacity * d.alpha }, rect, cov);\n}\n\n/** The Sponge's per-dab effect: each dab moves saturation by about half its flow, compounding over passes. */\nexport function spongeEffect(brush: BrushSettings, saturate: boolean, vibrance: boolean): RetouchDabEffect {\n const rgb = [0, 0, 0];\n return (medium, d, rect, cov) => {\n const w = rect.width;\n for (let yy = 0; yy < rect.height; yy++) {\n for (let xx = 0; xx < w; xx++) {\n const cv = cov[yy * w + xx];\n if (cv <= 0) continue;\n const dx = rect.x + xx;\n const dy = rect.y + yy;\n const k = perDabStrength(cv * d.alpha * d.opacity * 0.5, brush.spacing) * medium.selectionAt(dx, dy);\n if (k <= 0) continue;\n const ri = medium.locate(dx, dy, false);\n if (ri < 0 || medium.pixels[ri + 3] === 0) continue;\n const i = medium.locate(dx, dy, true);\n const px = medium.pixels;\n rgb[0] = px[i] / 255;\n rgb[1] = px[i + 1] / 255;\n rgb[2] = px[i + 2] / 255;\n sponge(rgb, k, saturate, vibrance);\n px[i] = Math.round(rgb[0] * 255);\n px[i + 1] = Math.round(rgb[1] * 255);\n px[i + 2] = Math.round(rgb[2] * 255);\n }\n }\n };\n}\n\n/**\n * An RGBA view of one-channel tiles (masks), for the sequential-dab tools: reads expand grey to\n * opaque RGB, writes land in RGBA copies, and `flush` writes their red channel back through\n * `target.writeTile`. Alpha is locked, so a mask's values are all a dab changes.\n */\nexport function rgbaViewOfGrey(target: PaintTileTarget): { target: PaintTileTarget; flush(): void } {\n const views = new Map<number, Uint8ClampedArray>();\n const dirty = new Map<number, { tx: number; ty: number; data: Uint8ClampedArray }>();\n const expand = (g: Uint8ClampedArray) => {\n const out = new Uint8ClampedArray(g.length * 4);\n for (let i = 0; i < g.length; i++) {\n out[i * 4] = out[i * 4 + 1] = out[i * 4 + 2] = g[i];\n out[i * 4 + 3] = 255;\n }\n return out;\n };\n const view: PaintTileTarget = {\n offset: target.offset,\n lockTransparency: true,\n selection: target.selection,\n readTile: (tx, ty) => {\n const key = tileKey(tx, ty);\n let v = views.get(key);\n if (!v) {\n // An empty mask tile is still values (0), not transparency: always give a tile.\n v = expand(target.readTile(tx, ty) ?? new Uint8ClampedArray(TILE * TILE));\n views.set(key, v);\n }\n return v;\n },\n writeTile: (tx, ty) => {\n const key = tileKey(tx, ty);\n let v = views.get(key);\n if (!v) {\n v = expand(target.readTile(tx, ty) ?? new Uint8ClampedArray(TILE * TILE));\n views.set(key, v);\n }\n dirty.set(key, { tx, ty, data: v });\n return v;\n },\n };\n return {\n target: view,\n flush: () => {\n for (const { tx, ty, data } of dirty.values()) {\n const g = target.writeTile(tx, ty);\n for (let i = 0; i < g.length; i++) g[i] = data[i * 4];\n }\n dirty.clear();\n },\n };\n}\n\nfunction unionRect(a: RasterRect | null, b: RasterRect): RasterRect {\n if (!a) return { ...b };\n const x = Math.min(a.x, b.x);\n const y = Math.min(a.y, b.y);\n return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };\n}\n","/**\n * A brush stroke along a path: polyline samples, each with an optional pressure and pen tilt, are\n * walked at the brush's spacing (pressure and tilt interpolated between samples) into dabs, built\n * up in a coverage map and composited onto a layer. This is what a vector editor calls to draw a\n * path with a natural-media brush (\"brushstrokes on vector paths\"): the path is the data, the\n * pixels are rendered from it.\n *\n * - Pressure scales size and / or opacity as the brush says.\n * - Tilt (`tiltX` / `tiltY` in degrees, or `altitude` / `azimuth` in radians, as Pointer Events give\n * them) widens the tip (`tilt.size`), flattens it along the lean (`tilt.roundness`), and with\n * `tilt.followAzimuth` turns the tip to the lean, as a pen laid on its side does.\n * - With `followPath` the tip turns with the path (a calligraphic nib along a curve).\n *\n * Deterministic and DOM-free: the same samples and brush give the same pixels everywhere.\n */\n\nimport { applyStrokeToTile, CoverageMap, dabRect, normalizeBrush, rasterizeDab, type BrushSettings, type Dab } from './brush';\nimport { TiledSurface, finishTile, tileKey, tilesInRect, TILE, type RasterRect } from '../raster/surface';\nimport type { BlendMode } from '../raster/blend';\n\n/** One sample of the path (document pixels). */\nexport interface PathSample {\n x: number;\n y: number;\n /** 0..1 (default 1). */\n pressure?: number;\n /** Pointer Events tilt in degrees (−90..90). */\n tiltX?: number;\n tiltY?: number;\n /** Radians above the surface (π/2 upright); overrides tiltX / tiltY. */\n altitude?: number;\n /** Radians clockwise from +x: where the pen leans (with altitude). */\n azimuth?: number;\n}\n\nexport interface PathStrokeOptions {\n brush: Partial<BrushSettings>;\n /** How tilt shapes the tip (each 0..1; default none). */\n tilt?: { size?: number; roundness?: number; followAzimuth?: boolean };\n /** Turn the tip with the direction of the path (added to the brush angle). */\n followPath?: boolean;\n /** Size at zero pressure as a fraction of the full size, when pressure controls size (default 0). */\n minSize?: number;\n /** Join the last sample back to the first. */\n closed?: boolean;\n}\n\n/** A pen's lean from a sample: 0 upright .. 1 flat, and the direction it leans (radians, clockwise from +x). */\nfunction lean(s: PathSample): { amount: number; azimuth: number } | null {\n if (typeof s.altitude === 'number' && Number.isFinite(s.altitude)) {\n return { amount: 1 - Math.min(1, Math.max(0, s.altitude / (Math.PI / 2))), azimuth: s.azimuth ?? 0 };\n }\n if (typeof s.tiltX === 'number' || typeof s.tiltY === 'number') {\n const tx = ((s.tiltX ?? 0) * Math.PI) / 180;\n const ty = ((s.tiltY ?? 0) * Math.PI) / 180;\n if (tx === 0 && ty === 0) return { amount: 0, azimuth: 0 };\n const az = Math.atan2(Math.tan(ty), Math.tan(tx));\n const alt = Math.atan(1 / Math.hypot(Math.tan(tx), Math.tan(ty)));\n return { amount: 1 - alt / (Math.PI / 2), azimuth: az };\n }\n return null;\n}\n\n/** The dabs of a brush stroke along `samples`, with pressure and tilt interpolated between them. */\nexport function pathStrokeDabs(samples: readonly PathSample[], options: PathStrokeOptions): Dab[] {\n const brush = normalizeBrush(options.brush);\n const pts = options.closed && samples.length > 2 ? [...samples, samples[0]] : [...samples];\n if (!pts.length) return [];\n const tilt = options.tilt ?? {};\n const minSize = Math.min(1, Math.max(0, options.minSize ?? 0));\n const dab = (x: number, y: number, p: number, l: { amount: number; azimuth: number } | null, dir: number): Dab => {\n const pr = Math.min(1, Math.max(0, p));\n const lean0 = l?.amount ?? 0;\n const size = brush.size * (brush.pressureSize ? minSize + (1 - minSize) * pr : 1) * (1 + 1.5 * (tilt.size ?? 0) * lean0);\n let angle = (brush.angle * Math.PI) / 180;\n if (options.followPath) angle += dir;\n if (tilt.followAzimuth && l) angle = -l.azimuth;\n const roundness = Math.max(0.05, brush.roundness * (1 - 0.85 * (tilt.roundness ?? 0) * lean0));\n const op = brush.pressureOpacity ? pr : 1;\n return { x, y, radius: Math.max(0.5, size / 2), alpha: brush.flow, opacity: brush.opacity * op, angle, roundness };\n };\n const out: Dab[] = [];\n const pressure = (s: PathSample) => (typeof s.pressure === 'number' && Number.isFinite(s.pressure) ? s.pressure : 1);\n if (pts.length === 1) {\n out.push(dab(pts[0].x, pts[0].y, pressure(pts[0]), lean(pts[0]), 0));\n return out;\n }\n let carry = 0;\n 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)));\n for (let i = 0; i + 1 < pts.length; i++) {\n const a = pts[i];\n const b = pts[i + 1];\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const len = Math.hypot(dx, dy);\n if (len === 0) continue;\n // Dab angles are counter-clockwise with y up, as the shared rasterizer reads them.\n const dir = Math.atan2(-dy, dx);\n const la = lean(a);\n const lb = lean(b);\n let t = carry;\n for (;;) {\n const f = t / len;\n if (f > 1) break;\n const p = pressure(a) + (pressure(b) - pressure(a)) * f;\n const l = la && lb ? { amount: la.amount + (lb.amount - la.amount) * f, azimuth: la.azimuth + (lb.azimuth - la.azimuth) * f } : (la ?? lb);\n const size = brush.size * (brush.pressureSize ? minSize + (1 - minSize) * p : 1);\n const step = Math.max(0.5, size * brush.spacing);\n if (t > 0 || i > 0) out.push(dab(a.x + dx * f, a.y + dy * f, p, l, dir));\n t += step;\n }\n carry = t - len;\n }\n return out;\n}\n\n/** The coverage of a brush stroke along `samples` (build-up towards each dab's opacity) and its bounds. */\nexport function pathStrokeCoverage(samples: readonly PathSample[], options: PathStrokeOptions): { coverage: CoverageMap; bounds: RasterRect | null; dabs: number } {\n const brush = normalizeBrush(options.brush);\n const coverage = new CoverageMap();\n const dabs = pathStrokeDabs(samples, options);\n let buf = new Float32Array(0);\n let bounds: RasterRect | null = null;\n for (const d of dabs) {\n const rect = dabRect(d, brush.hardness);\n const n = rect.width * rect.height;\n if (n <= 0) continue;\n if (buf.length < n) buf = new Float32Array(n);\n const vals = buf.subarray(0, n);\n rasterizeDab(d, brush.hardness, rect, vals);\n coverage.accumulate(rect, vals, d.opacity);\n if (!bounds) bounds = { ...rect };\n else {\n const x = Math.min(bounds.x, rect.x);\n const y = Math.min(bounds.y, rect.y);\n 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 };\n }\n }\n return { coverage, bounds, dabs: dabs.length };\n}\n\nexport interface PaintPathOptions extends PathStrokeOptions {\n /** RGBA 0..255 of the paint. */\n color: readonly [number, number, number, number];\n /** `erase` removes paint instead (default `paint`). */\n mode?: 'paint' | 'erase';\n /** Blend mode (default the brush's). */\n blend?: BlendMode;\n /** Layer offset: layer pixel = document pixel − offset (default 0, 0). */\n offset?: { x: number; y: number };\n lockTransparency?: boolean;\n /** Where paint may land (canvas-sized coverage 0..255), or none. */\n selection?: { width: number; height: number; data: ArrayLike<number> } | null;\n}\n\n/**\n * Paints a brush stroke along `samples` onto an RGBA layer surface and returns the new surface\n * (the input is not changed; untouched tiles are shared) with the bounds it touched.\n */\nexport function paintPathStroke(surface: TiledSurface, samples: readonly PathSample[], options: PaintPathOptions): { surface: TiledSurface; bounds: RasterRect | null; dabs: number } {\n if (surface.channels !== 4) throw new Error('paintPathStroke paints RGBA surfaces (4 channels).');\n const brush = normalizeBrush(options.brush);\n const { coverage, bounds, dabs } = pathStrokeCoverage(samples, options);\n if (!bounds) return { surface, bounds: null, dabs };\n const offset = options.offset ?? { x: 0, y: 0 };\n const apply = {\n mode: options.mode ?? 'paint',\n color: options.color,\n background: [0, 0, 0, 0] as const,\n opacity: brush.opacity,\n blend: options.blend ?? brush.blend,\n lockTransparency: options.lockTransparency ?? false,\n selection: options.selection ?? null,\n offset,\n };\n const tiles = new Map(surface.tiles);\n for (const { tx, ty } of tilesInRect({ x: bounds.x - offset.x, y: bounds.y - offset.y, width: bounds.width, height: bounds.height })) {\n const key = tileKey(tx, ty);\n const src = surface.tiles.get(key)?.data;\n const base = src && src.length === TILE * TILE * 4 ? src : new Uint8ClampedArray(TILE * TILE * 4);\n const t = finishTile(applyStrokeToTile(coverage, base, 4, tx, ty, apply), 4, surface.defaultValue);\n if (t) tiles.set(key, t);\n else tiles.delete(key);\n }\n return { surface: new TiledSurface(4, tiles, surface.defaultValue), bounds, dabs };\n}\n"]}
|