@pixerate/editor 0.259.0 → 0.260.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.
Files changed (74) hide show
  1. package/dist/agent/index.cjs +2 -2
  2. package/dist/agent/index.js +1 -1
  3. package/dist/animation-editor/index.cjs +61 -59
  4. package/dist/animation-editor/index.js +5 -3
  5. package/dist/brushes/index.cjs +52 -52
  6. package/dist/brushes/index.js +6 -6
  7. package/dist/{brushstrokeRender-JI4W6F2G.js → brushstrokeRender-25Q5BEY6.js} +17 -7
  8. package/dist/{brushstrokeRender-MQ6PSDM5.cjs → brushstrokeRender-N6UPZSQS.cjs} +31 -21
  9. package/dist/canvas/brushTypes.d.cts +5 -0
  10. package/dist/canvas/brushTypes.d.ts +5 -0
  11. package/dist/canvas/drawController.d.cts +15 -1
  12. package/dist/canvas/drawController.d.ts +15 -1
  13. package/dist/canvas/index.cjs +136 -102
  14. package/dist/canvas/index.js +35 -1
  15. package/dist/{chunk-3PPJRMIG.js → chunk-3O47TPGX.js} +197 -18
  16. package/dist/{chunk-5Q5MLXAD.cjs → chunk-3TQW5MPW.cjs} +23 -23
  17. package/dist/{chunk-JBBJE76O.cjs → chunk-3ZRNK3RO.cjs} +1138 -85
  18. package/dist/{chunk-YSGW7VV4.cjs → chunk-43NT242D.cjs} +1401 -228
  19. package/dist/{chunk-SMTUQWGY.js → chunk-5IW65VQ6.js} +1 -1
  20. package/dist/{chunk-YQ4PQTBB.js → chunk-6NZL24W4.js} +9 -1
  21. package/dist/{chunk-O3ZVZSNJ.cjs → chunk-7AUQ2UJ3.cjs} +137 -129
  22. package/dist/{chunk-4M4E3N6X.js → chunk-CQVTGBQI.js} +1 -1
  23. package/dist/{chunk-SSFMWJDK.js → chunk-D4TE5JNW.js} +1192 -19
  24. package/dist/{chunk-AORZ5M5C.js → chunk-EHALWBBD.js} +1 -1
  25. package/dist/{chunk-6WCQ35GI.cjs → chunk-NHA26O5X.cjs} +2 -2
  26. package/dist/{chunk-DPYAO5U6.cjs → chunk-PVJMTLPJ.cjs} +197 -18
  27. package/dist/{chunk-MQGQTKVW.cjs → chunk-PYTJBVW5.cjs} +29 -29
  28. package/dist/{chunk-IXQZHCOF.js → chunk-QAR2N7HZ.js} +1 -1
  29. package/dist/{chunk-5P4JEOIV.js → chunk-TMDDMJCR.js} +2 -2
  30. package/dist/{chunk-RSIKDWOP.cjs → chunk-TZOX7KWV.cjs} +15 -15
  31. package/dist/{chunk-IPUTIUGQ.cjs → chunk-UVZ7RQOE.cjs} +1 -1
  32. package/dist/{chunk-A7GJ6BXI.js → chunk-WJ4WQJCC.js} +1062 -9
  33. package/dist/{chunk-ICTPLVSR.js → chunk-X2EXYY4J.js} +1 -1
  34. package/dist/{chunk-WQCNC4DK.js → chunk-XC6DPRYI.js} +695 -4
  35. package/dist/{chunk-KBYB7OWB.cjs → chunk-YHDHFJUC.cjs} +776 -85
  36. package/dist/{chunk-P3PZ63M3.cjs → chunk-YLUIFXSL.cjs} +35 -35
  37. package/dist/commands/index.cjs +2 -2
  38. package/dist/commands/index.js +1 -1
  39. package/dist/image-editor/index.cjs +1385 -2484
  40. package/dist/image-editor/index.js +139 -1238
  41. package/dist/image-editor/selection-worker.cjs +3 -4
  42. package/dist/image-editor/selection-worker.js +1 -2
  43. package/dist/paint/index.cjs +3 -5
  44. package/dist/paint/index.js +40 -42
  45. package/dist/paint-editor/contract.d.cts +29 -0
  46. package/dist/paint-editor/contract.d.ts +29 -0
  47. package/dist/paint-editor/dab-stroke.d.cts +5 -0
  48. package/dist/paint-editor/dab-stroke.d.ts +5 -0
  49. package/dist/paint-editor/index.cjs +402 -258
  50. package/dist/paint-editor/index.d.cts +1 -0
  51. package/dist/paint-editor/index.d.ts +1 -0
  52. package/dist/paint-editor/index.js +197 -53
  53. package/dist/paint-editor/stamp-tip.d.cts +17 -0
  54. package/dist/paint-editor/stamp-tip.d.ts +17 -0
  55. package/dist/paint-editor/ui.d.cts +21 -1
  56. package/dist/paint-editor/ui.d.ts +21 -1
  57. package/dist/raster/index.cjs +2 -4
  58. package/dist/raster/index.js +6 -8
  59. package/dist/vector/brushstroke.d.cts +6 -0
  60. package/dist/vector/brushstroke.d.ts +6 -0
  61. package/dist/vector/controller.d.cts +11 -2
  62. package/dist/vector/controller.d.ts +11 -2
  63. package/dist/vector/index.cjs +990 -973
  64. package/dist/vector/index.js +28 -11
  65. package/package.json +1 -1
  66. package/skills/pixerate-brushes/SKILL.md +1 -1
  67. package/skills/pixerate-canvas/SKILL.md +3 -1
  68. package/skills/pixerate-vector/SKILL.md +2 -2
  69. package/dist/chunk-2VJAVXLI.js +0 -192
  70. package/dist/chunk-62Z5WLRA.js +0 -700
  71. package/dist/chunk-BOHDJJ2O.cjs +0 -192
  72. package/dist/chunk-NKGB64CW.cjs +0 -700
  73. package/dist/chunk-SS53NNZO.cjs +0 -1066
  74. package/dist/chunk-ZNA3IQZF.js +0 -1066
@@ -1,700 +0,0 @@
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;
2
-
3
-
4
-
5
-
6
-
7
-
8
- var _chunkBB6TR422cjs = require('./chunk-BB6TR422.cjs');
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
- var _chunkFQPUF2W2cjs = require('./chunk-FQPUF2W2.cjs');
17
-
18
-
19
-
20
-
21
- var _chunk2VX55NFMcjs = require('./chunk-2VX55NFM.cjs');
22
-
23
-
24
-
25
- var _chunk474IQG74cjs = require('./chunk-474IQG74.cjs');
26
-
27
- // src/paint/retouch.ts
28
- var TONE_RANGES = ["shadows", "midtones", "highlights"];
29
- function luma(r, g, b) {
30
- return 0.299 * r + 0.587 * g + 0.114 * b;
31
- }
32
- function dodgeBurnCurve(v, e, range, burn) {
33
- const x = Math.max(0, v);
34
- const k = Math.min(1, Math.max(0, e));
35
- const c = Math.min(1, x);
36
- if (range === "midtones") {
37
- const w2 = Math.min(1, Math.max(0, 4 * x * (1 - x)));
38
- return x + w2 * (Math.pow(c, burn ? 1 + k : 1 / (1 + k)) - x);
39
- }
40
- const w = range === "shadows" ? (1 - c) * (1 - c) : c * c;
41
- return burn ? x - k * w * x : x + k * w * (1 - c);
42
- }
43
- function compressGamut(c, l) {
44
- const L = Math.min(1, Math.max(0, l));
45
- const lo = Math.min(c[0], c[1], c[2]);
46
- const hi = Math.max(c[0], c[1], c[2]);
47
- let t = 1;
48
- if (hi > 1 && hi - L > 1e-9) t = Math.min(t, (1 - L) / (hi - L));
49
- if (lo < 0 && L - lo > 1e-9) t = Math.min(t, L / (L - lo));
50
- for (let i = 0; i < 3; i++) c[i] = L + (c[i] - L) * t;
51
- }
52
- function dodgeBurn(c, e, range, burn, protectTones) {
53
- if (!(e > 0)) return c;
54
- if (protectTones) {
55
- const l = luma(c[0], c[1], c[2]);
56
- const nl = dodgeBurnCurve(l, e, range, burn);
57
- if (l > 1e-6) for (let i = 0; i < 3; i++) c[i] *= nl / l;
58
- else c[0] = c[1] = c[2] = nl;
59
- compressGamut(c, nl);
60
- } else for (let i = 0; i < 3; i++) c[i] = dodgeBurnCurve(c[i], e, range, burn);
61
- return c;
62
- }
63
- function saturationOf(r, g, b) {
64
- const lo = Math.min(r, g, b);
65
- const hi = Math.max(r, g, b);
66
- return hi <= 1e-6 ? 0 : Math.min(1, Math.max(0, (hi - lo) / hi));
67
- }
68
- function sponge(c, amount, saturate, vibrance) {
69
- let a = Math.min(1, Math.max(0, amount));
70
- if (!(a > 0)) return c;
71
- if (vibrance) {
72
- const s = saturationOf(c[0], c[1], c[2]);
73
- a *= saturate ? 1 - s : 0.25 + 0.75 * s;
74
- }
75
- const l = luma(c[0], c[1], c[2]);
76
- const k = saturate ? 1 + a : 1 - a;
77
- for (let i = 0; i < 3; i++) c[i] = l + (c[i] - l) * k;
78
- compressGamut(c, l);
79
- return c;
80
- }
81
- function perDabStrength(e, spacing) {
82
- return 1 - Math.pow(1 - Math.min(1, Math.max(0, e)), Math.min(1, Math.max(0.01, spacing)));
83
- }
84
- var RETOUCH_SAMPLES = ["current", "current-below", "all"];
85
- var SPOT_HEAL_TYPES = ["proximity-match", "content-aware", "smooth"];
86
- var DEFAULT_RETOUCH = {
87
- aligned: true,
88
- sample: "current",
89
- spotType: "proximity-match",
90
- range: "midtones",
91
- exposure: 0.5,
92
- protectTones: true,
93
- spongeMode: "desaturate",
94
- vibrance: true,
95
- strength: 0.5,
96
- historySteps: 0
97
- };
98
- function normalizeRetouch(raw = {}, base = DEFAULT_RETOUCH) {
99
- const unit = (v, d) => typeof v === "number" && Number.isFinite(v) ? Math.min(1, Math.max(0, v)) : d;
100
- const bool = (v, d) => typeof v === "boolean" ? v : d;
101
- const pick = (v, all, d) => all.includes(v) ? v : d;
102
- return {
103
- aligned: bool(raw.aligned, base.aligned),
104
- sample: pick(raw.sample, RETOUCH_SAMPLES, base.sample),
105
- spotType: pick(raw.spotType, SPOT_HEAL_TYPES, base.spotType),
106
- range: pick(raw.range, TONE_RANGES, base.range),
107
- exposure: unit(raw.exposure, base.exposure),
108
- protectTones: bool(raw.protectTones, base.protectTones),
109
- spongeMode: pick(raw.spongeMode, ["desaturate", "saturate"], base.spongeMode),
110
- vibrance: bool(raw.vibrance, base.vibrance),
111
- strength: unit(raw.strength, base.strength),
112
- historySteps: typeof raw.historySteps === "number" && Number.isFinite(raw.historySteps) ? Math.min(1e3, Math.max(0, Math.round(raw.historySteps))) : base.historySteps
113
- };
114
- }
115
- function boxBlurPixels(data, w, h, n, r) {
116
- if (r < 1) return;
117
- if (n === 4) for (let i = 0; i < data.length; i += 4) for (let c = 0; c < 3; c++) data[i + c] *= data[i + 3] / 255;
118
- const tmp = new Float32Array(data.length);
119
- const k = 1 / (2 * r + 1);
120
- for (let y = 0; y < h; y++) {
121
- for (let x = 0; x < w; x++) {
122
- for (let c = 0; c < n; c++) {
123
- let s = 0;
124
- for (let d = -r; d <= r; d++) s += data[(y * w + Math.min(w - 1, Math.max(0, x + d))) * n + c];
125
- tmp[(y * w + x) * n + c] = s * k;
126
- }
127
- }
128
- }
129
- for (let y = 0; y < h; y++) {
130
- for (let x = 0; x < w; x++) {
131
- for (let c = 0; c < n; c++) {
132
- let s = 0;
133
- for (let d = -r; d <= r; d++) s += tmp[(Math.min(h - 1, Math.max(0, y + d)) * w + x) * n + c];
134
- data[(y * w + x) * n + c] = s * k;
135
- }
136
- }
137
- }
138
- if (n === 4) {
139
- for (let i = 0; i < data.length; i += 4) {
140
- const a = data[i + 3] / 255;
141
- for (let c = 0; c < 3; c++) data[i + c] = a > 0 ? data[i + c] / a : 0;
142
- }
143
- }
144
- }
145
- function retouchFilter(data, w, h, n, kind, radius = 2, amount = 1) {
146
- if (kind === "blur") {
147
- boxBlurPixels(data, w, h, n, radius);
148
- boxBlurPixels(data, w, h, n, radius);
149
- return;
150
- }
151
- const soft = data.slice();
152
- boxBlurPixels(soft, w, h, n, 1);
153
- for (let i = 0; i < data.length; i++) {
154
- if (n === 4 && (i & 3) === 3) continue;
155
- const v = data[i] + amount * (data[i] - soft[i]);
156
- data[i] = v > 0 ? v : 0;
157
- }
158
- }
159
- var IDENTITY_CLONE_TRANSFORM = { scaleX: 1, scaleY: 1, rotate: 0 };
160
- function isIdentityCloneTransform(t) {
161
- return t.scaleX === 1 && t.scaleY === 1 && (t.rotate % 360 + 360) % 360 === 0;
162
- }
163
- function cloneSamplePoint(t, source, anchor, x, y) {
164
- const a = -t.rotate * Math.PI / 180;
165
- const c = Math.cos(a);
166
- const s = Math.sin(a);
167
- const dx = x - anchor.x;
168
- const dy = y - anchor.y;
169
- return [source.x + (c * dx - s * dy) / t.scaleX, source.y + (s * dx + c * dy) / t.scaleY];
170
- }
171
- var TransformedPixelSource = (_class = class {
172
- constructor(inner, map) {;_class.prototype.__init.call(this);
173
- this.inner = inner;
174
- this.map = map;
175
- }
176
-
177
-
178
- __init() {this.px = [0, 0, 0, 0]}
179
- sample(x, y, out) {
180
- const [u, v] = this.map(x, y);
181
- const x0 = Math.floor(u);
182
- const y0 = Math.floor(v);
183
- const fx = u - x0;
184
- const fy = v - y0;
185
- let r = 0;
186
- let g = 0;
187
- let b = 0;
188
- let a = 0;
189
- for (let k = 0; k < 4; k++) {
190
- const w = (k & 1 ? fx : 1 - fx) * (k & 2 ? fy : 1 - fy);
191
- if (w <= 0) continue;
192
- if (!this.inner.sample(x0 + (k & 1), y0 + (k >> 1), this.px)) continue;
193
- const pa = this.px[3] * w;
194
- r += this.px[0] * pa;
195
- g += this.px[1] * pa;
196
- b += this.px[2] * pa;
197
- a += pa;
198
- }
199
- if (!(a > 0)) {
200
- out[0] = out[1] = out[2] = out[3] = 0;
201
- return false;
202
- }
203
- out[0] = r / a;
204
- out[1] = g / a;
205
- out[2] = b / a;
206
- out[3] = a;
207
- return true;
208
- }
209
- }, _class);
210
- var TilePixelSource = (_class2 = class {
211
- constructor(readTile, channels, offset = { x: 0, y: 0 }) {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);
212
- this.readTile = readTile;
213
- this.channels = channels;
214
- this.offset = offset;
215
- }
216
-
217
-
218
-
219
- __init2() {this.cache = /* @__PURE__ */ new Map()}
220
- __init3() {this.lastKey = NaN}
221
- __init4() {this.last = null}
222
- sample(x, y, out) {
223
- const lx = x - this.offset.x;
224
- const ly = y - this.offset.y;
225
- const tx = Math.floor(lx / _chunk474IQG74cjs.TILE);
226
- const ty = Math.floor(ly / _chunk474IQG74cjs.TILE);
227
- const key = _chunk474IQG74cjs.tileKey.call(void 0, tx, ty);
228
- if (key !== this.lastKey) {
229
- let t2 = this.cache.get(key);
230
- if (t2 === void 0) {
231
- t2 = this.readTile(tx, ty);
232
- this.cache.set(key, t2);
233
- }
234
- this.last = t2;
235
- this.lastKey = key;
236
- }
237
- const t = this.last;
238
- if (!t) {
239
- out[0] = out[1] = out[2] = out[3] = 0;
240
- return false;
241
- }
242
- const p = (ly - ty * _chunk474IQG74cjs.TILE) * _chunk474IQG74cjs.TILE + (lx - tx * _chunk474IQG74cjs.TILE);
243
- if (this.channels === 1) {
244
- out[0] = out[1] = out[2] = t[p];
245
- out[3] = 255;
246
- return true;
247
- }
248
- const i = p * 4;
249
- out[0] = t[i];
250
- out[1] = t[i + 1];
251
- out[2] = t[i + 2];
252
- out[3] = t[i + 3];
253
- return out[3] > 0;
254
- }
255
- }, _class2);
256
- var RegionPixelSource = class {
257
- constructor(rect, data) {
258
- this.rect = rect;
259
- this.data = data;
260
- }
261
-
262
-
263
- sample(x, y, out) {
264
- const r = this.rect;
265
- const lx = x - r.x;
266
- const ly = y - r.y;
267
- if (lx < 0 || ly < 0 || lx >= r.width || ly >= r.height) {
268
- out[0] = out[1] = out[2] = out[3] = 0;
269
- return false;
270
- }
271
- const i = (ly * r.width + lx) * 4;
272
- out[0] = this.data[i];
273
- out[1] = this.data[i + 1];
274
- out[2] = this.data[i + 2];
275
- out[3] = this.data[i + 3];
276
- return out[3] > 0;
277
- }
278
- };
279
- function readSourceRegion(source, rect, dx = 0, dy = 0) {
280
- const out = new Float32Array(rect.width * rect.height * 4);
281
- const px = [0, 0, 0, 0];
282
- for (let y = 0; y < rect.height; y++) {
283
- for (let x = 0; x < rect.width; x++) {
284
- source.sample(rect.x + x + dx, rect.y + y + dy, px);
285
- const i = (y * rect.width + x) * 4;
286
- out[i] = px[0];
287
- out[i + 1] = px[1];
288
- out[i + 2] = px[2];
289
- out[i + 3] = px[3];
290
- }
291
- }
292
- return out;
293
- }
294
- function applyRetouchToTile(coverage, tileData, channels, tx, ty, paint, s, options = {}) {
295
- const out = (_nullishCoalesce(options.into, () => ( tileData))).slice();
296
- const ox = tx * _chunk474IQG74cjs.TILE + s.offset.x;
297
- const oy = ty * _chunk474IQG74cjs.TILE + s.offset.y;
298
- let x0 = 0;
299
- let y0 = 0;
300
- let x1 = _chunk474IQG74cjs.TILE;
301
- let y1 = _chunk474IQG74cjs.TILE;
302
- if (options.region) {
303
- const r = options.region;
304
- x0 = Math.max(0, Math.floor(r.x) - ox);
305
- y0 = Math.max(0, Math.floor(r.y) - oy);
306
- x1 = Math.min(_chunk474IQG74cjs.TILE, Math.ceil(r.x + r.width) - ox);
307
- y1 = Math.min(_chunk474IQG74cjs.TILE, Math.ceil(r.y + r.height) - oy);
308
- if (x1 <= x0 || y1 <= y0) return out;
309
- if (options.into) {
310
- for (let y = y0; y < y1; y++) out.set(tileData.subarray((y * _chunk474IQG74cjs.TILE + x0) * channels, (y * _chunk474IQG74cjs.TILE + x1) * channels), (y * _chunk474IQG74cjs.TILE + x0) * channels);
311
- }
312
- }
313
- const sel = s.selection;
314
- const blend = _nullishCoalesce(s.blend, () => ( "normal"));
315
- const src = [0, 0, 0, 0];
316
- const rgb = [0, 0, 0];
317
- const cb = [0, 0, 0, 0];
318
- const cs = [0, 0, 0, 0];
319
- let covKey = NaN;
320
- let covTile;
321
- for (let y = y0; y < y1; y++) {
322
- const dy = oy + y;
323
- const cty = Math.floor(dy / _chunk474IQG74cjs.TILE);
324
- for (let x = x0; x < x1; x++) {
325
- const dx = ox + x;
326
- const ctx = Math.floor(dx / _chunk474IQG74cjs.TILE);
327
- const key = _chunk474IQG74cjs.tileKey.call(void 0, ctx, cty);
328
- if (key !== covKey) {
329
- covKey = key;
330
- covTile = coverage.tiles.get(key);
331
- }
332
- if (!covTile) continue;
333
- const c = covTile[(dy - cty * _chunk474IQG74cjs.TILE) * _chunk474IQG74cjs.TILE + (dx - ctx * _chunk474IQG74cjs.TILE)];
334
- if (c <= 0) continue;
335
- let k = c * s.opacity;
336
- if (sel) {
337
- if (dx < 0 || dy < 0 || dx >= sel.width || dy >= sel.height) continue;
338
- k *= sel.data[dy * sel.width + dx] / 255;
339
- }
340
- if (k > 1) k = 1;
341
- if (k <= 0) continue;
342
- const p = y * _chunk474IQG74cjs.TILE + x;
343
- if (channels === 1) {
344
- const g = out[p];
345
- let t;
346
- if (paint.kind === "tone") {
347
- rgb[0] = rgb[1] = rgb[2] = g / 255;
348
- paint.tone(rgb);
349
- t = luma(rgb[0], rgb[1], rgb[2]) * 255;
350
- } else if (paint.kind === "color") t = paint.color[0];
351
- else {
352
- if (!paint.source.sample(dx + paint.dx, dy + paint.dy, src)) continue;
353
- t = src[0];
354
- k *= src[3] / 255;
355
- }
356
- out[p] = Math.round(g + (t - g) * k);
357
- continue;
358
- }
359
- const i = p * 4;
360
- const a = out[i + 3];
361
- if (paint.kind === "tone") {
362
- if (a === 0) continue;
363
- rgb[0] = out[i] / 255;
364
- rgb[1] = out[i + 1] / 255;
365
- rgb[2] = out[i + 2] / 255;
366
- const r0 = rgb[0];
367
- const g0 = rgb[1];
368
- const b0 = rgb[2];
369
- paint.tone(rgb);
370
- _chunkFQPUF2W2cjs.put255.call(void 0, out, i, r0 + (rgb[0] - r0) * k);
371
- _chunkFQPUF2W2cjs.put255.call(void 0, out, i + 1, g0 + (rgb[1] - g0) * k);
372
- _chunkFQPUF2W2cjs.put255.call(void 0, out, i + 2, b0 + (rgb[2] - b0) * k);
373
- continue;
374
- }
375
- if (s.lockTransparency && a === 0) continue;
376
- if (paint.kind === "color") {
377
- src[0] = paint.color[0];
378
- src[1] = paint.color[1];
379
- src[2] = paint.color[2];
380
- src[3] = paint.color[3];
381
- } else if (!paint.source.sample(dx + paint.dx, dy + paint.dy, src)) continue;
382
- for (let ch = 0; ch < 4; ch++) {
383
- cb[ch] = out[i + ch] / 255;
384
- cs[ch] = src[ch] / 255;
385
- }
386
- const o = _chunk2VX55NFMcjs.blendPixel.call(void 0, blend, cb, cs, k);
387
- _chunkFQPUF2W2cjs.put255.call(void 0, out, i, o[0]);
388
- _chunkFQPUF2W2cjs.put255.call(void 0, out, i + 1, o[1]);
389
- _chunkFQPUF2W2cjs.put255.call(void 0, out, i + 2, o[2]);
390
- if (!s.lockTransparency) _chunkFQPUF2W2cjs.put255.call(void 0, out, i + 3, o[3]);
391
- }
392
- }
393
- return out;
394
- }
395
- function applyToneToDeepTile(coverage, samples, tx, ty, tone, s, options = {}) {
396
- const linear = samples instanceof Float32Array;
397
- const out = (_nullishCoalesce(options.into, () => ( samples))).slice();
398
- const ox = tx * _chunk474IQG74cjs.TILE + s.offset.x;
399
- const oy = ty * _chunk474IQG74cjs.TILE + s.offset.y;
400
- let x0 = 0;
401
- let y0 = 0;
402
- let x1 = _chunk474IQG74cjs.TILE;
403
- let y1 = _chunk474IQG74cjs.TILE;
404
- if (options.region) {
405
- const r = options.region;
406
- x0 = Math.max(0, Math.floor(r.x) - ox);
407
- y0 = Math.max(0, Math.floor(r.y) - oy);
408
- x1 = Math.min(_chunk474IQG74cjs.TILE, Math.ceil(r.x + r.width) - ox);
409
- y1 = Math.min(_chunk474IQG74cjs.TILE, Math.ceil(r.y + r.height) - oy);
410
- if (x1 <= x0 || y1 <= y0) return out;
411
- if (options.into) for (let y = y0; y < y1; y++) out.set(samples.subarray((y * _chunk474IQG74cjs.TILE + x0) * 4, (y * _chunk474IQG74cjs.TILE + x1) * 4), (y * _chunk474IQG74cjs.TILE + x0) * 4);
412
- }
413
- const sel = s.selection;
414
- const rgb = [0, 0, 0];
415
- const before = [0, 0, 0];
416
- const excess = [0, 0, 0];
417
- let covKey = NaN;
418
- let covTile;
419
- for (let y = y0; y < y1; y++) {
420
- const dy = oy + y;
421
- const cty = Math.floor(dy / _chunk474IQG74cjs.TILE);
422
- for (let x = x0; x < x1; x++) {
423
- const dx = ox + x;
424
- const ctx = Math.floor(dx / _chunk474IQG74cjs.TILE);
425
- const key = _chunk474IQG74cjs.tileKey.call(void 0, ctx, cty);
426
- if (key !== covKey) {
427
- covKey = key;
428
- covTile = coverage.tiles.get(key);
429
- }
430
- if (!covTile) continue;
431
- const c = covTile[(dy - cty * _chunk474IQG74cjs.TILE) * _chunk474IQG74cjs.TILE + (dx - ctx * _chunk474IQG74cjs.TILE)];
432
- if (c <= 0) continue;
433
- let k = c * s.opacity;
434
- if (sel) {
435
- if (dx < 0 || dy < 0 || dx >= sel.width || dy >= sel.height) continue;
436
- k *= sel.data[dy * sel.width + dx] / 255;
437
- }
438
- if (k > 1) k = 1;
439
- if (k <= 0) continue;
440
- const i = (y * _chunk474IQG74cjs.TILE + x) * 4;
441
- if (out[i + 3] === 0) continue;
442
- for (let ch = 0; ch < 3; ch++) {
443
- const v = out[i + ch];
444
- if (linear) {
445
- excess[ch] = v > 1 ? v - 1 : 0;
446
- rgb[ch] = _chunk2VX55NFMcjs.srgbEncode.call(void 0, v > 1 ? 1 : v < 0 ? 0 : v);
447
- } else rgb[ch] = v / 65535;
448
- before[ch] = rgb[ch];
449
- }
450
- tone(rgb);
451
- for (let ch = 0; ch < 3; ch++) {
452
- const e = before[ch] + (rgb[ch] - before[ch]) * k;
453
- if (linear) out[i + ch] = _chunk2VX55NFMcjs.srgbDecode.call(void 0, e) + excess[ch];
454
- else out[i + ch] = e <= 0 ? 0 : e >= 1 ? 65535 : Math.round(e * 65535);
455
- }
456
- }
457
- }
458
- return out;
459
- }
460
- function toneOf(tool, settings) {
461
- const burn = tool === "burn";
462
- return (rgb) => {
463
- dodgeBurn(rgb, settings.exposure, settings.range, burn, settings.protectTones);
464
- };
465
- }
466
- function healPixels(w, h, src, dst, mask) {
467
- const out = new Float32Array(dst);
468
- const bb = _chunkBB6TR422cjs.maskBounds.call(void 0, w, h, mask);
469
- if (!bb) return out;
470
- const x0 = Math.max(0, bb[0] - 1);
471
- const y0 = Math.max(0, bb[1] - 1);
472
- const x1 = Math.min(w, bb[2] + 1);
473
- const y1 = Math.min(h, bb[3] + 1);
474
- const rw = x1 - x0;
475
- const rh = y1 - y0;
476
- const s = new Float32Array(rw * rh * 4);
477
- const d = new Float32Array(rw * rh * 4);
478
- const m = new Uint8Array(rw * rh);
479
- for (let y = 0; y < rh; y++) {
480
- for (let x = 0; x < rw; x++) {
481
- const gi = (y + y0) * w + x + x0;
482
- const li = y * rw + x;
483
- m[li] = mask[gi] ? 1 : 0;
484
- for (let c = 0; c < 4; c++) {
485
- s[li * 4 + c] = src[gi * 4 + c];
486
- d[li * 4 + c] = dst[gi * 4 + c];
487
- }
488
- }
489
- }
490
- const healed = _chunkBB6TR422cjs.seamlessClone.call(void 0, rw, rh, 4, s, d, m);
491
- for (let y = 0; y < rh; y++) {
492
- for (let x = 0; x < rw; x++) {
493
- const gi = ((y + y0) * w + x + x0) * 4;
494
- const li = (y * rw + x) * 4;
495
- for (let c = 0; c < 4; c++) out[gi + c] = Math.min(255, Math.max(0, healed[li + c]));
496
- }
497
- }
498
- return out;
499
- }
500
- function spotHealPixels(w, h, img, hole, size, type, onOffset) {
501
- const domain = _chunkBB6TR422cjs.dilateMask.call(void 0, w, h, hole, 2);
502
- const healMask = _chunkBB6TR422cjs.dilateMask.call(void 0, w, h, hole, 1);
503
- let filled = null;
504
- let bestFound = null;
505
- if (type === "proximity-match") {
506
- const ring = Math.min(16, Math.max(3, Math.floor(size / 8)));
507
- const off = _chunkBB6TR422cjs.bestOffset.call(void 0, w, h, 4, img, domain, ring, Math.floor(Math.max(w, h) / 2));
508
- if (off) {
509
- bestFound = off;
510
- filled = new Float32Array(img);
511
- const [ddx, ddy] = off;
512
- for (let i = 0; i < w * h; i++) {
513
- if (!domain[i]) continue;
514
- const x = i % w + ddx;
515
- const y = Math.floor(i / w) + ddy;
516
- const j = (y * w + x) * 4;
517
- for (let c = 0; c < 4; c++) filled[i * 4 + c] = img[j + c];
518
- }
519
- }
520
- }
521
- _optionalChain([onOffset, 'optionalCall', _ => _(filled ? bestFound : null)]);
522
- if (!filled && type === "content-aware") filled = _chunkBB6TR422cjs.contentAwareFill.call(void 0, w, h, 4, img, domain);
523
- if (!filled) filled = _chunkBB6TR422cjs.membraneFill.call(void 0, w, h, 4, img, domain);
524
- return healPixels(w, h, filled, img, healMask);
525
- }
526
- function spotHealWindow(bounds, canvas) {
527
- const g = Math.max(8, Math.ceil(Math.max(bounds.width, bounds.height)));
528
- const x0 = Math.max(0, bounds.x - g);
529
- const y0 = Math.max(0, bounds.y - g);
530
- const x1 = Math.min(canvas.width, bounds.x + bounds.width + g);
531
- const y1 = Math.min(canvas.height, bounds.y + bounds.height + g);
532
- return { x: x0, y: y0, width: Math.max(0, x1 - x0), height: Math.max(0, y1 - y0) };
533
- }
534
- var RetouchDabStroke = (_class3 = class {
535
- constructor(brush, target, effect) {;_class3.prototype.__init5.call(this);_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);
536
- this.brush = brush;
537
- this.effect = effect;
538
- this.walker = new (0, _chunkFQPUF2W2cjs.DabWalker)(brush);
539
- this.medium = new (0, _chunkFQPUF2W2cjs.TileMedium)(target);
540
- }
541
-
542
-
543
- __init5() {this.dabCount = 0}
544
- __init6() {this.bounds = null}
545
-
546
-
547
- __init7() {this.smoothPos = null}
548
- __init8() {this.buf = new Float32Array(0)}
549
- push(points) {
550
- const dabs = [];
551
- for (const p of points) this.walker.push(this.smooth(p), dabs);
552
- return this.paint(dabs);
553
- }
554
- finish(last) {
555
- const dabs = [];
556
- if (last && this.smoothPos && (this.smoothPos.x !== last.x || this.smoothPos.y !== last.y)) this.walker.push(last, dabs);
557
- this.walker.finish(dabs);
558
- return this.paint(dabs);
559
- }
560
- smooth(p) {
561
- const a = 1 - Math.min(0.95, Math.max(0, this.brush.smoothing));
562
- const cur = this.smoothPos;
563
- const n = cur && a < 1 ? { ...p, x: cur.x + (p.x - cur.x) * a, y: cur.y + (p.y - cur.y) * a } : p;
564
- this.smoothPos = n;
565
- return n;
566
- }
567
- paint(dabs) {
568
- const rects = [];
569
- for (const d of dabs) {
570
- const rect = _chunkFQPUF2W2cjs.dabRect.call(void 0, d, this.brush.hardness);
571
- const n = rect.width * rect.height;
572
- if (this.buf.length < n) this.buf = new Float32Array(n);
573
- const cov = this.buf.subarray(0, n);
574
- _chunkFQPUF2W2cjs.rasterizeDab.call(void 0, { ...d, alpha: 1 }, this.brush.hardness, rect, cov);
575
- this.medium.reset();
576
- this.effect(this.medium, d, rect, cov);
577
- rects.push(rect);
578
- this.bounds = unionRect(this.bounds, rect);
579
- this.dabCount++;
580
- }
581
- return rects;
582
- }
583
- }, _class3);
584
- function smudgeEffect(brush, strength, mixing = "rgb") {
585
- const s = Math.min(1, Math.max(0, strength));
586
- const tip = new (0, _chunkFQPUF2W2cjs.SmudgeTip)({ strength: s, length: s, mixing }, brush.size);
587
- return (medium, d, rect, cov) => tip.dab(medium, { x: d.x, y: d.y, radius: d.radius, opacity: d.opacity * d.alpha }, rect, cov);
588
- }
589
- function spongeEffect(brush, saturate, vibrance) {
590
- const rgb = [0, 0, 0];
591
- return (medium, d, rect, cov) => {
592
- const w = rect.width;
593
- for (let yy = 0; yy < rect.height; yy++) {
594
- for (let xx = 0; xx < w; xx++) {
595
- const cv = cov[yy * w + xx];
596
- if (cv <= 0) continue;
597
- const dx = rect.x + xx;
598
- const dy = rect.y + yy;
599
- const k = perDabStrength(cv * d.alpha * d.opacity * 0.5, brush.spacing) * medium.selectionAt(dx, dy);
600
- if (k <= 0) continue;
601
- const ri = medium.locate(dx, dy, false);
602
- if (ri < 0 || medium.pixels[ri + 3] === 0) continue;
603
- const i = medium.locate(dx, dy, true);
604
- const px = medium.pixels;
605
- rgb[0] = px[i] / 255;
606
- rgb[1] = px[i + 1] / 255;
607
- rgb[2] = px[i + 2] / 255;
608
- sponge(rgb, k, saturate, vibrance);
609
- _chunkFQPUF2W2cjs.put255.call(void 0, px, i, rgb[0]);
610
- _chunkFQPUF2W2cjs.put255.call(void 0, px, i + 1, rgb[1]);
611
- _chunkFQPUF2W2cjs.put255.call(void 0, px, i + 2, rgb[2]);
612
- }
613
- }
614
- };
615
- }
616
- function rgbaViewOfGrey(target) {
617
- const views = /* @__PURE__ */ new Map();
618
- const dirty = /* @__PURE__ */ new Map();
619
- const expand = (g) => {
620
- const out = new Uint8ClampedArray(g.length * 4);
621
- for (let i = 0; i < g.length; i++) {
622
- out[i * 4] = out[i * 4 + 1] = out[i * 4 + 2] = g[i];
623
- out[i * 4 + 3] = 255;
624
- }
625
- return out;
626
- };
627
- const view = {
628
- offset: target.offset,
629
- lockTransparency: true,
630
- selection: target.selection,
631
- readTile: (tx, ty) => {
632
- const key = _chunk474IQG74cjs.tileKey.call(void 0, tx, ty);
633
- let v = views.get(key);
634
- if (!v) {
635
- v = expand(_nullishCoalesce(target.readTile(tx, ty), () => ( new Uint8ClampedArray(_chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE))));
636
- views.set(key, v);
637
- }
638
- return v;
639
- },
640
- writeTile: (tx, ty) => {
641
- const key = _chunk474IQG74cjs.tileKey.call(void 0, tx, ty);
642
- let v = views.get(key);
643
- if (!v) {
644
- v = expand(_nullishCoalesce(target.readTile(tx, ty), () => ( new Uint8ClampedArray(_chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE))));
645
- views.set(key, v);
646
- }
647
- dirty.set(key, { tx, ty, data: v });
648
- return v;
649
- }
650
- };
651
- return {
652
- target: view,
653
- flush: () => {
654
- for (const { tx, ty, data } of dirty.values()) {
655
- const g = target.writeTile(tx, ty);
656
- for (let i = 0; i < g.length; i++) g[i] = data[i * 4];
657
- }
658
- dirty.clear();
659
- }
660
- };
661
- }
662
- function unionRect(a, b) {
663
- if (!a) return { ...b };
664
- const x = Math.min(a.x, b.x);
665
- const y = Math.min(a.y, b.y);
666
- 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 };
667
- }
668
-
669
-
670
-
671
-
672
-
673
-
674
-
675
-
676
-
677
-
678
-
679
-
680
-
681
-
682
-
683
-
684
-
685
-
686
-
687
-
688
-
689
-
690
-
691
-
692
-
693
-
694
-
695
-
696
-
697
-
698
-
699
-
700
- 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.boxBlurPixels = boxBlurPixels; exports.retouchFilter = retouchFilter; exports.IDENTITY_CLONE_TRANSFORM = IDENTITY_CLONE_TRANSFORM; exports.isIdentityCloneTransform = isIdentityCloneTransform; exports.cloneSamplePoint = cloneSamplePoint; exports.TransformedPixelSource = TransformedPixelSource; 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;