@pixerate/editor 0.97.0 → 0.99.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 +4 -2
- package/dist/animation-editor/index.cjs +55 -53
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +3 -2
- package/dist/animation-editor/index.d.ts +3 -2
- package/dist/animation-editor/index.js +11 -9
- package/dist/animation-editor/index.js.map +1 -1
- package/dist/chunk-DWGZUSES.cjs +694 -0
- package/dist/chunk-DWGZUSES.cjs.map +1 -0
- package/dist/chunk-GX332W2C.js +181 -0
- package/dist/chunk-GX332W2C.js.map +1 -0
- package/dist/{chunk-7MD7C6XQ.cjs → chunk-JF5PXN7W.cjs} +96 -744
- package/dist/chunk-JF5PXN7W.cjs.map +1 -0
- package/dist/chunk-KKREERP2.js +694 -0
- package/dist/chunk-KKREERP2.js.map +1 -0
- package/dist/chunk-MUUXNRU4.cjs +181 -0
- package/dist/chunk-MUUXNRU4.cjs.map +1 -0
- package/dist/{chunk-OEVSVA6V.js → chunk-WIR377F6.js} +788 -22
- package/dist/chunk-WIR377F6.js.map +1 -0
- package/dist/{chunk-4AB5BHYK.cjs → chunk-WT6ZAWJP.cjs} +788 -22
- package/dist/chunk-WT6ZAWJP.cjs.map +1 -0
- package/dist/{chunk-4JLB2USO.js → chunk-YGZNGDIT.js} +45 -693
- package/dist/chunk-YGZNGDIT.js.map +1 -0
- package/dist/image-editor/index.cjs +1798 -333
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +482 -6
- package/dist/image-editor/index.d.ts +482 -6
- package/dist/image-editor/index.js +1488 -23
- package/dist/image-editor/index.js.map +1 -1
- package/dist/raster/index.cjs +23 -2
- package/dist/raster/index.cjs.map +1 -1
- package/dist/raster/index.d.cts +98 -2
- package/dist/raster/index.d.ts +98 -2
- package/dist/raster/index.js +23 -2
- package/dist/{svg-ymShkNtu.d.cts → svg-C9r284x8.d.cts} +6 -9
- package/dist/{svg-Dh17jCyA.d.ts → svg-MVKBqwD4.d.ts} +6 -9
- package/dist/types-CwMPoRMU.d.cts +40 -0
- package/dist/types-CwMPoRMU.d.ts +40 -0
- package/dist/vector/index.cjs +490 -554
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +154 -292
- package/dist/vector/index.d.ts +154 -292
- package/dist/vector/index.js +91 -155
- package/dist/vector/index.js.map +1 -1
- package/dist/warp-B8rAguzs.d.ts +165 -0
- package/dist/warp-nYs2DPrx.d.cts +165 -0
- package/package.json +1 -1
- package/skills/pixerate-image-editor/SKILL.md +49 -3
- package/dist/chunk-4AB5BHYK.cjs.map +0 -1
- package/dist/chunk-4JLB2USO.js.map +0 -1
- package/dist/chunk-7MD7C6XQ.cjs.map +0 -1
- package/dist/chunk-OEVSVA6V.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11;
|
|
2
2
|
|
|
3
3
|
var _chunkD6FH2YAXcjs = require('../chunk-D6FH2YAX.cjs');
|
|
4
4
|
|
|
@@ -58,7 +58,28 @@ var _chunkVJUVNERTcjs = require('../chunk-VJUVNERT.cjs');
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
var _chunkWT6ZAWJPcjs = require('../chunk-WT6ZAWJP.cjs');
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
var _chunkMUUXNRU4cjs = require('../chunk-MUUXNRU4.cjs');
|
|
62
83
|
|
|
63
84
|
|
|
64
85
|
|
|
@@ -137,6 +158,28 @@ var _chunkZZOTHJ4Kcjs = require('../chunk-ZZOTHJ4K.cjs');
|
|
|
137
158
|
|
|
138
159
|
var _chunkCRMAXIUVcjs = require('../chunk-CRMAXIUV.cjs');
|
|
139
160
|
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
var _chunkDWGZUSEScjs = require('../chunk-DWGZUSES.cjs');
|
|
182
|
+
|
|
140
183
|
// src/image-editor/color.ts
|
|
141
184
|
var LEGACY_PROCESS_VERSION = 1;
|
|
142
185
|
var LATEST_PROCESS_VERSION = 2;
|
|
@@ -1147,7 +1190,7 @@ function smoothCoverage(m, w, h, r) {
|
|
|
1147
1190
|
return src;
|
|
1148
1191
|
}
|
|
1149
1192
|
function featherCoverage(m, w, h, radius) {
|
|
1150
|
-
const out =
|
|
1193
|
+
const out = _chunkWT6ZAWJPcjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
|
|
1151
1194
|
for (let i = 0; i < out.length; i++) if (Math.abs(out[i]) < 1e-7) out[i] = 0;
|
|
1152
1195
|
return out;
|
|
1153
1196
|
}
|
|
@@ -1295,7 +1338,7 @@ function layerMaskCoverage(mask) {
|
|
|
1295
1338
|
let v = new Float32Array(sel.data.length);
|
|
1296
1339
|
for (let i = 0; i < v.length; i++) v[i] = sel.data[i] / 255;
|
|
1297
1340
|
const feather = _nullishCoalesce(mask.feather, () => ( 0));
|
|
1298
|
-
if (feather > 0) v =
|
|
1341
|
+
if (feather > 0) v = _chunkWT6ZAWJPcjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
|
|
1299
1342
|
const density = _nullishCoalesce(mask.density, () => ( 1));
|
|
1300
1343
|
if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
|
|
1301
1344
|
return v;
|
|
@@ -1538,7 +1581,7 @@ function normalizeAdjustmentLayers(raw) {
|
|
|
1538
1581
|
return out;
|
|
1539
1582
|
}
|
|
1540
1583
|
function curveLutFromLevels(points) {
|
|
1541
|
-
return
|
|
1584
|
+
return _chunkWT6ZAWJPcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
|
|
1542
1585
|
}
|
|
1543
1586
|
var toUnitLevels = (c) => ({
|
|
1544
1587
|
inBlack: c.inBlack / 255,
|
|
@@ -2364,7 +2407,7 @@ function newLayerId(prefix = "layer") {
|
|
|
2364
2407
|
return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
|
|
2365
2408
|
}
|
|
2366
2409
|
function pixelLayers(layers) {
|
|
2367
|
-
return
|
|
2410
|
+
return _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
|
|
2368
2411
|
}
|
|
2369
2412
|
function developFilter(layer) {
|
|
2370
2413
|
return _optionalChain([layer, 'access', _8 => _8.filters, 'optionalAccess', _9 => _9.find, 'call', _10 => _10((f) => f.kind === "develop")]);
|
|
@@ -2485,7 +2528,7 @@ var PHOTO_PROFILE = {
|
|
|
2485
2528
|
return v;
|
|
2486
2529
|
}
|
|
2487
2530
|
};
|
|
2488
|
-
var LayerCompositor = class extends
|
|
2531
|
+
var LayerCompositor = class extends _chunkWT6ZAWJPcjs.RasterCompositor {
|
|
2489
2532
|
constructor(options = {}) {
|
|
2490
2533
|
super(PHOTO_PROFILE, options);
|
|
2491
2534
|
}
|
|
@@ -3150,6 +3193,44 @@ var ImageEditorRenderer = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
3150
3193
|
}
|
|
3151
3194
|
ctx.restore();
|
|
3152
3195
|
}
|
|
3196
|
+
if (options.freeTransform) {
|
|
3197
|
+
const t = options.freeTransform;
|
|
3198
|
+
ctx.save();
|
|
3199
|
+
try {
|
|
3200
|
+
const scr = (p) => projectImagePoint(p, projection);
|
|
3201
|
+
const outline = t.outline.map(scr);
|
|
3202
|
+
ctx.beginPath();
|
|
3203
|
+
outline.forEach((p, i) => i ? ctx.lineTo(p.x, p.y) : ctx.moveTo(p.x, p.y));
|
|
3204
|
+
ctx.closePath();
|
|
3205
|
+
ctx.lineWidth = 3;
|
|
3206
|
+
ctx.strokeStyle = "rgba(0,0,0,0.5)";
|
|
3207
|
+
ctx.stroke();
|
|
3208
|
+
ctx.lineWidth = 1;
|
|
3209
|
+
ctx.strokeStyle = "#ffffff";
|
|
3210
|
+
ctx.stroke();
|
|
3211
|
+
for (const h of t.handles.map(scr)) {
|
|
3212
|
+
ctx.fillStyle = "#ffffff";
|
|
3213
|
+
ctx.strokeStyle = "#1e293b";
|
|
3214
|
+
ctx.fillRect(h.x - 4, h.y - 4, 8, 8);
|
|
3215
|
+
ctx.strokeRect(h.x - 4, h.y - 4, 8, 8);
|
|
3216
|
+
}
|
|
3217
|
+
const r = scr(t.reference);
|
|
3218
|
+
ctx.beginPath();
|
|
3219
|
+
ctx.arc(r.x, r.y, 5, 0, Math.PI * 2);
|
|
3220
|
+
ctx.moveTo(r.x - 8, r.y);
|
|
3221
|
+
ctx.lineTo(r.x + 8, r.y);
|
|
3222
|
+
ctx.moveTo(r.x, r.y - 8);
|
|
3223
|
+
ctx.lineTo(r.x, r.y + 8);
|
|
3224
|
+
ctx.lineWidth = 3;
|
|
3225
|
+
ctx.strokeStyle = "rgba(0,0,0,0.5)";
|
|
3226
|
+
ctx.stroke();
|
|
3227
|
+
ctx.lineWidth = 1;
|
|
3228
|
+
ctx.strokeStyle = "#ffffff";
|
|
3229
|
+
ctx.stroke();
|
|
3230
|
+
} catch (e6) {
|
|
3231
|
+
}
|
|
3232
|
+
ctx.restore();
|
|
3233
|
+
}
|
|
3153
3234
|
if (isActivelyCropping) {
|
|
3154
3235
|
const activeCrop = options.draftCrop !== void 0 && options.draftCrop !== null ? options.draftCrop : _nullishCoalesce(crop, () => ( { x: 0, y: 0, width: naturalWidth, height: naturalHeight }));
|
|
3155
3236
|
this.drawCropOverlay(ctx, getViewportMetrics(geoState, vpWidth, vpHeight, true, activeCrop));
|
|
@@ -3214,7 +3295,7 @@ var ImageEditorRenderer = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
3214
3295
|
applyDepthMask(imageData, maskData, depthMask);
|
|
3215
3296
|
}
|
|
3216
3297
|
}
|
|
3217
|
-
} catch (
|
|
3298
|
+
} catch (e7) {
|
|
3218
3299
|
}
|
|
3219
3300
|
}
|
|
3220
3301
|
_optionalChain([onPixels, 'optionalCall', _46 => _46(imageData)]);
|
|
@@ -3262,7 +3343,7 @@ var ImageEditorRenderer = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
3262
3343
|
/** Loads what the compositor reads synchronously: depth maps (at canvas size) and annotation images. */
|
|
3263
3344
|
/** Loads depth maps and annotation images the compositor reads synchronously. */
|
|
3264
3345
|
async prepareLayerAssets(layers, width, height) {
|
|
3265
|
-
for (const l of
|
|
3346
|
+
for (const l of _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers)) {
|
|
3266
3347
|
const source = _optionalChain([l, 'access', _57 => _57.mask, 'optionalAccess', _58 => _58.source]);
|
|
3267
3348
|
if (_optionalChain([source, 'optionalAccess', _59 => _59.enabled]) && source.maskSource) {
|
|
3268
3349
|
const key = `${source.maskSource}|${width}x${height}`;
|
|
@@ -3276,14 +3357,14 @@ var ImageEditorRenderer = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
3276
3357
|
this.depthMaps.set(key, { width, height, data: data.data });
|
|
3277
3358
|
this.assetVersion++;
|
|
3278
3359
|
}
|
|
3279
|
-
} catch (
|
|
3360
|
+
} catch (e8) {
|
|
3280
3361
|
}
|
|
3281
3362
|
}
|
|
3282
3363
|
if (l.type === "annotation" && l.annotation.type === "image" && !this.imageCache.peek(l.annotation.src)) {
|
|
3283
3364
|
try {
|
|
3284
3365
|
await this.imageCache.get(l.annotation.src);
|
|
3285
3366
|
this.assetVersion++;
|
|
3286
|
-
} catch (
|
|
3367
|
+
} catch (e9) {
|
|
3287
3368
|
}
|
|
3288
3369
|
}
|
|
3289
3370
|
}
|
|
@@ -3311,7 +3392,7 @@ var ImageEditorRenderer = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
3311
3392
|
this.drawAnnotationShape(ctx, annotation, img);
|
|
3312
3393
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
3313
3394
|
return new Uint8ClampedArray(ctx.getImageData(0, 0, rect.width, rect.height).data);
|
|
3314
|
-
} catch (
|
|
3395
|
+
} catch (e10) {
|
|
3315
3396
|
return null;
|
|
3316
3397
|
}
|
|
3317
3398
|
}
|
|
@@ -3510,7 +3591,7 @@ var ImageEditorRenderer = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
3510
3591
|
_chunkCRMAXIUVcjs.blendImageData.call(void 0, backdrop, source, _chunkCRMAXIUVcjs.normalizeBlendMode.call(void 0, ann.blend));
|
|
3511
3592
|
lctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
3512
3593
|
lctx.putImageData(backdrop, 0, 0);
|
|
3513
|
-
} catch (
|
|
3594
|
+
} catch (e11) {
|
|
3514
3595
|
return false;
|
|
3515
3596
|
}
|
|
3516
3597
|
ctx.save();
|
|
@@ -3526,7 +3607,7 @@ var ImageEditorRenderer = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
3526
3607
|
if (ann.type === "image") {
|
|
3527
3608
|
try {
|
|
3528
3609
|
img = await this.imageCache.get(ann.src);
|
|
3529
|
-
} catch (
|
|
3610
|
+
} catch (e12) {
|
|
3530
3611
|
}
|
|
3531
3612
|
}
|
|
3532
3613
|
this.drawAnnotationShape(ctx, ann, img);
|
|
@@ -3958,7 +4039,7 @@ function removeAnnotationLayers(layers) {
|
|
|
3958
4039
|
function polygonCoverage(points, width, height, antiAlias = true) {
|
|
3959
4040
|
const m = new Float32Array(width * height);
|
|
3960
4041
|
if (points.length < 3 || width <= 0 || height <= 0) return m;
|
|
3961
|
-
const
|
|
4042
|
+
const sub2 = antiAlias ? 4 : 1;
|
|
3962
4043
|
const edges = [];
|
|
3963
4044
|
for (let i = 0; i < points.length; i++) {
|
|
3964
4045
|
const a = points[i];
|
|
@@ -3973,8 +4054,8 @@ function polygonCoverage(points, width, height, antiAlias = true) {
|
|
|
3973
4054
|
const xs = [];
|
|
3974
4055
|
for (let py = 0; py < height; py++) {
|
|
3975
4056
|
const row = py * width;
|
|
3976
|
-
for (let s = 0; s <
|
|
3977
|
-
const y = py + (s + 0.5) /
|
|
4057
|
+
for (let s = 0; s < sub2; s++) {
|
|
4058
|
+
const y = py + (s + 0.5) / sub2;
|
|
3978
4059
|
while (next < edges.length && edges[next].top <= y) active.push(edges[next++]);
|
|
3979
4060
|
if (active.length) active = active.filter((e) => e.bottom > y);
|
|
3980
4061
|
if (!active.length) continue;
|
|
@@ -3996,7 +4077,7 @@ function polygonCoverage(points, width, height, antiAlias = true) {
|
|
|
3996
4077
|
const c = cx + 0.5;
|
|
3997
4078
|
cov = c >= x0 && c < x1 ? 1 : 0;
|
|
3998
4079
|
}
|
|
3999
|
-
if (cov > 0) m[row + cx] += cov /
|
|
4080
|
+
if (cov > 0) m[row + cx] += cov / sub2;
|
|
4000
4081
|
}
|
|
4001
4082
|
}
|
|
4002
4083
|
}
|
|
@@ -4445,11 +4526,11 @@ function refineCoverage(guide, m, w, h, params = {}) {
|
|
|
4445
4526
|
}
|
|
4446
4527
|
const ss = smoothSigma(p);
|
|
4447
4528
|
if (ss >= 0.3) {
|
|
4448
|
-
a =
|
|
4529
|
+
a = _chunkWT6ZAWJPcjs.gaussianBlur.call(void 0, a, w, h, ss, "clamp");
|
|
4449
4530
|
const gain = 1 + ss;
|
|
4450
4531
|
for (let i = 0; i < a.length; i++) a[i] = Math.min(1, Math.max(0, (a[i] - 0.5) * gain + 0.5));
|
|
4451
4532
|
}
|
|
4452
|
-
a =
|
|
4533
|
+
a = _chunkWT6ZAWJPcjs.gaussianBlur.call(void 0, a, w, h, featherSigma(p), "clamp");
|
|
4453
4534
|
if (p.contrast > 0) {
|
|
4454
4535
|
const gain = 1 / (1 - 0.99 * p.contrast / 100);
|
|
4455
4536
|
for (let i = 0; i < a.length; i++) a[i] = Math.min(1, Math.max(0, (a[i] - 0.5) * gain + 0.5));
|
|
@@ -4507,7 +4588,7 @@ function refineSelection(pixels, mask, params = {}) {
|
|
|
4507
4588
|
// src/image-editor/layers/serialize.ts
|
|
4508
4589
|
var LAYERED_SCHEMA_VERSION = 3;
|
|
4509
4590
|
function serializePatterns(patterns) {
|
|
4510
|
-
return patterns.map((p) => ({ id: p.id, name: p.name, png:
|
|
4591
|
+
return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkWT6ZAWJPcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
|
|
4511
4592
|
}
|
|
4512
4593
|
function deserializePatterns(raw, problems = []) {
|
|
4513
4594
|
if (!Array.isArray(raw)) return [];
|
|
@@ -4530,7 +4611,7 @@ function encodeSurface(surface) {
|
|
|
4530
4611
|
let out = null;
|
|
4531
4612
|
if (b) {
|
|
4532
4613
|
const data = _chunkCRMAXIUVcjs.readRegion.call(void 0, surface, b);
|
|
4533
|
-
out = { url:
|
|
4614
|
+
out = { url: _chunkWT6ZAWJPcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
|
|
4534
4615
|
}
|
|
4535
4616
|
encodedCache.set(surface, out);
|
|
4536
4617
|
return out;
|
|
@@ -4552,7 +4633,7 @@ function baseFields(layer, ctx) {
|
|
|
4552
4633
|
function serializeEffects(effects) {
|
|
4553
4634
|
const out = { enabled: effects.enabled, items: JSON.parse(JSON.stringify(effects.items)) };
|
|
4554
4635
|
if (effects.scale !== void 0 && effects.scale !== 1) out.scale = effects.scale;
|
|
4555
|
-
if (effects.psd) out.psd = { key: effects.psd.key, data:
|
|
4636
|
+
if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkWT6ZAWJPcjs.bytesToBase64.call(void 0, effects.psd.data) };
|
|
4556
4637
|
return out;
|
|
4557
4638
|
}
|
|
4558
4639
|
function deserializeEffects(raw) {
|
|
@@ -4562,12 +4643,12 @@ function deserializeEffects(raw) {
|
|
|
4562
4643
|
const p = r.psd;
|
|
4563
4644
|
if (p && typeof p.key === "string" && typeof p.data === "string") {
|
|
4564
4645
|
try {
|
|
4565
|
-
psd = { key: p.key, data:
|
|
4566
|
-
} catch (
|
|
4646
|
+
psd = { key: p.key, data: _chunkWT6ZAWJPcjs.base64ToBytes.call(void 0, p.data) };
|
|
4647
|
+
} catch (e13) {
|
|
4567
4648
|
psd = void 0;
|
|
4568
4649
|
}
|
|
4569
4650
|
}
|
|
4570
|
-
return
|
|
4651
|
+
return _chunkWT6ZAWJPcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
|
|
4571
4652
|
}
|
|
4572
4653
|
function serializeMask(mask, hint, ctx) {
|
|
4573
4654
|
const out = { defaultValue: mask.defaultValue };
|
|
@@ -4584,6 +4665,7 @@ function serializeMask(mask, hint, ctx) {
|
|
|
4584
4665
|
if (mask.density !== void 0 && mask.density !== 1) out.density = mask.density;
|
|
4585
4666
|
if (mask.feather) out.feather = mask.feather;
|
|
4586
4667
|
if (mask.enabled === false) out.enabled = false;
|
|
4668
|
+
if (mask.linked === false) out.linked = false;
|
|
4587
4669
|
return out;
|
|
4588
4670
|
}
|
|
4589
4671
|
function serializeLayer(layer, ctx) {
|
|
@@ -4639,7 +4721,7 @@ async function serializeLayersExternal(layers, store) {
|
|
|
4639
4721
|
for (const [id, url] of Object.entries(inline.assets)) {
|
|
4640
4722
|
let ref = refs.get(url);
|
|
4641
4723
|
if (!ref) {
|
|
4642
|
-
const parsed =
|
|
4724
|
+
const parsed = _chunkWT6ZAWJPcjs.parseDataUrl.call(void 0, url);
|
|
4643
4725
|
const png = decodePngHeader(parsed.bytes);
|
|
4644
4726
|
ref = await store.put(new Blob([parsed.bytes], { type: "image/png" }), { id, width: png.width, height: png.height });
|
|
4645
4727
|
if (typeof ref !== "string" || !ref) throw new Error(`The asset store returned no reference for "${id}".`);
|
|
@@ -4667,7 +4749,7 @@ async function resolveExternalAssets(assets, store, problems) {
|
|
|
4667
4749
|
try {
|
|
4668
4750
|
const blob = await store.get(ref);
|
|
4669
4751
|
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
4670
|
-
out[id] = `data:image/png;base64,${
|
|
4752
|
+
out[id] = `data:image/png;base64,${_chunkWT6ZAWJPcjs.bytesToBase64.call(void 0, bytes)}`;
|
|
4671
4753
|
} catch (err) {
|
|
4672
4754
|
problems.push(`Asset "${id}" (${ref}) could not be fetched: ${err.message}`);
|
|
4673
4755
|
}
|
|
@@ -4675,9 +4757,9 @@ async function resolveExternalAssets(assets, store, problems) {
|
|
|
4675
4757
|
return out;
|
|
4676
4758
|
}
|
|
4677
4759
|
function decodePngDataUrl(url, channels) {
|
|
4678
|
-
const parsed =
|
|
4760
|
+
const parsed = _chunkWT6ZAWJPcjs.parseDataUrl.call(void 0, url);
|
|
4679
4761
|
if (!parsed) throw new Error("Asset is not a data URL.");
|
|
4680
|
-
const png =
|
|
4762
|
+
const png = _chunkWT6ZAWJPcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
|
|
4681
4763
|
if (png.channels === channels) return png;
|
|
4682
4764
|
if (channels === 1) {
|
|
4683
4765
|
const out2 = new Uint8ClampedArray(png.width * png.height);
|
|
@@ -4720,6 +4802,7 @@ function readMask(raw, ctx, what) {
|
|
|
4720
4802
|
if (typeof r.density === "number" && r.density !== 1) mask.density = num(r.density, 0, 1, 1);
|
|
4721
4803
|
if (typeof r.feather === "number" && r.feather > 0) mask.feather = num(r.feather, 0, 1e3, 0);
|
|
4722
4804
|
if (r.enabled === false) mask.enabled = false;
|
|
4805
|
+
if (r.linked === false) mask.linked = false;
|
|
4723
4806
|
if (r.source && typeof r.source === "object") {
|
|
4724
4807
|
const s = { ...DEFAULT_DEPTH_MASK_VALUES, ...r.source };
|
|
4725
4808
|
mask.source = { ...s, depthRange: [...s.depthRange] };
|
|
@@ -4839,47 +4922,47 @@ var fail = (message) => {
|
|
|
4839
4922
|
throw new LayerOperationError(message);
|
|
4840
4923
|
};
|
|
4841
4924
|
function requireLayer(layers, id) {
|
|
4842
|
-
const loc =
|
|
4925
|
+
const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, id);
|
|
4843
4926
|
if (!loc) {
|
|
4844
|
-
const ids =
|
|
4927
|
+
const ids = _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
|
|
4845
4928
|
fail(`Unknown layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "The document has no layers."} Call list_layers for ids.`);
|
|
4846
4929
|
}
|
|
4847
4930
|
return loc;
|
|
4848
4931
|
}
|
|
4849
4932
|
function requireUnlocked(layer, what, action) {
|
|
4850
|
-
if (
|
|
4851
|
-
if (what !== "all" &&
|
|
4933
|
+
if (_chunkWT6ZAWJPcjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
|
|
4934
|
+
if (what !== "all" && _chunkWT6ZAWJPcjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
|
|
4852
4935
|
}
|
|
4853
4936
|
function placeLayer(layers, layer, placement = {}, defaultIndex) {
|
|
4854
4937
|
const given = [placement.aboveId, placement.belowId, placement.parentId].filter((v) => v !== void 0).length;
|
|
4855
4938
|
if (given > 1) fail("Give only one of aboveId, belowId and parentId.");
|
|
4856
4939
|
if (placement.aboveId || placement.belowId) {
|
|
4857
4940
|
const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
|
|
4858
|
-
return
|
|
4941
|
+
return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _79 => _79.parent, 'optionalAccess', _80 => _80.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
|
|
4859
4942
|
}
|
|
4860
4943
|
if (placement.parentId) {
|
|
4861
4944
|
const ref = requireLayer(layers, placement.parentId);
|
|
4862
4945
|
if (ref.layer.type !== "group") fail(`Layer "${placement.parentId}" is not a group; parentId must be a group id.`);
|
|
4863
|
-
return
|
|
4946
|
+
return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
|
|
4864
4947
|
}
|
|
4865
|
-
return
|
|
4948
|
+
return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
|
|
4866
4949
|
}
|
|
4867
4950
|
function removeLayer(layers, id) {
|
|
4868
4951
|
const loc = requireLayer(layers, id);
|
|
4869
4952
|
requireUnlocked(loc.layer, "all", "delete it");
|
|
4870
|
-
return
|
|
4953
|
+
return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => null);
|
|
4871
4954
|
}
|
|
4872
4955
|
function moveLayer(layers, id, placement) {
|
|
4873
4956
|
const loc = requireLayer(layers, id);
|
|
4874
4957
|
requireUnlocked(loc.layer, "all", "move it");
|
|
4875
4958
|
const target = _nullishCoalesce(_nullishCoalesce(placement.aboveId, () => ( placement.belowId)), () => ( placement.parentId));
|
|
4876
4959
|
if (target === id) fail("A layer cannot be placed relative to itself.");
|
|
4877
|
-
if (target && loc.layer.type === "group" &&
|
|
4960
|
+
if (target && loc.layer.type === "group" && _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
|
|
4878
4961
|
fail(`Group "${id}" cannot be moved into its own child "${target}".`);
|
|
4879
4962
|
}
|
|
4880
4963
|
if (target) requireLayer(layers, target);
|
|
4881
4964
|
if (!target && placement.index === void 0) fail("Give aboveId, belowId, parentId or index.");
|
|
4882
|
-
const without =
|
|
4965
|
+
const without = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => null);
|
|
4883
4966
|
return placeLayer(without, loc.layer, placement);
|
|
4884
4967
|
}
|
|
4885
4968
|
function withNewIds(layer) {
|
|
@@ -4893,7 +4976,7 @@ function duplicateLayer(layers, id, name) {
|
|
|
4893
4976
|
const copy = withNewIds(loc.layer);
|
|
4894
4977
|
copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
|
|
4895
4978
|
delete copy.locks;
|
|
4896
|
-
return { layers:
|
|
4979
|
+
return { layers: _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _81 => _81.parent, 'optionalAccess', _82 => _82.id]), () => ( null)), loc.index + 1), id: copy.id };
|
|
4897
4980
|
}
|
|
4898
4981
|
function setLayerProperties(layers, id, props) {
|
|
4899
4982
|
const loc = requireLayer(layers, id);
|
|
@@ -4940,7 +5023,7 @@ function setLayerProperties(layers, id, props) {
|
|
|
4940
5023
|
if (props.collapsed) g.collapsed = true;
|
|
4941
5024
|
else delete g.collapsed;
|
|
4942
5025
|
}
|
|
4943
|
-
return
|
|
5026
|
+
return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
4944
5027
|
}
|
|
4945
5028
|
function groupLayers(layers, ids, name = "Group") {
|
|
4946
5029
|
if (!ids.length) fail("Give at least one layer id to group.");
|
|
@@ -4969,17 +5052,17 @@ function groupLayers(layers, ids, name = "Group") {
|
|
|
4969
5052
|
group.children[0] = c;
|
|
4970
5053
|
}
|
|
4971
5054
|
let out = layers;
|
|
4972
|
-
for (const l of ordered) out =
|
|
4973
|
-
return { layers:
|
|
5055
|
+
for (const l of ordered) out = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
|
|
5056
|
+
return { layers: _chunkWT6ZAWJPcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
|
|
4974
5057
|
}
|
|
4975
5058
|
function ungroupLayer(layers, id) {
|
|
4976
5059
|
const loc = requireLayer(layers, id);
|
|
4977
5060
|
if (loc.layer.type !== "group") fail(`Layer "${id}" is not a group.`);
|
|
4978
5061
|
requireUnlocked(loc.layer, "all", "ungroup it");
|
|
4979
5062
|
const group = loc.layer;
|
|
4980
|
-
let out =
|
|
5063
|
+
let out = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => null);
|
|
4981
5064
|
group.children.forEach((c, i) => {
|
|
4982
|
-
out =
|
|
5065
|
+
out = _chunkWT6ZAWJPcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _91 => _91.parent, 'optionalAccess', _92 => _92.id]), () => ( null)), loc.index + i);
|
|
4983
5066
|
});
|
|
4984
5067
|
return { layers: out, ids: group.children.map((c) => c.id) };
|
|
4985
5068
|
}
|
|
@@ -4989,12 +5072,17 @@ function offsetLayer(layers, id, offset) {
|
|
|
4989
5072
|
requireUnlocked(loc.layer, "position", "move it");
|
|
4990
5073
|
if (!Number.isFinite(offset.x) || !Number.isFinite(offset.y)) fail("x and y must be numbers.");
|
|
4991
5074
|
const layer = loc.layer;
|
|
4992
|
-
|
|
5075
|
+
const next = { ...layer, offset: { x: Math.round(offset.x), y: Math.round(offset.y) } };
|
|
5076
|
+
const mask = layer.mask;
|
|
5077
|
+
if (mask && mask.linked === false && !mask.source) {
|
|
5078
|
+
next.mask = { ...mask, surface: _chunkCRMAXIUVcjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
|
|
5079
|
+
}
|
|
5080
|
+
return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
4993
5081
|
}
|
|
4994
5082
|
function setLayerMask(layers, id, mask) {
|
|
4995
5083
|
const loc = requireLayer(layers, id);
|
|
4996
5084
|
requireUnlocked(loc.layer, "all", "change its mask");
|
|
4997
|
-
return
|
|
5085
|
+
return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, (l) => {
|
|
4998
5086
|
const next = { ...l };
|
|
4999
5087
|
if (mask) next.mask = mask;
|
|
5000
5088
|
else delete next.mask;
|
|
@@ -5033,7 +5121,7 @@ function requirePixelLayer(layers, id) {
|
|
|
5033
5121
|
function addLayerFilter(layers, id, filter) {
|
|
5034
5122
|
const layer = requirePixelLayer(layers, id);
|
|
5035
5123
|
if (_optionalChain([layer, 'access', _93 => _93.filters, 'optionalAccess', _94 => _94.some, 'call', _95 => _95((f) => f.kind === filter.kind)])) fail(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
|
|
5036
|
-
return
|
|
5124
|
+
return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
|
|
5037
5125
|
}
|
|
5038
5126
|
function updateLayerFilter(layers, id, filterId, changes) {
|
|
5039
5127
|
const layer = requirePixelLayer(layers, id);
|
|
@@ -5044,7 +5132,7 @@ function updateLayerFilter(layers, id, filterId, changes) {
|
|
|
5044
5132
|
const merged = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
|
|
5045
5133
|
const filters = [...layer.filters];
|
|
5046
5134
|
filters[i] = merged;
|
|
5047
|
-
return
|
|
5135
|
+
return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
|
|
5048
5136
|
}
|
|
5049
5137
|
function removeLayerFilter(layers, id, filterId) {
|
|
5050
5138
|
const layer = requirePixelLayer(layers, id);
|
|
@@ -5053,7 +5141,7 @@ function removeLayerFilter(layers, id, filterId) {
|
|
|
5053
5141
|
const next = { ...layer };
|
|
5054
5142
|
if (filters.length) next.filters = filters;
|
|
5055
5143
|
else delete next.filters;
|
|
5056
|
-
return
|
|
5144
|
+
return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
5057
5145
|
}
|
|
5058
5146
|
function requireEffectLayer(layers, id, action) {
|
|
5059
5147
|
const layer = requireLayer(layers, id).layer;
|
|
@@ -5068,7 +5156,7 @@ function guard(fn) {
|
|
|
5068
5156
|
try {
|
|
5069
5157
|
return fn();
|
|
5070
5158
|
} catch (e) {
|
|
5071
|
-
if (e instanceof
|
|
5159
|
+
if (e instanceof _chunkWT6ZAWJPcjs.LayerEffectError) fail(e.message);
|
|
5072
5160
|
throw e;
|
|
5073
5161
|
}
|
|
5074
5162
|
}
|
|
@@ -5076,20 +5164,20 @@ function setLayerEffects(layers, id, effects) {
|
|
|
5076
5164
|
const layer = requireEffectLayer(layers, id, "change its effects");
|
|
5077
5165
|
const next = { ...layer };
|
|
5078
5166
|
if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
|
|
5079
|
-
guard(() =>
|
|
5167
|
+
guard(() => _chunkWT6ZAWJPcjs.validateLayerEffects.call(void 0, effects));
|
|
5080
5168
|
next.effects = effects;
|
|
5081
5169
|
} else delete next.effects;
|
|
5082
|
-
return
|
|
5170
|
+
return _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
5083
5171
|
}
|
|
5084
5172
|
function addLayerEffect(layers, id, kind, params = {}, index) {
|
|
5085
|
-
if (!
|
|
5173
|
+
if (!_chunkWT6ZAWJPcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkWT6ZAWJPcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
|
|
5086
5174
|
const layer = requireEffectLayer(layers, id, "add effects");
|
|
5087
5175
|
const current = layerEffectsOf(layer);
|
|
5088
5176
|
const ids = new Set(current.items.map((e) => e.id));
|
|
5089
|
-
let effectId =
|
|
5090
|
-
while (ids.has(effectId)) effectId =
|
|
5177
|
+
let effectId = _chunkWT6ZAWJPcjs.newEffectId.call(void 0, );
|
|
5178
|
+
while (ids.has(effectId)) effectId = _chunkWT6ZAWJPcjs.newEffectId.call(void 0, );
|
|
5091
5179
|
const { id: _ignored, kind: _kind, ...rest } = params;
|
|
5092
|
-
const effect = guard(() =>
|
|
5180
|
+
const effect = guard(() => _chunkWT6ZAWJPcjs.mergeLayerEffect.call(void 0, _chunkWT6ZAWJPcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
|
|
5093
5181
|
const items = [...current.items];
|
|
5094
5182
|
const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
|
|
5095
5183
|
items.splice(at, 0, effect);
|
|
@@ -5106,7 +5194,7 @@ function updateLayerEffect(layers, id, effectId, changes) {
|
|
|
5106
5194
|
const i = requireEffect(layer, effectId);
|
|
5107
5195
|
const current = layer.effects;
|
|
5108
5196
|
const items = [...current.items];
|
|
5109
|
-
items[i] = guard(() =>
|
|
5197
|
+
items[i] = guard(() => _chunkWT6ZAWJPcjs.mergeLayerEffect.call(void 0, items[i], changes));
|
|
5110
5198
|
return setLayerEffects(layers, id, { ...current, items });
|
|
5111
5199
|
}
|
|
5112
5200
|
function removeLayerEffect(layers, id, effectId) {
|
|
@@ -5363,7 +5451,7 @@ var PsdWriter = (_class4 = class {constructor() { _class4.prototype.__init24.cal
|
|
|
5363
5451
|
function decodeLegacyName(b) {
|
|
5364
5452
|
try {
|
|
5365
5453
|
return new TextDecoder("utf-8", { fatal: true }).decode(b);
|
|
5366
|
-
} catch (
|
|
5454
|
+
} catch (e14) {
|
|
5367
5455
|
return String.fromCharCode(...b);
|
|
5368
5456
|
}
|
|
5369
5457
|
}
|
|
@@ -5865,7 +5953,7 @@ function parseAdjustmentBlock(key, data) {
|
|
|
5865
5953
|
default:
|
|
5866
5954
|
return null;
|
|
5867
5955
|
}
|
|
5868
|
-
} catch (
|
|
5956
|
+
} catch (e15) {
|
|
5869
5957
|
return null;
|
|
5870
5958
|
}
|
|
5871
5959
|
}
|
|
@@ -6041,9 +6129,9 @@ function packbitsDecodeInto(src, expected, out, at) {
|
|
|
6041
6129
|
function inflateChecked(data, expected) {
|
|
6042
6130
|
let out;
|
|
6043
6131
|
try {
|
|
6044
|
-
out =
|
|
6132
|
+
out = _chunkWT6ZAWJPcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
|
|
6045
6133
|
} catch (e) {
|
|
6046
|
-
throw new PsdError(`ZIP channel data: ${e instanceof
|
|
6134
|
+
throw new PsdError(`ZIP channel data: ${e instanceof _chunkWT6ZAWJPcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
|
|
6047
6135
|
}
|
|
6048
6136
|
if (out.length < expected) throw new PsdError(`ZIP stream produced ${out.length} of ${expected} bytes.`);
|
|
6049
6137
|
return out.length === expected ? out : out.subarray(0, expected);
|
|
@@ -6175,6 +6263,7 @@ var CHANNEL_USER_MASK = -2;
|
|
|
6175
6263
|
var CHANNEL_REAL_USER_MASK = -3;
|
|
6176
6264
|
var LAYER_FLAG_TRANSPARENCY_PROTECTED = 1;
|
|
6177
6265
|
var LAYER_FLAG_HIDDEN = 2;
|
|
6266
|
+
var MASK_FLAG_UNLINKED = 1;
|
|
6178
6267
|
var MASK_FLAG_DISABLED = 2;
|
|
6179
6268
|
var MASK_FLAG_PARAMETERS = 16;
|
|
6180
6269
|
var SECTION_OTHER = 0;
|
|
@@ -6282,7 +6371,7 @@ function parseMask(d) {
|
|
|
6282
6371
|
}
|
|
6283
6372
|
if (!realFirst) m.real = readReal();
|
|
6284
6373
|
return m;
|
|
6285
|
-
} catch (
|
|
6374
|
+
} catch (e16) {
|
|
6286
6375
|
return void 0;
|
|
6287
6376
|
}
|
|
6288
6377
|
}
|
|
@@ -6363,7 +6452,7 @@ function layerName(rec) {
|
|
|
6363
6452
|
if (luni) {
|
|
6364
6453
|
try {
|
|
6365
6454
|
return new PsdReader(luni).unicode();
|
|
6366
|
-
} catch (
|
|
6455
|
+
} catch (e17) {
|
|
6367
6456
|
}
|
|
6368
6457
|
}
|
|
6369
6458
|
return rec.legacyName;
|
|
@@ -6780,34 +6869,34 @@ function blendOf(d, key, fallback, notes) {
|
|
|
6780
6869
|
function colorOf(d, fallback = "#000000") {
|
|
6781
6870
|
if (!d) return fallback;
|
|
6782
6871
|
const g = (k) => descNumber(d, k);
|
|
6783
|
-
if (g("redFloat") !== void 0) return
|
|
6872
|
+
if (g("redFloat") !== void 0) return _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
|
|
6784
6873
|
switch (d.classId) {
|
|
6785
6874
|
case "HSBC": {
|
|
6786
6875
|
const rgb = decodePsdColor(1, [(_nullishCoalesce(g("H "), () => ( 0))) / 360 * 65535, (_nullishCoalesce(g("Strt"), () => ( 0))) / 100 * 65535, (_nullishCoalesce(g("Brgh"), () => ( 0))) / 100 * 65535]);
|
|
6787
|
-
return rgb ?
|
|
6876
|
+
return rgb ? _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
6788
6877
|
}
|
|
6789
6878
|
case "CMYC": {
|
|
6790
6879
|
const inv = (k) => (1 - (_nullishCoalesce(g(k), () => ( 0))) / 100) * 65535;
|
|
6791
6880
|
const rgb = decodePsdColor(2, [inv("Cyn "), inv("Mgnt"), inv("Ylw "), inv("Blck")]);
|
|
6792
|
-
return rgb ?
|
|
6881
|
+
return rgb ? _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
6793
6882
|
}
|
|
6794
6883
|
case "LbCl": {
|
|
6795
6884
|
const rgb = decodePsdColor(7, [(_nullishCoalesce(g("Lmnc"), () => ( 0))) * 100, Math.round((_nullishCoalesce(g("A "), () => ( 0))) * 100) & 65535, Math.round((_nullishCoalesce(g("B "), () => ( 0))) * 100) & 65535]);
|
|
6796
|
-
return rgb ?
|
|
6885
|
+
return rgb ? _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
6797
6886
|
}
|
|
6798
6887
|
case "Grsc": {
|
|
6799
6888
|
const v = 1 - (_nullishCoalesce(g("Gry "), () => ( 0))) / 100;
|
|
6800
|
-
return
|
|
6889
|
+
return _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, [v, v, v]);
|
|
6801
6890
|
}
|
|
6802
6891
|
}
|
|
6803
6892
|
const r = g("Rd ");
|
|
6804
6893
|
const gr = g("Grn ");
|
|
6805
6894
|
const b = g("Bl ");
|
|
6806
6895
|
if (r === void 0 || gr === void 0 || b === void 0) return fallback;
|
|
6807
|
-
return
|
|
6896
|
+
return _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
|
|
6808
6897
|
}
|
|
6809
6898
|
function colorDesc(hex) {
|
|
6810
|
-
const [r, g, b] = _nullishCoalesce(
|
|
6899
|
+
const [r, g, b] = _nullishCoalesce(_chunkWT6ZAWJPcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
|
|
6811
6900
|
return descriptor("RGBC", [
|
|
6812
6901
|
["Rd ", dbl(r * 255)],
|
|
6813
6902
|
["Grn ", dbl(g * 255)],
|
|
@@ -6890,9 +6979,9 @@ function gradientOf(d, notes) {
|
|
|
6890
6979
|
raw.forEach((s, i) => {
|
|
6891
6980
|
if (i > 0 && Math.abs(s.mid - 0.5) > 1e-3) {
|
|
6892
6981
|
const a = raw[i - 1];
|
|
6893
|
-
const ca =
|
|
6894
|
-
const cb =
|
|
6895
|
-
stops.push({ position: a.position + (s.position - a.position) * s.mid, color:
|
|
6982
|
+
const ca = _chunkWT6ZAWJPcjs.parseEffectColor.call(void 0, a.color);
|
|
6983
|
+
const cb = _chunkWT6ZAWJPcjs.parseEffectColor.call(void 0, s.color);
|
|
6984
|
+
stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
|
|
6896
6985
|
notes.add("gradient midpoints are drawn as straight segments");
|
|
6897
6986
|
}
|
|
6898
6987
|
stops.push({ position: s.position, color: s.color });
|
|
@@ -7004,8 +7093,8 @@ var KINDS = [
|
|
|
7004
7093
|
["FrFX", "frameFXMulti", "stroke"]
|
|
7005
7094
|
];
|
|
7006
7095
|
function common(d, kind, notes) {
|
|
7007
|
-
const def =
|
|
7008
|
-
return { id:
|
|
7096
|
+
const def = _chunkWT6ZAWJPcjs.defaultLayerEffect.call(void 0, kind, "x");
|
|
7097
|
+
return { id: _chunkWT6ZAWJPcjs.newEffectId.call(void 0, ), enabled: descBool(d, "enab") !== false, blend: blendOf(d, "Md ", def.blend, notes), opacity: clamp3(pct(d, "Opct", def.opacity), 0, 1) };
|
|
7009
7098
|
}
|
|
7010
7099
|
function readOne(kind, d, notes) {
|
|
7011
7100
|
const size = (key, fallback) => clamp3(num2(d, key, fallback), 0, 250);
|
|
@@ -7048,7 +7137,7 @@ function readOne(kind, d, notes) {
|
|
|
7048
7137
|
case "bevel-emboss": {
|
|
7049
7138
|
const styles = { OtrB: "outer-bevel", InrB: "inner-bevel", Embs: "emboss", PlEb: "pillow-emboss", strokeEmboss: "stroke-emboss" };
|
|
7050
7139
|
const out = {
|
|
7051
|
-
id:
|
|
7140
|
+
id: _chunkWT6ZAWJPcjs.newEffectId.call(void 0, ),
|
|
7052
7141
|
enabled: descBool(d, "enab") !== false,
|
|
7053
7142
|
kind,
|
|
7054
7143
|
style: _nullishCoalesce(styles[_nullishCoalesce(enumOf(d, "bvlS"), () => ( ""))], () => ( "inner-bevel")),
|
|
@@ -7114,7 +7203,7 @@ function parseLfx2(data) {
|
|
|
7114
7203
|
let d;
|
|
7115
7204
|
try {
|
|
7116
7205
|
d = parseVersionedDescriptor(data.subarray(4));
|
|
7117
|
-
} catch (
|
|
7206
|
+
} catch (e18) {
|
|
7118
7207
|
return null;
|
|
7119
7208
|
}
|
|
7120
7209
|
const notes = /* @__PURE__ */ new Set();
|
|
@@ -7259,10 +7348,10 @@ function writeLfx2(effects) {
|
|
|
7259
7348
|
["Scl ", unit("#Prc", 100)],
|
|
7260
7349
|
["masterFXSwitch", boolV(effects.enabled)]
|
|
7261
7350
|
];
|
|
7262
|
-
const scale =
|
|
7351
|
+
const scale = _chunkWT6ZAWJPcjs.effectsScale.call(void 0, effects);
|
|
7263
7352
|
let dropped = 0;
|
|
7264
7353
|
for (const [single, multi, kind] of KINDS) {
|
|
7265
|
-
const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(
|
|
7354
|
+
const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkWT6ZAWJPcjs.scaleLayerEffect.call(void 0, e, scale)));
|
|
7266
7355
|
if (!of.length) continue;
|
|
7267
7356
|
if (of.length === 1) items.push([single, obj(of[0])]);
|
|
7268
7357
|
else if (multi) items.push([multi, { type: "VlLs", items: of.map(obj) }]);
|
|
@@ -7294,7 +7383,7 @@ function parseLrfx(data) {
|
|
|
7294
7383
|
const colorAt = (rd) => {
|
|
7295
7384
|
rd.u16();
|
|
7296
7385
|
const c = [rd.u16(), rd.u16(), rd.u16(), rd.u16()];
|
|
7297
|
-
return
|
|
7386
|
+
return _chunkWT6ZAWJPcjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
|
|
7298
7387
|
};
|
|
7299
7388
|
const blendAt = (rd) => {
|
|
7300
7389
|
rd.skip(4);
|
|
@@ -7313,7 +7402,7 @@ function parseLrfx(data) {
|
|
|
7313
7402
|
const enabled = b.u8() !== 0;
|
|
7314
7403
|
const useGlobalLight = b.u8() !== 0;
|
|
7315
7404
|
const opacity = b.u8() / 255;
|
|
7316
|
-
const base = { id:
|
|
7405
|
+
const base = { id: _chunkWT6ZAWJPcjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
|
|
7317
7406
|
items.push(key === "dsdw" ? { ...base, kind: "drop-shadow", spread: 0, knocksOut: true } : { ...base, kind: "inner-shadow", choke: 0 });
|
|
7318
7407
|
} else if (key === "oglw" || key === "iglw") {
|
|
7319
7408
|
b.u32();
|
|
@@ -7323,7 +7412,7 @@ function parseLrfx(data) {
|
|
|
7323
7412
|
const blend = blendAt(b);
|
|
7324
7413
|
const enabled = b.u8() !== 0;
|
|
7325
7414
|
const opacity = b.u8() / 255;
|
|
7326
|
-
const base = { id:
|
|
7415
|
+
const base = { id: _chunkWT6ZAWJPcjs.newEffectId.call(void 0, ), enabled, blend, opacity, fill: { type: "color", color }, technique: "softer", size: clamp3(blur, 0, 250), antiAlias: false, range: 0.5, jitter: 0, noise: 0 };
|
|
7327
7416
|
items.push(key === "oglw" ? { ...base, kind: "outer-glow", spread: 0 } : { ...base, kind: "inner-glow", choke: 0, source: "edge" });
|
|
7328
7417
|
} else if (key === "sofi") {
|
|
7329
7418
|
b.u32();
|
|
@@ -7331,11 +7420,11 @@ function parseLrfx(data) {
|
|
|
7331
7420
|
const color = colorAt(b);
|
|
7332
7421
|
const opacity = b.u8() / 255;
|
|
7333
7422
|
const enabled = b.u8() !== 0;
|
|
7334
|
-
items.push({ id:
|
|
7423
|
+
items.push({ id: _chunkWT6ZAWJPcjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
|
|
7335
7424
|
} else if (key === "bevl") notes.add("legacy bevels are not read");
|
|
7336
7425
|
}
|
|
7337
7426
|
return { effects: { enabled: true, items }, notes: [...notes] };
|
|
7338
|
-
} catch (
|
|
7427
|
+
} catch (e19) {
|
|
7339
7428
|
return null;
|
|
7340
7429
|
}
|
|
7341
7430
|
}
|
|
@@ -7604,6 +7693,7 @@ function recordMask(ctx, rec, name) {
|
|
|
7604
7693
|
if (m.userDensity !== void 0 && m.userDensity < 255) mask.density = percent(m.userDensity);
|
|
7605
7694
|
if (m.userFeather !== void 0 && m.userFeather > 0) mask.feather = Math.min(1e3, m.userFeather);
|
|
7606
7695
|
if (flags & MASK_FLAG_DISABLED) mask.enabled = false;
|
|
7696
|
+
if (flags & MASK_FLAG_UNLINKED) mask.linked = false;
|
|
7607
7697
|
return mask;
|
|
7608
7698
|
}
|
|
7609
7699
|
function baseProps(ctx, rec, name, notes) {
|
|
@@ -7657,7 +7747,7 @@ function recordEffects(ctx, rec, name, notes, group) {
|
|
|
7657
7747
|
}
|
|
7658
7748
|
for (const e of parsed.effects.items) {
|
|
7659
7749
|
for (const id of patternIds(e)) {
|
|
7660
|
-
if (ctx.patterns.has(id) ||
|
|
7750
|
+
if (ctx.patterns.has(id) || _chunkWT6ZAWJPcjs.builtinPattern.call(void 0, id)) continue;
|
|
7661
7751
|
ctx.warn.add("A pattern effect uses a pattern the file does not contain, and paints nothing", name);
|
|
7662
7752
|
notes.push(`pattern "${id}" is not in the file`);
|
|
7663
7753
|
}
|
|
@@ -7890,7 +7980,8 @@ function maskChannel(mask, ox, oy, psb) {
|
|
|
7890
7980
|
if (mask.source) throw new PsdError("A parametric mask must be baked before export.");
|
|
7891
7981
|
const bounds = _chunkCRMAXIUVcjs.contentBounds.call(void 0, mask.surface);
|
|
7892
7982
|
const def = mask.defaultValue;
|
|
7893
|
-
const
|
|
7983
|
+
const flags = (mask.enabled === false ? MASK_FLAG_DISABLED : 0) | (mask.linked === false ? MASK_FLAG_UNLINKED : 0);
|
|
7984
|
+
const m = { rect: EMPTY_RECT, defaultColor: def, flags };
|
|
7894
7985
|
if ((_nullishCoalesce(mask.density, () => ( 1))) < 1) m.userDensity = Math.round(Math.max(0, _nullishCoalesce(mask.density, () => ( 1))) * 255);
|
|
7895
7986
|
if ((_nullishCoalesce(mask.feather, () => ( 0))) > 0) m.userFeather = mask.feather;
|
|
7896
7987
|
if (!bounds) return { channel: emptyChannel(CHANNEL_USER_MASK), mask: m };
|
|
@@ -7919,7 +8010,7 @@ function exportPsd(input) {
|
|
|
7919
8010
|
const key = layer.type === "group" ? "lfxs" : "lfx2";
|
|
7920
8011
|
if (fx.psd) {
|
|
7921
8012
|
const original = parseLfx2(fx.psd.data);
|
|
7922
|
-
if (original ?
|
|
8013
|
+
if (original ? _chunkWT6ZAWJPcjs.effectsFingerprint.call(void 0, original.effects) === _chunkWT6ZAWJPcjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
|
|
7923
8014
|
}
|
|
7924
8015
|
if (!fx.items.length && fx.enabled && (_nullishCoalesce(fx.scale, () => ( 1))) === 1) return null;
|
|
7925
8016
|
const { data, dropped } = writeLfx2(fx);
|
|
@@ -8064,7 +8155,7 @@ function exportPsd(input) {
|
|
|
8064
8155
|
const byId = new Map((_nullishCoalesce(input.patterns, () => ( []))).map((p) => [p.id, p]));
|
|
8065
8156
|
const embed = [];
|
|
8066
8157
|
for (const id of patternIds2) {
|
|
8067
|
-
const p = _nullishCoalesce(byId.get(id), () => (
|
|
8158
|
+
const p = _nullishCoalesce(byId.get(id), () => ( _chunkWT6ZAWJPcjs.builtinPattern.call(void 0, id)));
|
|
8068
8159
|
if (p) embed.push(p);
|
|
8069
8160
|
else note(`Pattern "${id}" is not in the document and was not embedded`, id);
|
|
8070
8161
|
}
|
|
@@ -8087,6 +8178,499 @@ function exportPsd(input) {
|
|
|
8087
8178
|
return { bytes, psb, records: records.length, warnings };
|
|
8088
8179
|
}
|
|
8089
8180
|
|
|
8181
|
+
// src/image-editor/transform.ts
|
|
8182
|
+
var FREE_TRANSFORM_MODES = ["scale", "rotate", "skew", "distort", "perspective", "warp"];
|
|
8183
|
+
var TRANSFORM_ANCHORS = ["top-left", "top", "top-right", "left", "center", "right", "bottom-left", "bottom", "bottom-right"];
|
|
8184
|
+
var ANCHOR_FRACTION = {
|
|
8185
|
+
"top-left": [0, 0],
|
|
8186
|
+
top: [0.5, 0],
|
|
8187
|
+
"top-right": [1, 0],
|
|
8188
|
+
left: [0, 0.5],
|
|
8189
|
+
center: [0.5, 0.5],
|
|
8190
|
+
right: [1, 0.5],
|
|
8191
|
+
"bottom-left": [0, 1],
|
|
8192
|
+
bottom: [0.5, 1],
|
|
8193
|
+
"bottom-right": [1, 1]
|
|
8194
|
+
};
|
|
8195
|
+
function isTransformAnchor(value) {
|
|
8196
|
+
return typeof value === "string" && value in ANCHOR_FRACTION;
|
|
8197
|
+
}
|
|
8198
|
+
function identityTransform(box) {
|
|
8199
|
+
return { box: { ...box }, corners: _chunkMUUXNRU4cjs.boxQuad.call(void 0, box) };
|
|
8200
|
+
}
|
|
8201
|
+
function cornersFromMatrix(box, m) {
|
|
8202
|
+
const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, box);
|
|
8203
|
+
return [_chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[0]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[1]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[2]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[3])];
|
|
8204
|
+
}
|
|
8205
|
+
function matrixFromCorners(box, corners, eps = 1e-6) {
|
|
8206
|
+
const [tl, tr, br, bl] = corners;
|
|
8207
|
+
const size = 1 + Math.max(box.width, box.height);
|
|
8208
|
+
if (Math.abs(tl.x + br.x - tr.x - bl.x) > eps * size || Math.abs(tl.y + br.y - tr.y - bl.y) > eps * size) return null;
|
|
8209
|
+
const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, box, corners);
|
|
8210
|
+
return h ? _chunkMUUXNRU4cjs.affineFromHomography.call(void 0, h, 1e-9) : null;
|
|
8211
|
+
}
|
|
8212
|
+
function transformHomography(geometry) {
|
|
8213
|
+
const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
|
|
8214
|
+
if (!h) return null;
|
|
8215
|
+
return _chunkMUUXNRU4cjs.homographyKeepsQuad.call(void 0, h, _chunkMUUXNRU4cjs.boxQuad.call(void 0, geometry.box)) ? h : null;
|
|
8216
|
+
}
|
|
8217
|
+
function hasWarp(geometry) {
|
|
8218
|
+
const w = geometry.warp;
|
|
8219
|
+
if (!w) return false;
|
|
8220
|
+
const id = _chunkDWGZUSEScjs.identityWarpMesh.call(void 0, geometry.box, w.us.length - 1, w.vs.length - 1);
|
|
8221
|
+
if (id.points.length !== w.points.length || id.us.some((u, i) => Math.abs(u - w.us[i]) > 1e-12) || id.vs.some((v, i) => Math.abs(v - w.vs[i]) > 1e-12)) return true;
|
|
8222
|
+
return w.points.some((p, i) => Math.abs(p.x - id.points[i].x) > 1e-6 || Math.abs(p.y - id.points[i].y) > 1e-6);
|
|
8223
|
+
}
|
|
8224
|
+
function isIdentityTransform(geometry) {
|
|
8225
|
+
if (hasWarp(geometry)) return false;
|
|
8226
|
+
const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, geometry.box);
|
|
8227
|
+
return geometry.corners.every((c, i) => Math.abs(c.x - q2[i].x) < 1e-6 && Math.abs(c.y - q2[i].y) < 1e-6);
|
|
8228
|
+
}
|
|
8229
|
+
function transformMap(geometry) {
|
|
8230
|
+
const h = transformHomography(geometry);
|
|
8231
|
+
if (!h) return null;
|
|
8232
|
+
const { box } = geometry;
|
|
8233
|
+
const warp = hasWarp(geometry) ? geometry.warp : null;
|
|
8234
|
+
if (!warp) return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p);
|
|
8235
|
+
return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, _chunkDWGZUSEScjs.evalWarpMesh.call(void 0, warp, (p.x - box.x) / box.width, (p.y - box.y) / box.height));
|
|
8236
|
+
}
|
|
8237
|
+
function transformedPoint(geometry, fx, fy) {
|
|
8238
|
+
const f = transformMap(geometry);
|
|
8239
|
+
const { box } = geometry;
|
|
8240
|
+
return f ? f({ x: box.x + fx * box.width, y: box.y + fy * box.height }) : null;
|
|
8241
|
+
}
|
|
8242
|
+
function anchorPoint(geometry, anchor) {
|
|
8243
|
+
const [fx, fy] = ANCHOR_FRACTION[anchor];
|
|
8244
|
+
const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
|
|
8245
|
+
const p = { x: geometry.box.x + fx * geometry.box.width, y: geometry.box.y + fy * geometry.box.height };
|
|
8246
|
+
return _nullishCoalesce((h && _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p)), () => ( p));
|
|
8247
|
+
}
|
|
8248
|
+
function transformedBox(geometry) {
|
|
8249
|
+
const f = transformMap(geometry);
|
|
8250
|
+
if (!f) return null;
|
|
8251
|
+
const { box } = geometry;
|
|
8252
|
+
const pts = [];
|
|
8253
|
+
const n = hasWarp(geometry) ? 16 : 1;
|
|
8254
|
+
for (let i = 0; i <= n; i++) {
|
|
8255
|
+
const t = i / n;
|
|
8256
|
+
for (const [fx, fy] of [[t, 0], [1, t], [1 - t, 1], [0, 1 - t]]) {
|
|
8257
|
+
const p = f({ x: box.x + fx * box.width, y: box.y + fy * box.height });
|
|
8258
|
+
if (!p) return null;
|
|
8259
|
+
pts.push(p);
|
|
8260
|
+
}
|
|
8261
|
+
}
|
|
8262
|
+
const xs = pts.map((p) => p.x);
|
|
8263
|
+
const ys = pts.map((p) => p.y);
|
|
8264
|
+
const x = Math.min(...xs);
|
|
8265
|
+
const y = Math.min(...ys);
|
|
8266
|
+
return { x, y, width: Math.max(...xs) - x, height: Math.max(...ys) - y };
|
|
8267
|
+
}
|
|
8268
|
+
function referencePoint(box, reference) {
|
|
8269
|
+
if (reference && typeof reference === "object") return { x: reference.x, y: reference.y };
|
|
8270
|
+
const [fx, fy] = ANCHOR_FRACTION[_nullishCoalesce(reference, () => ( "center"))];
|
|
8271
|
+
return { x: box.x + fx * box.width, y: box.y + fy * box.height };
|
|
8272
|
+
}
|
|
8273
|
+
function matrixFromParams(box, params) {
|
|
8274
|
+
const sx = (_nullishCoalesce(params.scaleX, () => ( 100))) / 100;
|
|
8275
|
+
const sy = (_nullishCoalesce(params.scaleY, () => ( 100))) / 100;
|
|
8276
|
+
const tx = Math.tan((_nullishCoalesce(params.skewX, () => ( 0))) * Math.PI / 180);
|
|
8277
|
+
const ty = Math.tan((_nullishCoalesce(params.skewY, () => ( 0))) * Math.PI / 180);
|
|
8278
|
+
const ref = referencePoint(box, params.reference);
|
|
8279
|
+
const linear = _chunkDWGZUSEScjs.multiplyMatrices.call(void 0, _chunkDWGZUSEScjs.multiplyMatrices.call(void 0, [1, ty, tx, 1, 0, 0], [sx, 0, 0, sy, 0, 0]), _chunkDWGZUSEScjs.rotateMatrix.call(void 0, _nullishCoalesce(params.rotate, () => ( 0))));
|
|
8280
|
+
return _chunkDWGZUSEScjs.multiplyMatrices.call(void 0, _chunkDWGZUSEScjs.matrixAbout.call(void 0, linear, ref), _chunkDWGZUSEScjs.translateMatrix.call(void 0, _nullishCoalesce(params.dx, () => ( 0)), _nullishCoalesce(params.dy, () => ( 0))));
|
|
8281
|
+
}
|
|
8282
|
+
function describeTransform(geometry, reference = "center") {
|
|
8283
|
+
const m = hasWarp(geometry) ? null : matrixFromCorners(geometry.box, geometry.corners);
|
|
8284
|
+
const ref = referencePoint(geometry.box, reference);
|
|
8285
|
+
const bounds = transformedBox(geometry);
|
|
8286
|
+
if (!m) {
|
|
8287
|
+
const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
|
|
8288
|
+
const at2 = _nullishCoalesce((h && _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, ref)), () => ( ref));
|
|
8289
|
+
return { affine: false, scaleX: 100, scaleY: 100, rotate: 0, skewX: 0, x: at2.x, y: at2.y, bounds, corners: geometry.corners };
|
|
8290
|
+
}
|
|
8291
|
+
const [a, b, c, d] = m;
|
|
8292
|
+
const sxAbs = Math.hypot(a, b);
|
|
8293
|
+
const rot = Math.atan2(b, a) * 180 / Math.PI;
|
|
8294
|
+
const shear = sxAbs ? (a * c + b * d) / sxAbs : 0;
|
|
8295
|
+
const sy = sxAbs ? (a * d - b * c) / sxAbs : 0;
|
|
8296
|
+
const skew = sxAbs ? Math.atan(shear / sxAbs) * 180 / Math.PI : 0;
|
|
8297
|
+
const at = _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, ref);
|
|
8298
|
+
const clean = (v) => Math.abs(v) < 1e-9 ? 0 : v;
|
|
8299
|
+
return {
|
|
8300
|
+
affine: true,
|
|
8301
|
+
scaleX: clean(sxAbs * 100),
|
|
8302
|
+
scaleY: clean(sy * 100),
|
|
8303
|
+
rotate: clean(rot === -180 ? 180 : rot),
|
|
8304
|
+
skewX: clean(skew),
|
|
8305
|
+
x: at.x,
|
|
8306
|
+
y: at.y,
|
|
8307
|
+
bounds,
|
|
8308
|
+
corners: geometry.corners
|
|
8309
|
+
};
|
|
8310
|
+
}
|
|
8311
|
+
function applyParams(geometry, params) {
|
|
8312
|
+
const ref = params.reference && typeof params.reference === "object" ? params.reference : anchorPoint(geometry, _nullishCoalesce(params.reference, () => ( "center")));
|
|
8313
|
+
const m = matrixFromParams({ x: ref.x, y: ref.y, width: 0, height: 0 }, { ...params, reference: ref });
|
|
8314
|
+
const c = geometry.corners;
|
|
8315
|
+
return [_chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[0]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[1]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[2]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[3])];
|
|
8316
|
+
}
|
|
8317
|
+
function flipCorners(geometry, axis) {
|
|
8318
|
+
const c = anchorPoint(geometry, "center");
|
|
8319
|
+
const m = axis === "horizontal" ? [-1, 0, 0, 1, 2 * c.x, 0] : [1, 0, 0, -1, 0, 2 * c.y];
|
|
8320
|
+
const q2 = geometry.corners;
|
|
8321
|
+
return [_chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[0]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[1]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[2]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[3])];
|
|
8322
|
+
}
|
|
8323
|
+
function boxPointOf(geometry, p) {
|
|
8324
|
+
const m = matrixFromCorners(geometry.box, geometry.corners);
|
|
8325
|
+
if (m) return _chunkDWGZUSEScjs.applyMatrix.call(void 0, _chunkDWGZUSEScjs.invertMatrix.call(void 0, m), p);
|
|
8326
|
+
return null;
|
|
8327
|
+
}
|
|
8328
|
+
function presetWarp(box, preset) {
|
|
8329
|
+
return _chunkDWGZUSEScjs.warpPresetMesh.call(void 0, preset, box);
|
|
8330
|
+
}
|
|
8331
|
+
function isValidWarp(mesh) {
|
|
8332
|
+
return _chunkDWGZUSEScjs.isValidWarpMesh.call(void 0, mesh);
|
|
8333
|
+
}
|
|
8334
|
+
function geometryHomography(geometry) {
|
|
8335
|
+
const m = matrixFromCorners(geometry.box, geometry.corners);
|
|
8336
|
+
return m ? _chunkMUUXNRU4cjs.homographyFromAffine.call(void 0, m) : transformHomography(geometry);
|
|
8337
|
+
}
|
|
8338
|
+
|
|
8339
|
+
// src/image-editor/free-transform.ts
|
|
8340
|
+
var FREE_TRANSFORM_CONTENTS = ["auto", "layer", "selection", "selection-copy", "selection-outline"];
|
|
8341
|
+
var fail2 = (message) => {
|
|
8342
|
+
throw new LayerOperationError(message);
|
|
8343
|
+
};
|
|
8344
|
+
var T = (x, y) => [1, 0, x, 0, 1, y, 0, 0, 1];
|
|
8345
|
+
function previewStep(scale) {
|
|
8346
|
+
if (!scale || !(scale > 0) || scale >= 1) return 1;
|
|
8347
|
+
return Math.min(8, 2 ** Math.floor(Math.log2(1 / scale)));
|
|
8348
|
+
}
|
|
8349
|
+
function toDoc(r, o) {
|
|
8350
|
+
return r ? { x: r.x + o.x, y: r.y + o.y, width: r.width, height: r.height } : null;
|
|
8351
|
+
}
|
|
8352
|
+
function selectionSurface(sel) {
|
|
8353
|
+
return _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width: sel.width, height: sel.height, data: sel.data }, 1, 0, 0, 0);
|
|
8354
|
+
}
|
|
8355
|
+
function liftPixels(surface, sel, o) {
|
|
8356
|
+
const sb = sel.bounds;
|
|
8357
|
+
const area = { x: sb.x - o.x, y: sb.y - o.y, width: sb.width, height: sb.height };
|
|
8358
|
+
const px2 = _chunkCRMAXIUVcjs.readRegion.call(void 0, surface, area);
|
|
8359
|
+
const kept = new Uint8ClampedArray(px2);
|
|
8360
|
+
for (let y = 0; y < area.height; y++) {
|
|
8361
|
+
for (let x = 0; x < area.width; x++) {
|
|
8362
|
+
const k = sel.data[(sb.y + y) * sel.width + sb.x + x] / 255;
|
|
8363
|
+
const i = (y * area.width + x) * 4;
|
|
8364
|
+
if (k <= 0) {
|
|
8365
|
+
px2[i] = px2[i + 1] = px2[i + 2] = px2[i + 3] = 0;
|
|
8366
|
+
continue;
|
|
8367
|
+
}
|
|
8368
|
+
px2[i + 3] = px2[i + 3] * k;
|
|
8369
|
+
if (!px2[i + 3]) px2[i] = px2[i + 1] = px2[i + 2] = 0;
|
|
8370
|
+
kept[i + 3] = kept[i + 3] * (1 - k);
|
|
8371
|
+
if (!kept[i + 3]) kept[i] = kept[i + 1] = kept[i + 2] = 0;
|
|
8372
|
+
}
|
|
8373
|
+
}
|
|
8374
|
+
return { lifted: _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width: area.width, height: area.height, data: px2 }, 4, area.x, area.y), rest: _chunkCRMAXIUVcjs.writeRegion.call(void 0, surface, area, kept) };
|
|
8375
|
+
}
|
|
8376
|
+
function liftMask(mask, sel, o) {
|
|
8377
|
+
const sb = sel.bounds;
|
|
8378
|
+
const area = { x: sb.x - o.x, y: sb.y - o.y, width: sb.width, height: sb.height };
|
|
8379
|
+
const v = _chunkCRMAXIUVcjs.readRegion.call(void 0, mask, area);
|
|
8380
|
+
const def = mask.defaultValue;
|
|
8381
|
+
const lifted = new Uint8ClampedArray(area.width * area.height * 4);
|
|
8382
|
+
const rest = new Uint8ClampedArray(v.length);
|
|
8383
|
+
for (let y = 0; y < area.height; y++) {
|
|
8384
|
+
for (let x = 0; x < area.width; x++) {
|
|
8385
|
+
const i = y * area.width + x;
|
|
8386
|
+
const k = sel.data[(sb.y + y) * sel.width + sb.x + x] / 255;
|
|
8387
|
+
const g = v[i];
|
|
8388
|
+
if (k > 0) {
|
|
8389
|
+
lifted[i * 4] = lifted[i * 4 + 1] = lifted[i * 4 + 2] = g;
|
|
8390
|
+
lifted[i * 4 + 3] = k * 255;
|
|
8391
|
+
}
|
|
8392
|
+
rest[i] = g * (1 - k) + def * k;
|
|
8393
|
+
}
|
|
8394
|
+
}
|
|
8395
|
+
return { lifted: _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width: area.width, height: area.height, data: lifted }, 4, area.x, area.y), rest: _chunkCRMAXIUVcjs.writeRegion.call(void 0, mask, area, rest) };
|
|
8396
|
+
}
|
|
8397
|
+
var FreeTransformSession = (_class6 = class {
|
|
8398
|
+
constructor(host, init = {}) {;_class6.prototype.__init28.call(this);_class6.prototype.__init29.call(this);_class6.prototype.__init30.call(this);
|
|
8399
|
+
this.host = host;
|
|
8400
|
+
if (init.interpolation !== void 0 && !_chunkWT6ZAWJPcjs.isInterpolation.call(void 0, init.interpolation)) fail2(`Unknown interpolation "${String(init.interpolation)}"; use nearest, bilinear or bicubic.`);
|
|
8401
|
+
this.interp = _nullishCoalesce(init.interpolation, () => ( "bicubic"));
|
|
8402
|
+
const sel = host.selection();
|
|
8403
|
+
const selected = Boolean(_optionalChain([sel, 'optionalAccess', _133 => _133.bounds]));
|
|
8404
|
+
let content = _nullishCoalesce(init.content, () => ( "auto"));
|
|
8405
|
+
if (!["auto", "layer", "selection", "selection-copy", "selection-outline"].includes(content)) {
|
|
8406
|
+
fail2(`Unknown content "${String(content)}"; use auto, layer, selection, selection-copy or selection-outline.`);
|
|
8407
|
+
}
|
|
8408
|
+
if (content === "auto") content = selected ? "selection" : "layer";
|
|
8409
|
+
this.content = content;
|
|
8410
|
+
if (content !== "layer" && !selected) fail2(`Nothing is selected; ${content} needs a selection. Select first, or use content layer.`);
|
|
8411
|
+
const layers = host.layers();
|
|
8412
|
+
this.startLayers = layers;
|
|
8413
|
+
this.startSelection = sel;
|
|
8414
|
+
this.startActive = host.activeLayerId();
|
|
8415
|
+
this.before = host.capture();
|
|
8416
|
+
const moves = [];
|
|
8417
|
+
let box = null;
|
|
8418
|
+
if (content === "selection-outline") {
|
|
8419
|
+
this.layerId = null;
|
|
8420
|
+
this.parts.push({ what: "selection", offset: { x: 0, y: 0 }, moving: selectionSurface(sel), base: null, reduced: /* @__PURE__ */ new Map() });
|
|
8421
|
+
moves.push("selection");
|
|
8422
|
+
box = { ...sel.bounds };
|
|
8423
|
+
} else {
|
|
8424
|
+
const id = _nullishCoalesce(init.layerId, () => ( host.activeLayerId()));
|
|
8425
|
+
if (!id) fail2("No layer given and none is active; pass layerId (see list_layers).");
|
|
8426
|
+
const layer = requireLayer(layers, id).layer;
|
|
8427
|
+
this.layerId = layer.id;
|
|
8428
|
+
const mask = layer.mask && !layer.mask.source ? layer.mask : void 0;
|
|
8429
|
+
const channel = _nullishCoalesce(init.channel, () => ( (layer.id === host.activeLayerId() ? host.activeTarget() : "pixels")));
|
|
8430
|
+
if (channel !== "pixels" && channel !== "mask") fail2(`Unknown channel "${String(channel)}"; use pixels or mask.`);
|
|
8431
|
+
const linked = _optionalChain([mask, 'optionalAccess', _134 => _134.linked]) !== false;
|
|
8432
|
+
const maskAlone = channel === "mask" && (!linked || layer.type !== "pixel");
|
|
8433
|
+
if (channel === "mask" && !mask) fail2(_optionalChain([layer, 'access', _135 => _135.mask, 'optionalAccess', _136 => _136.source]) ? `Layer "${layer.name || id}" has a depth mask, which is generated, not transformed.` : `Layer "${layer.name || id}" has no mask to transform; add one with add_layer_mask, or transform its pixels.`);
|
|
8434
|
+
if (!maskAlone && layer.type !== "pixel") fail2(`Layer "${layer.name || id}" is a ${layer.type} layer; Free Transform works on pixel layers, layer masks (channel mask) and selections.`);
|
|
8435
|
+
if (!layer.visible && content !== "selection-copy") fail2(`Layer "${layer.name || id}" is hidden; show it before you transform it.`);
|
|
8436
|
+
if (content !== "selection-copy") {
|
|
8437
|
+
requireUnlocked(layer, "position", "transform it");
|
|
8438
|
+
if (!maskAlone) requireUnlocked(layer, "pixels", "transform it");
|
|
8439
|
+
}
|
|
8440
|
+
const o = layer.type === "pixel" ? layer.offset : { x: 0, y: 0 };
|
|
8441
|
+
const pixels = layer.type === "pixel" ? host.pixelsOf(layer) : null;
|
|
8442
|
+
if (maskAlone) {
|
|
8443
|
+
if (content === "selection-copy") fail2("Layer via Copy copies pixels; transform a mask with content layer or selection.");
|
|
8444
|
+
if (content === "selection") {
|
|
8445
|
+
const { lifted, rest } = liftMask(mask.surface, sel, o);
|
|
8446
|
+
this.parts.push({ what: "mask", offset: o, moving: lifted, base: rest, reduced: /* @__PURE__ */ new Map() });
|
|
8447
|
+
box = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, lifted), o);
|
|
8448
|
+
} else {
|
|
8449
|
+
this.parts.push({ what: "mask", offset: o, moving: mask.surface, base: null, reduced: /* @__PURE__ */ new Map() });
|
|
8450
|
+
box = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, mask.surface), o);
|
|
8451
|
+
}
|
|
8452
|
+
moves.push("mask");
|
|
8453
|
+
} else if (content === "layer") {
|
|
8454
|
+
this.parts.push({ what: "pixels", offset: o, moving: pixels, base: null, reduced: /* @__PURE__ */ new Map() });
|
|
8455
|
+
moves.push("pixels");
|
|
8456
|
+
box = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, pixels), o);
|
|
8457
|
+
if (mask && linked) {
|
|
8458
|
+
this.parts.push({ what: "mask", offset: o, moving: mask.surface, base: null, reduced: /* @__PURE__ */ new Map() });
|
|
8459
|
+
moves.push("mask");
|
|
8460
|
+
if (!box) box = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, mask.surface), o);
|
|
8461
|
+
}
|
|
8462
|
+
} else if (content === "selection") {
|
|
8463
|
+
const { lifted, rest } = liftPixels(pixels, sel, o);
|
|
8464
|
+
this.parts.push({ what: "pixels", offset: o, moving: lifted, base: rest, reduced: /* @__PURE__ */ new Map() });
|
|
8465
|
+
moves.push("pixels");
|
|
8466
|
+
box = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, lifted), o);
|
|
8467
|
+
if (mask && linked) {
|
|
8468
|
+
const m = liftMask(mask.surface, sel, o);
|
|
8469
|
+
this.parts.push({ what: "mask", offset: o, moving: m.lifted, base: m.rest, reduced: /* @__PURE__ */ new Map() });
|
|
8470
|
+
moves.push("mask");
|
|
8471
|
+
}
|
|
8472
|
+
} else {
|
|
8473
|
+
const { lifted } = liftPixels(pixels, sel, o);
|
|
8474
|
+
box = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, lifted), o);
|
|
8475
|
+
if (box) {
|
|
8476
|
+
const copy = {
|
|
8477
|
+
type: "pixel",
|
|
8478
|
+
id: newLayerId(),
|
|
8479
|
+
name: `${layer.name || "Layer"} copy`,
|
|
8480
|
+
visible: true,
|
|
8481
|
+
opacity: 1,
|
|
8482
|
+
blend: "normal",
|
|
8483
|
+
surface: lifted,
|
|
8484
|
+
offset: { ...o }
|
|
8485
|
+
};
|
|
8486
|
+
this.copyId = copy.id;
|
|
8487
|
+
const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, layer.id);
|
|
8488
|
+
this.startLayers = _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _137 => _137.parent, 'optionalAccess', _138 => _138.id]), () => ( null)), loc.index + 1);
|
|
8489
|
+
this.parts.push({ what: "pixels", offset: o, moving: lifted, base: null, reduced: /* @__PURE__ */ new Map() });
|
|
8490
|
+
moves.push("pixels");
|
|
8491
|
+
}
|
|
8492
|
+
}
|
|
8493
|
+
if (content !== "layer") {
|
|
8494
|
+
this.parts.push({ what: "selection", offset: { x: 0, y: 0 }, moving: selectionSurface(sel), base: null, reduced: /* @__PURE__ */ new Map() });
|
|
8495
|
+
moves.push("selection");
|
|
8496
|
+
}
|
|
8497
|
+
}
|
|
8498
|
+
if (!box && moves[0] === "mask") fail2("The mask holds nothing but its default value, so there is nothing to transform; paint it first, or transform the pixels (channel pixels).");
|
|
8499
|
+
if (!box) fail2(content === "layer" ? "The layer has no pixels to transform." : "The selection holds no pixels of this layer; select some, or transform the outline (content selection-outline).");
|
|
8500
|
+
this.box = box;
|
|
8501
|
+
this.moves = moves;
|
|
8502
|
+
this.geometryValue = identityTransform(box);
|
|
8503
|
+
this.shown = this.startLayers;
|
|
8504
|
+
if (this.copyId) host.show(this.startLayers, sel, this.copyId);
|
|
8505
|
+
this.shown = host.layers();
|
|
8506
|
+
}
|
|
8507
|
+
|
|
8508
|
+
|
|
8509
|
+
/** The layer being transformed (`null` for `selection-outline`). */
|
|
8510
|
+
|
|
8511
|
+
/** The new layer of a `selection-copy`. */
|
|
8512
|
+
__init28() {this.copyId = null}
|
|
8513
|
+
/** The frame (document pixels). */
|
|
8514
|
+
|
|
8515
|
+
/** What moves. */
|
|
8516
|
+
|
|
8517
|
+
|
|
8518
|
+
|
|
8519
|
+
__init29() {this.parts = []}
|
|
8520
|
+
|
|
8521
|
+
|
|
8522
|
+
|
|
8523
|
+
|
|
8524
|
+
/** The stack this session last showed: anything else means the document changed under it. */
|
|
8525
|
+
|
|
8526
|
+
__init30() {this.closed = false}
|
|
8527
|
+
/** The current geometry. */
|
|
8528
|
+
get geometry() {
|
|
8529
|
+
return this.geometryValue;
|
|
8530
|
+
}
|
|
8531
|
+
get interpolation() {
|
|
8532
|
+
return this.interp;
|
|
8533
|
+
}
|
|
8534
|
+
get isOpen() {
|
|
8535
|
+
return !this.closed;
|
|
8536
|
+
}
|
|
8537
|
+
check() {
|
|
8538
|
+
if (this.closed) fail2("This transform has already been committed or cancelled; begin a new one.");
|
|
8539
|
+
if (this.host.layers() !== this.shown) {
|
|
8540
|
+
this.closed = true;
|
|
8541
|
+
fail2("The document changed while the transform was open, so it was abandoned; begin a new one.");
|
|
8542
|
+
}
|
|
8543
|
+
}
|
|
8544
|
+
/**
|
|
8545
|
+
* Changes the geometry (`corners`, `warp`) or the interpolation and, unless `preview` is `false`,
|
|
8546
|
+
* shows the result live (no history). Returns the geometry.
|
|
8547
|
+
*/
|
|
8548
|
+
update(changes, preview = {}) {
|
|
8549
|
+
this.check();
|
|
8550
|
+
if (changes.interpolation !== void 0) {
|
|
8551
|
+
if (!_chunkWT6ZAWJPcjs.isInterpolation.call(void 0, changes.interpolation)) fail2(`Unknown interpolation "${String(changes.interpolation)}"; use nearest, bilinear or bicubic.`);
|
|
8552
|
+
this.interp = changes.interpolation;
|
|
8553
|
+
}
|
|
8554
|
+
const next = {
|
|
8555
|
+
box: this.box,
|
|
8556
|
+
corners: (_nullishCoalesce(changes.corners, () => ( this.geometryValue.corners))).map((p) => ({ x: p.x, y: p.y })),
|
|
8557
|
+
warp: changes.warp === void 0 ? _nullishCoalesce(this.geometryValue.warp, () => ( null)) : changes.warp
|
|
8558
|
+
};
|
|
8559
|
+
if (next.corners.length !== 4 || !next.corners.every((p) => Number.isFinite(p.x) && Number.isFinite(p.y))) fail2("corners must be four finite points: top-left, top-right, bottom-right, bottom-left.");
|
|
8560
|
+
if (!transformMap(next)) fail2("These corners fold the frame over itself or through the horizon; keep the quad convex.");
|
|
8561
|
+
this.geometryValue = next;
|
|
8562
|
+
if (preview !== false) this.render(preview);
|
|
8563
|
+
return next;
|
|
8564
|
+
}
|
|
8565
|
+
/** Resamples every part for the current geometry and shows it (or returns it, for commit). */
|
|
8566
|
+
resample(final, preview = {}) {
|
|
8567
|
+
const g = this.geometryValue;
|
|
8568
|
+
const identity = isIdentityTransform(g);
|
|
8569
|
+
const warp = hasWarp(g);
|
|
8570
|
+
const h = warp ? null : geometryHomography(g);
|
|
8571
|
+
const f = warp ? transformMap(g) : null;
|
|
8572
|
+
const step = final ? 1 : previewStep(preview.scale);
|
|
8573
|
+
const interpolation = final ? this.interp : this.interp === "nearest" ? "nearest" : "bilinear";
|
|
8574
|
+
let layers = this.startLayers;
|
|
8575
|
+
let selection = this.startSelection;
|
|
8576
|
+
const targetId = _nullishCoalesce(this.copyId, () => ( this.layerId));
|
|
8577
|
+
for (const part of this.parts) {
|
|
8578
|
+
const o = part.offset;
|
|
8579
|
+
let moved;
|
|
8580
|
+
if (identity) moved = part.moving;
|
|
8581
|
+
else {
|
|
8582
|
+
let src = part.moving;
|
|
8583
|
+
let k = 1;
|
|
8584
|
+
if (step > 1) {
|
|
8585
|
+
k = step;
|
|
8586
|
+
let r = part.reduced.get(k);
|
|
8587
|
+
if (!r) {
|
|
8588
|
+
r = _chunkWT6ZAWJPcjs.reduceSurface.call(void 0, part.moving, k);
|
|
8589
|
+
part.reduced.set(k, r);
|
|
8590
|
+
}
|
|
8591
|
+
src = r;
|
|
8592
|
+
}
|
|
8593
|
+
const opts = { interpolation, step: step > 1 ? step : void 0 };
|
|
8594
|
+
if (preview.clip && !final) opts.clip = { x: Math.floor(preview.clip.x - o.x), y: Math.floor(preview.clip.y - o.y), width: Math.ceil(preview.clip.width) + 1, height: Math.ceil(preview.clip.height) + 1 };
|
|
8595
|
+
try {
|
|
8596
|
+
if (f) {
|
|
8597
|
+
moved = _chunkWT6ZAWJPcjs.warpSurface.call(void 0, src, (p) => {
|
|
8598
|
+
const q2 = f({ x: p.x * k + o.x, y: p.y * k + o.y });
|
|
8599
|
+
return q2 && { x: q2.x - o.x, y: q2.y - o.y };
|
|
8600
|
+
}, opts);
|
|
8601
|
+
} else {
|
|
8602
|
+
const hl = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, [k, 0, 0, 0, k, 0, 0, 0, 1], T(o.x, o.y)), h), T(-o.x, -o.y));
|
|
8603
|
+
moved = _chunkWT6ZAWJPcjs.transformSurface.call(void 0, src, hl, opts);
|
|
8604
|
+
}
|
|
8605
|
+
} catch (e) {
|
|
8606
|
+
if (e instanceof _chunkWT6ZAWJPcjs.TransformTooLargeError) fail2(e.message);
|
|
8607
|
+
throw e;
|
|
8608
|
+
}
|
|
8609
|
+
}
|
|
8610
|
+
const result = part.base ? _chunkWT6ZAWJPcjs.compositeSurfaceOver.call(void 0, part.base, moved) : moved;
|
|
8611
|
+
if (part.what === "selection") {
|
|
8612
|
+
const { width, height } = this.host.canvas();
|
|
8613
|
+
const data = new Uint8Array(_chunkCRMAXIUVcjs.readRegion.call(void 0, result, { x: 0, y: 0, width, height }).buffer);
|
|
8614
|
+
const next = createSelectionMask(width, height, data);
|
|
8615
|
+
selection = next.bounds ? next : null;
|
|
8616
|
+
} else if (part.what === "pixels") {
|
|
8617
|
+
layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, targetId, (l) => {
|
|
8618
|
+
const next = { ...l, surface: result };
|
|
8619
|
+
delete next.source;
|
|
8620
|
+
return next;
|
|
8621
|
+
});
|
|
8622
|
+
} else {
|
|
8623
|
+
layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, targetId, (l) => ({ ...l, mask: { ...l.mask, surface: result } }));
|
|
8624
|
+
}
|
|
8625
|
+
}
|
|
8626
|
+
return { layers, selection };
|
|
8627
|
+
}
|
|
8628
|
+
render(preview) {
|
|
8629
|
+
const { layers, selection } = this.resample(false, preview);
|
|
8630
|
+
this.host.show(layers, selection, _nullishCoalesce(this.copyId, () => ( this.startActive)));
|
|
8631
|
+
this.shown = this.host.layers();
|
|
8632
|
+
}
|
|
8633
|
+
/** Finishes the transform with full-quality resampling, as one undo step. */
|
|
8634
|
+
commit() {
|
|
8635
|
+
this.check();
|
|
8636
|
+
const g = this.geometryValue;
|
|
8637
|
+
const changed = !isIdentityTransform(g) || Boolean(this.copyId);
|
|
8638
|
+
if (!changed) {
|
|
8639
|
+
this.closed = true;
|
|
8640
|
+
this.host.restore(this.before);
|
|
8641
|
+
return this.result(false, this.startLayers, this.startSelection);
|
|
8642
|
+
}
|
|
8643
|
+
const { layers, selection } = this.resample(true);
|
|
8644
|
+
this.closed = true;
|
|
8645
|
+
this.host.show(layers, selection, _nullishCoalesce(this.copyId, () => ( this.startActive)));
|
|
8646
|
+
this.host.record(this.before);
|
|
8647
|
+
return this.result(true, layers, selection);
|
|
8648
|
+
}
|
|
8649
|
+
/** Abandons the transform and puts everything back (no history). */
|
|
8650
|
+
cancel() {
|
|
8651
|
+
if (this.closed) return;
|
|
8652
|
+
this.closed = true;
|
|
8653
|
+
this.host.restore(this.before);
|
|
8654
|
+
}
|
|
8655
|
+
result(changed, layers, selection) {
|
|
8656
|
+
let bounds = null;
|
|
8657
|
+
const id = _nullishCoalesce(this.copyId, () => ( this.layerId));
|
|
8658
|
+
const layer = id ? _optionalChain([_chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, id), 'optionalAccess', _139 => _139.layer]) : void 0;
|
|
8659
|
+
if (this.moves.includes("pixels") && _optionalChain([layer, 'optionalAccess', _140 => _140.type]) === "pixel") bounds = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, this.host.pixelsOf(layer)), layer.offset);
|
|
8660
|
+
else if (this.moves.includes("mask") && _optionalChain([layer, 'optionalAccess', _141 => _141.mask])) bounds = toDoc(_chunkCRMAXIUVcjs.contentBounds.call(void 0, layer.mask.surface), layer.type === "pixel" ? layer.offset : { x: 0, y: 0 });
|
|
8661
|
+
else if (this.moves.includes("selection")) bounds = _optionalChain([selection, 'optionalAccess', _142 => _142.bounds]) ? { ...selection.bounds } : null;
|
|
8662
|
+
return {
|
|
8663
|
+
layerId: _nullishCoalesce(this.copyId, () => ( this.layerId)),
|
|
8664
|
+
content: this.content,
|
|
8665
|
+
moved: [...this.moves],
|
|
8666
|
+
box: { ...this.box },
|
|
8667
|
+
corners: this.geometryValue.corners,
|
|
8668
|
+
bounds,
|
|
8669
|
+
changed
|
|
8670
|
+
};
|
|
8671
|
+
}
|
|
8672
|
+
}, _class6);
|
|
8673
|
+
|
|
8090
8674
|
// src/image-editor/controller.ts
|
|
8091
8675
|
var IMAGE_EDITOR_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION;
|
|
8092
8676
|
function paintCoverageInto(base, coverage, apply, rects) {
|
|
@@ -8097,7 +8681,7 @@ function paintCoverageInto(base, coverage, apply, rects) {
|
|
|
8097
8681
|
const key = _chunkCRMAXIUVcjs.tileKey.call(void 0, t.tx, t.ty);
|
|
8098
8682
|
if (done.has(key)) continue;
|
|
8099
8683
|
done.add(key);
|
|
8100
|
-
const src = _nullishCoalesce(_optionalChain([base, 'access',
|
|
8684
|
+
const src = _nullishCoalesce(_optionalChain([base, 'access', _143 => _143.tiles, 'access', _144 => _144.get, 'call', _145 => _145(key), 'optionalAccess', _146 => _146.data]), () => ( defaultTile(base)));
|
|
8101
8685
|
const data = _chunkZZOTHJ4Kcjs.applyStrokeToTile.call(void 0, coverage, src, base.channels, t.tx, t.ty, apply);
|
|
8102
8686
|
const tile = _chunkCRMAXIUVcjs.finishTile.call(void 0, data, base.channels, base.defaultValue);
|
|
8103
8687
|
if (tile) tiles.set(key, tile);
|
|
@@ -8111,8 +8695,8 @@ function defaultTile(s) {
|
|
|
8111
8695
|
if (s.defaultValue) d.fill(s.defaultValue);
|
|
8112
8696
|
return d;
|
|
8113
8697
|
}
|
|
8114
|
-
var PaintStrokeSession = (
|
|
8115
|
-
constructor(controller, target, stroke, apply) {;
|
|
8698
|
+
var PaintStrokeSession = (_class7 = class {
|
|
8699
|
+
constructor(controller, target, stroke, apply) {;_class7.prototype.__init31.call(this);_class7.prototype.__init32.call(this);_class7.prototype.__init33.call(this);_class7.prototype.__init34.call(this);_class7.prototype.__init35.call(this);
|
|
8116
8700
|
this.controller = controller;
|
|
8117
8701
|
this.target = target;
|
|
8118
8702
|
this.apply = apply;
|
|
@@ -8134,14 +8718,14 @@ var PaintStrokeSession = (_class6 = class {
|
|
|
8134
8718
|
|
|
8135
8719
|
|
|
8136
8720
|
|
|
8137
|
-
|
|
8721
|
+
__init31() {this.touched = /* @__PURE__ */ new Set()}
|
|
8138
8722
|
|
|
8139
8723
|
|
|
8140
|
-
|
|
8724
|
+
__init32() {this.mixerInit = null}
|
|
8141
8725
|
/** Mixer tiles written since the last update: they get new tile objects so the compositor sees them change. */
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8726
|
+
__init33() {this.fresh = /* @__PURE__ */ new Set()}
|
|
8727
|
+
__init34() {this.last = null}
|
|
8728
|
+
__init35() {this.closed = false}
|
|
8145
8729
|
/** The live pixels a mixer stroke reads and writes; base tiles are copied on first write. */
|
|
8146
8730
|
mixerPixels() {
|
|
8147
8731
|
const a = this.apply;
|
|
@@ -8149,11 +8733,11 @@ var PaintStrokeSession = (_class6 = class {
|
|
|
8149
8733
|
offset: a.offset,
|
|
8150
8734
|
lockTransparency: a.lockTransparency,
|
|
8151
8735
|
selection: a.selection,
|
|
8152
|
-
readTile: (tx, ty) => _nullishCoalesce(_optionalChain([this, 'access',
|
|
8736
|
+
readTile: (tx, ty) => _nullishCoalesce(_optionalChain([this, 'access', _147 => _147.live, 'access', _148 => _148.get, 'call', _149 => _149(_chunkCRMAXIUVcjs.tileKey.call(void 0, tx, ty)), 'optionalAccess', _150 => _150.data]), () => ( (this.base.defaultValue ? defaultTile(this.base) : null))),
|
|
8153
8737
|
writeTile: (tx, ty) => {
|
|
8154
8738
|
const key = _chunkCRMAXIUVcjs.tileKey.call(void 0, tx, ty);
|
|
8155
8739
|
if (!this.touched.has(key)) {
|
|
8156
|
-
const src = _nullishCoalesce(_optionalChain([this, 'access',
|
|
8740
|
+
const src = _nullishCoalesce(_optionalChain([this, 'access', _151 => _151.base, 'access', _152 => _152.tiles, 'access', _153 => _153.get, 'call', _154 => _154(key), 'optionalAccess', _155 => _155.data]), () => ( defaultTile(this.base)));
|
|
8157
8741
|
this.live.set(key, { data: new Uint8ClampedArray(src), uniform: null });
|
|
8158
8742
|
this.touched.add(key);
|
|
8159
8743
|
}
|
|
@@ -8190,8 +8774,8 @@ var PaintStrokeSession = (_class6 = class {
|
|
|
8190
8774
|
}
|
|
8191
8775
|
}
|
|
8192
8776
|
for (const [key, { tx, ty, r }] of regions) {
|
|
8193
|
-
const src = _nullishCoalesce(_optionalChain([this, 'access',
|
|
8194
|
-
const prev = this.touched.has(key) ? _optionalChain([this, 'access',
|
|
8777
|
+
const src = _nullishCoalesce(_optionalChain([this, 'access', _156 => _156.base, 'access', _157 => _157.tiles, 'access', _158 => _158.get, 'call', _159 => _159(key), 'optionalAccess', _160 => _160.data]), () => ( defaultTile(this.base)));
|
|
8778
|
+
const prev = this.touched.has(key) ? _optionalChain([this, 'access', _161 => _161.live, 'access', _162 => _162.get, 'call', _163 => _163(key), 'optionalAccess', _164 => _164.data]) : void 0;
|
|
8195
8779
|
this.touched.add(key);
|
|
8196
8780
|
const data = _chunkZZOTHJ4Kcjs.applyStrokeToTile.call(void 0, stroke.coverage, src, ch, tx, ty, this.apply, prev ? { into: prev, region: r } : {});
|
|
8197
8781
|
this.live.set(key, { data, uniform: null });
|
|
@@ -8229,7 +8813,7 @@ var PaintStrokeSession = (_class6 = class {
|
|
|
8229
8813
|
this.closed = true;
|
|
8230
8814
|
this.controller._strokeCommit(this.before, this.target.id, this.target.channel, null);
|
|
8231
8815
|
}
|
|
8232
|
-
},
|
|
8816
|
+
}, _class7);
|
|
8233
8817
|
function sameTile(a, b) {
|
|
8234
8818
|
if (!a || !b) return !a && !b;
|
|
8235
8819
|
if (a === b) return true;
|
|
@@ -8266,14 +8850,14 @@ function migrateSerializedImageEditorState(data) {
|
|
|
8266
8850
|
const legacy = data;
|
|
8267
8851
|
const adjustments = normalizeStoredAdjustments(legacy.adjustments);
|
|
8268
8852
|
return {
|
|
8269
|
-
version: _optionalChain([adjustments, 'access',
|
|
8853
|
+
version: _optionalChain([adjustments, 'access', _165 => _165.layers, 'optionalAccess', _166 => _166.length]) ? 2 : 1,
|
|
8270
8854
|
crop: legacy.crop ? { ...legacy.crop } : null,
|
|
8271
8855
|
transform: { ...DEFAULT_TRANSFORM, ...legacy.transform },
|
|
8272
8856
|
adjustments: serializeAdjustments(adjustments),
|
|
8273
8857
|
depthMask: {
|
|
8274
8858
|
...DEFAULT_DEPTH_MASK,
|
|
8275
8859
|
...legacy.depthMask,
|
|
8276
|
-
depthRange: [..._nullishCoalesce(_optionalChain([legacy, 'access',
|
|
8860
|
+
depthRange: [..._nullishCoalesce(_optionalChain([legacy, 'access', _167 => _167.depthMask, 'optionalAccess', _168 => _168.depthRange]), () => ( DEFAULT_DEPTH_MASK.depthRange))]
|
|
8277
8861
|
},
|
|
8278
8862
|
annotations: JSON.parse(JSON.stringify(_nullishCoalesce(legacy.annotations, () => ( [])))),
|
|
8279
8863
|
...legacy.selection ? { selection: { ...legacy.selection } } : {}
|
|
@@ -8302,29 +8886,29 @@ function migrateToLayeredState(data, size) {
|
|
|
8302
8886
|
var DEFAULT_TRANSFORM = DEFAULT_TRANSFORM_VALUES;
|
|
8303
8887
|
var DEFAULT_DEPTH_MASK = DEFAULT_DEPTH_MASK_VALUES;
|
|
8304
8888
|
var DEVELOP_KEYS = ["brightness", "contrast", "saturation", "exposure", "temperature", "tint"];
|
|
8305
|
-
var ImageEditorController = (
|
|
8889
|
+
var ImageEditorController = (_class8 = class {
|
|
8306
8890
|
|
|
8307
8891
|
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8892
|
+
__init36() {this.imageElement = null}
|
|
8893
|
+
__init37() {this.listeners = /* @__PURE__ */ new Set()}
|
|
8894
|
+
__init38() {this.histogramListeners = /* @__PURE__ */ new Set()}
|
|
8311
8895
|
|
|
8312
8896
|
// History stacks
|
|
8313
|
-
|
|
8314
|
-
|
|
8897
|
+
__init39() {this.undoStack = []}
|
|
8898
|
+
__init40() {this.redoStack = []}
|
|
8315
8899
|
|
|
8316
8900
|
|
|
8317
|
-
|
|
8901
|
+
__init41() {this.isApplyingHistory = false}
|
|
8318
8902
|
|
|
8319
8903
|
/** Pixels the selection tools sample (host-provided or read back from the source). */
|
|
8320
|
-
|
|
8321
|
-
|
|
8904
|
+
__init42() {this.samplePixels = null}
|
|
8905
|
+
__init43() {this.samplePixelsOverride = false}
|
|
8322
8906
|
/** Decoded source pixels (the Background's surface), by the buffer or element they came from. */
|
|
8323
|
-
|
|
8324
|
-
|
|
8907
|
+
__init44() {this.sourceSurfaces = /* @__PURE__ */ new WeakMap()}
|
|
8908
|
+
__init45() {this.viewKey = []}
|
|
8325
8909
|
/** For `compositePixels` and mask evaluation (the renderer keeps its own for the viewport). */
|
|
8326
|
-
|
|
8327
|
-
constructor(options = {}) {;
|
|
8910
|
+
__init46() {this.compositor = new LayerCompositor()}
|
|
8911
|
+
constructor(options = {}) {;_class8.prototype.__init36.call(this);_class8.prototype.__init37.call(this);_class8.prototype.__init38.call(this);_class8.prototype.__init39.call(this);_class8.prototype.__init40.call(this);_class8.prototype.__init41.call(this);_class8.prototype.__init42.call(this);_class8.prototype.__init43.call(this);_class8.prototype.__init44.call(this);_class8.prototype.__init45.call(this);_class8.prototype.__init46.call(this);_class8.prototype.__init47.call(this);_class8.prototype.__init48.call(this);_class8.prototype.__init49.call(this);_class8.prototype.__init50.call(this);_class8.prototype.__init51.call(this);_class8.prototype.__init52.call(this);_class8.prototype.__init53.call(this);_class8.prototype.__init54.call(this);_class8.prototype.__init55.call(this);_class8.prototype.__init56.call(this);
|
|
8328
8912
|
this.maxHistoryDepth = _nullishCoalesce(options.maxHistoryDepth, () => ( 50));
|
|
8329
8913
|
this.maxHistoryBytes = _nullishCoalesce(options.maxHistoryBytes, () => ( 512 * 1024 * 1024));
|
|
8330
8914
|
this.onStateChange = options.onStateChange;
|
|
@@ -8337,7 +8921,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
8337
8921
|
sourceIsOpaque: () => this.sourceIsOpaque(),
|
|
8338
8922
|
version: () => `${this.sourceVersion()}:${this.patternsVersion()}`,
|
|
8339
8923
|
globalLight: () => this.state.globalLight,
|
|
8340
|
-
pattern: (id) => _nullishCoalesce(_optionalChain([this, 'access',
|
|
8924
|
+
pattern: (id) => _nullishCoalesce(_optionalChain([this, 'access', _169 => _169.state, 'access', _170 => _170.patterns, 'optionalAccess', _171 => _171.find, 'call', _172 => _172((p) => p.id === id)]), () => ( null))
|
|
8341
8925
|
};
|
|
8342
8926
|
this.state = {
|
|
8343
8927
|
sourceUrl: typeof options.image === "string" ? options.image : null,
|
|
@@ -8370,10 +8954,10 @@ var ImageEditorController = (_class7 = class {
|
|
|
8370
8954
|
};
|
|
8371
8955
|
}
|
|
8372
8956
|
this.applyStored(_nullishCoalesce(options.initialState, () => ( {})));
|
|
8373
|
-
if (_optionalChain([options, 'access',
|
|
8957
|
+
if (_optionalChain([options, 'access', _173 => _173.initialState, 'optionalAccess', _174 => _174.selection])) {
|
|
8374
8958
|
try {
|
|
8375
8959
|
this.state.selection = normalizeSelection(deserializeSelection(options.initialState.selection));
|
|
8376
|
-
} catch (
|
|
8960
|
+
} catch (e20) {
|
|
8377
8961
|
}
|
|
8378
8962
|
}
|
|
8379
8963
|
this.initialSnapshot = this.captureHistoryEntry();
|
|
@@ -8414,7 +8998,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
8414
8998
|
height: img.naturalHeight || img.height || 600
|
|
8415
8999
|
}
|
|
8416
9000
|
};
|
|
8417
|
-
} catch (
|
|
9001
|
+
} catch (e21) {
|
|
8418
9002
|
return { sourceUrl: src, element: null, dimensions: { ...this.state.imageDimensions } };
|
|
8419
9003
|
}
|
|
8420
9004
|
}
|
|
@@ -8447,13 +9031,13 @@ var ImageEditorController = (_class7 = class {
|
|
|
8447
9031
|
* Where layer pixels changed since the last viewport render, when only strokes changed them
|
|
8448
9032
|
* (the renderer then recomposites just those rectangles); `'all'` after any other change.
|
|
8449
9033
|
*/
|
|
8450
|
-
|
|
9034
|
+
__init47() {this.pendingDirty = "all"}
|
|
8451
9035
|
notify(strokeRects) {
|
|
8452
9036
|
if (strokeRects && this.pendingDirty !== "all") this.pendingDirty.push(...strokeRects);
|
|
8453
9037
|
else if (!strokeRects) this.pendingDirty = "all";
|
|
8454
9038
|
this.syncViews();
|
|
8455
9039
|
const currentState = { ...this.state };
|
|
8456
|
-
_optionalChain([this, 'access',
|
|
9040
|
+
_optionalChain([this, 'access', _175 => _175.onStateChange, 'optionalCall', _176 => _176(currentState)]);
|
|
8457
9041
|
this.listeners.forEach((l) => l(currentState));
|
|
8458
9042
|
}
|
|
8459
9043
|
/** Recomputes the compatibility views (`adjustments`, `depthMask`, `annotations`) when the stack changed. */
|
|
@@ -8664,7 +9248,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
8664
9248
|
return this.state.layers;
|
|
8665
9249
|
}
|
|
8666
9250
|
getLayer(id) {
|
|
8667
|
-
return _optionalChain([
|
|
9251
|
+
return _optionalChain([_chunkWT6ZAWJPcjs.findLayer.call(void 0, this.state.layers, id), 'optionalAccess', _177 => _177.layer]);
|
|
8668
9252
|
}
|
|
8669
9253
|
/** The active layer, or `undefined`. */
|
|
8670
9254
|
getActiveLayer() {
|
|
@@ -8677,7 +9261,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
8677
9261
|
setActiveLayer(id, target = "pixels") {
|
|
8678
9262
|
if (id !== null && !this.getLayer(id)) return false;
|
|
8679
9263
|
const layer = id ? this.getLayer(id) : void 0;
|
|
8680
|
-
const t = target === "mask" && _optionalChain([layer, 'optionalAccess',
|
|
9264
|
+
const t = target === "mask" && _optionalChain([layer, 'optionalAccess', _178 => _178.mask]) ? "mask" : "pixels";
|
|
8681
9265
|
if (this.state.activeLayerId === id && this.state.activeTarget === t) return true;
|
|
8682
9266
|
this.state.activeLayerId = id;
|
|
8683
9267
|
this.state.activeTarget = t;
|
|
@@ -8696,7 +9280,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
8696
9280
|
if (!b) return null;
|
|
8697
9281
|
return { x: b.x + layer.offset.x, y: b.y + layer.offset.y, width: b.width, height: b.height, data: _chunkCRMAXIUVcjs.readRegion.call(void 0, surface, b) };
|
|
8698
9282
|
}
|
|
8699
|
-
|
|
9283
|
+
__init48() {this.boundsCache = /* @__PURE__ */ new WeakMap()}
|
|
8700
9284
|
/**
|
|
8701
9285
|
* Document bounds of a layer's non-transparent pixels (pixel layers; the Background's source
|
|
8702
9286
|
* included), or `null` for an empty or non-pixel layer.
|
|
@@ -8723,7 +9307,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
8723
9307
|
let layers = this.state.layers;
|
|
8724
9308
|
if (options.layerIds) {
|
|
8725
9309
|
const keep = new Set(options.layerIds);
|
|
8726
|
-
layers =
|
|
9310
|
+
layers = _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers).filter((l) => keep.has(l.id) && l.type !== "group");
|
|
8727
9311
|
}
|
|
8728
9312
|
const data = this.compositor.composite(layers, r, this.compositorSources());
|
|
8729
9313
|
return { width: r.width, height: r.height, data };
|
|
@@ -8736,11 +9320,11 @@ var ImageEditorController = (_class7 = class {
|
|
|
8736
9320
|
surfaceOf: (l) => this.surfaceOf(l),
|
|
8737
9321
|
version: `${this.sourceVersion()}:${this.patternsVersion()}`,
|
|
8738
9322
|
globalLight: this.state.globalLight,
|
|
8739
|
-
pattern: (id) => _nullishCoalesce(_optionalChain([this, 'access',
|
|
9323
|
+
pattern: (id) => _nullishCoalesce(_optionalChain([this, 'access', _179 => _179.state, 'access', _180 => _180.patterns, 'optionalAccess', _181 => _181.find, 'call', _182 => _182((p) => p.id === id)]), () => ( null))
|
|
8740
9324
|
};
|
|
8741
9325
|
}
|
|
8742
|
-
|
|
8743
|
-
|
|
9326
|
+
__init49() {this.sourceIds = /* @__PURE__ */ new WeakMap()}
|
|
9327
|
+
__init50() {this.nextSourceId = 1}
|
|
8744
9328
|
/** Changes whenever the Background's source pixels can have changed. */
|
|
8745
9329
|
sourceVersion() {
|
|
8746
9330
|
const key = this.samplePixelsOverride ? this.samplePixels : _nullishCoalesce(this.imageElement, () => ( this.samplePixels));
|
|
@@ -8789,7 +9373,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
8789
9373
|
}
|
|
8790
9374
|
return fits ? fromPixels(px2) : null;
|
|
8791
9375
|
}
|
|
8792
|
-
|
|
9376
|
+
__init51() {this.opaqueCache = /* @__PURE__ */ new WeakMap()}
|
|
8793
9377
|
/** Whether every source pixel is opaque (some legacy renders depend on it). */
|
|
8794
9378
|
sourceIsOpaque() {
|
|
8795
9379
|
const s = this.sourceSurface();
|
|
@@ -8813,9 +9397,9 @@ var ImageEditorController = (_class7 = class {
|
|
|
8813
9397
|
if (!ctx || typeof ctx.getImageData !== "function") return null;
|
|
8814
9398
|
ctx.drawImage(el, 0, 0, width, height);
|
|
8815
9399
|
const data = ctx.getImageData(0, 0, width, height);
|
|
8816
|
-
if (!_optionalChain([data, 'optionalAccess',
|
|
9400
|
+
if (!_optionalChain([data, 'optionalAccess', _183 => _183.data]) || data.data.length < width * height * 4) return null;
|
|
8817
9401
|
return { width, height, data: data.data };
|
|
8818
|
-
} catch (
|
|
9402
|
+
} catch (e22) {
|
|
8819
9403
|
return null;
|
|
8820
9404
|
}
|
|
8821
9405
|
}
|
|
@@ -8824,8 +9408,8 @@ var ImageEditorController = (_class7 = class {
|
|
|
8824
9408
|
commitLayers(next, extra, commitToHistory = true) {
|
|
8825
9409
|
if (commitToHistory) this.recordHistory();
|
|
8826
9410
|
this.state.layers = next;
|
|
8827
|
-
_optionalChain([extra, 'optionalCall',
|
|
8828
|
-
if (this.state.activeLayerId && !
|
|
9411
|
+
_optionalChain([extra, 'optionalCall', _184 => _184()]);
|
|
9412
|
+
if (this.state.activeLayerId && !_chunkWT6ZAWJPcjs.findLayer.call(void 0, next, this.state.activeLayerId)) {
|
|
8829
9413
|
this.state.activeLayerId = null;
|
|
8830
9414
|
this.state.activeTarget = "pixels";
|
|
8831
9415
|
}
|
|
@@ -8834,7 +9418,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
8834
9418
|
/** The default position of a new layer: above the active layer, else the top of the stack. */
|
|
8835
9419
|
newLayerPlacement(placement) {
|
|
8836
9420
|
if (placement.aboveId || placement.belowId || placement.parentId || placement.index !== void 0) return placement;
|
|
8837
|
-
const active = this.state.activeLayerId ?
|
|
9421
|
+
const active = this.state.activeLayerId ? _chunkWT6ZAWJPcjs.findLayer.call(void 0, this.state.layers, this.state.activeLayerId) : null;
|
|
8838
9422
|
return active ? { aboveId: active.layer.id } : {};
|
|
8839
9423
|
}
|
|
8840
9424
|
/**
|
|
@@ -8857,11 +9441,11 @@ var ImageEditorController = (_class7 = class {
|
|
|
8857
9441
|
}
|
|
8858
9442
|
const blend = parseBlend(init.blend);
|
|
8859
9443
|
if (init.opacity !== void 0 && !(init.opacity >= 0 && init.opacity <= 1)) throw new LayerOperationError("opacity must be from 0 to 1.");
|
|
8860
|
-
const ids = new Set(
|
|
9444
|
+
const ids = new Set(_chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.id));
|
|
8861
9445
|
const layer = {
|
|
8862
9446
|
type: "pixel",
|
|
8863
9447
|
id: init.id && !ids.has(init.id) ? init.id : newLayerId(),
|
|
8864
|
-
name: _optionalChain([init, 'access',
|
|
9448
|
+
name: _optionalChain([init, 'access', _185 => _185.name, 'optionalAccess', _186 => _186.trim, 'call', _187 => _187()]) || this.nextLayerName(),
|
|
8865
9449
|
visible: _nullishCoalesce(init.visible, () => ( true)),
|
|
8866
9450
|
opacity: _nullishCoalesce(init.opacity, () => ( 1)),
|
|
8867
9451
|
blend: _nullishCoalesce(blend, () => ( "normal")),
|
|
@@ -8888,27 +9472,27 @@ var ImageEditorController = (_class7 = class {
|
|
|
8888
9472
|
async decodeImage(image) {
|
|
8889
9473
|
const trimmed = image.trim();
|
|
8890
9474
|
let png = null;
|
|
8891
|
-
if (/^data:image\/png/i.test(trimmed)) png = _nullishCoalesce(_optionalChain([
|
|
9475
|
+
if (/^data:image\/png/i.test(trimmed)) png = _nullishCoalesce(_optionalChain([_chunkWT6ZAWJPcjs.parseDataUrl.call(void 0, trimmed), 'optionalAccess', _188 => _188.bytes]), () => ( null));
|
|
8892
9476
|
else if (/^[A-Za-z0-9+/=\s]+$/.test(trimmed) && trimmed.length > 16) {
|
|
8893
9477
|
try {
|
|
8894
|
-
const bytes =
|
|
8895
|
-
if (
|
|
8896
|
-
} catch (
|
|
9478
|
+
const bytes = _chunkWT6ZAWJPcjs.base64ToBytes.call(void 0, trimmed);
|
|
9479
|
+
if (_chunkWT6ZAWJPcjs.isPng.call(void 0, bytes)) png = bytes;
|
|
9480
|
+
} catch (e23) {
|
|
8897
9481
|
png = null;
|
|
8898
9482
|
}
|
|
8899
9483
|
}
|
|
8900
9484
|
if (png) {
|
|
8901
9485
|
try {
|
|
8902
|
-
const d =
|
|
9486
|
+
const d = _chunkWT6ZAWJPcjs.decodePng.call(void 0, png);
|
|
8903
9487
|
return { width: d.width, height: d.height, data: d.data };
|
|
8904
|
-
} catch (
|
|
9488
|
+
} catch (e24) {
|
|
8905
9489
|
}
|
|
8906
9490
|
}
|
|
8907
|
-
const src = png ? `data:image/png;base64,${
|
|
9491
|
+
const src = png ? `data:image/png;base64,${_chunkWT6ZAWJPcjs.bytesToBase64.call(void 0, png)}` : trimmed;
|
|
8908
9492
|
let img;
|
|
8909
9493
|
try {
|
|
8910
9494
|
img = await this.renderer.imageCache.get(src);
|
|
8911
|
-
} catch (
|
|
9495
|
+
} catch (e25) {
|
|
8912
9496
|
throw new LayerOperationError("The image could not be decoded here. Pass a PNG (data URL or base64), or run in a browser for other formats and URLs.");
|
|
8913
9497
|
}
|
|
8914
9498
|
const w = img.naturalWidth || img.width;
|
|
@@ -8920,7 +9504,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
8920
9504
|
return { width: w, height: h, data: data.data };
|
|
8921
9505
|
}
|
|
8922
9506
|
nextLayerName() {
|
|
8923
|
-
const names = new Set(
|
|
9507
|
+
const names = new Set(_chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.name));
|
|
8924
9508
|
let n = 1;
|
|
8925
9509
|
while (names.has(`Layer ${n}`)) n++;
|
|
8926
9510
|
return `Layer ${n}`;
|
|
@@ -8937,7 +9521,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
8937
9521
|
removeLayer(id) {
|
|
8938
9522
|
const next = removeLayer(this.state.layers, id);
|
|
8939
9523
|
this.commitLayers(next, () => {
|
|
8940
|
-
if (this.state.selectedAnnotationId && !
|
|
9524
|
+
if (this.state.selectedAnnotationId && !_chunkWT6ZAWJPcjs.flattenLayers.call(void 0, next).some((l) => l.type === "annotation" && l.annotation.id === this.state.selectedAnnotationId)) {
|
|
8941
9525
|
this.state.selectedAnnotationId = null;
|
|
8942
9526
|
}
|
|
8943
9527
|
});
|
|
@@ -8945,10 +9529,10 @@ var ImageEditorController = (_class7 = class {
|
|
|
8945
9529
|
/** Moves a layer above / below another, or into a group, as one undo step. Returns its new parent and index. */
|
|
8946
9530
|
moveLayer(id, placement) {
|
|
8947
9531
|
const next = moveLayer(this.state.layers, id, placement);
|
|
8948
|
-
const loc =
|
|
8949
|
-
if (next === this.state.layers) return { parentId: _nullishCoalesce(_optionalChain([loc, 'access',
|
|
9532
|
+
const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, next, id);
|
|
9533
|
+
if (next === this.state.layers) return { parentId: _nullishCoalesce(_optionalChain([loc, 'access', _189 => _189.parent, 'optionalAccess', _190 => _190.id]), () => ( null)), index: loc.index };
|
|
8950
9534
|
this.commitLayers(next);
|
|
8951
|
-
return { parentId: _nullishCoalesce(_optionalChain([loc, 'access',
|
|
9535
|
+
return { parentId: _nullishCoalesce(_optionalChain([loc, 'access', _191 => _191.parent, 'optionalAccess', _192 => _192.id]), () => ( null)), index: loc.index };
|
|
8952
9536
|
}
|
|
8953
9537
|
/**
|
|
8954
9538
|
* Changes name, visibility, opacity, fill, blend, clipping, locks or (groups) collapsed state, as
|
|
@@ -8957,7 +9541,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
8957
9541
|
setLayerProperties(id, props, commitToHistory = true) {
|
|
8958
9542
|
const next = setLayerProperties(this.state.layers, id, props);
|
|
8959
9543
|
this.commitLayers(next, void 0, commitToHistory);
|
|
8960
|
-
return
|
|
9544
|
+
return _chunkWT6ZAWJPcjs.findLayer.call(void 0, next, id).layer;
|
|
8961
9545
|
}
|
|
8962
9546
|
/** Adds an empty pass-through group above the active layer (or at `placement`) and makes it active. Returns its id. */
|
|
8963
9547
|
addGroup(init = {}) {
|
|
@@ -8965,7 +9549,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
8965
9549
|
const group = {
|
|
8966
9550
|
type: "group",
|
|
8967
9551
|
id: newLayerId("group"),
|
|
8968
|
-
name: _optionalChain([init, 'access',
|
|
9552
|
+
name: _optionalChain([init, 'access', _193 => _193.name, 'optionalAccess', _194 => _194.trim, 'call', _195 => _195()]) || "Group",
|
|
8969
9553
|
visible: true,
|
|
8970
9554
|
opacity: 1,
|
|
8971
9555
|
blend,
|
|
@@ -9015,7 +9599,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9015
9599
|
let mask;
|
|
9016
9600
|
if (from === "selection") {
|
|
9017
9601
|
const sel = this.state.selection;
|
|
9018
|
-
if (!_optionalChain([sel, 'optionalAccess',
|
|
9602
|
+
if (!_optionalChain([sel, 'optionalAccess', _196 => _196.bounds])) throw new LayerOperationError("Nothing is selected; select first, or use reveal-all / hide-all.");
|
|
9019
9603
|
mask = this.maskFromSelection(sel, props);
|
|
9020
9604
|
if (layer.type === "pixel" && (layer.offset.x || layer.offset.y)) {
|
|
9021
9605
|
mask = { ...mask, surface: _chunkCRMAXIUVcjs.translateSurface.call(void 0, mask.surface, -layer.offset.x, -layer.offset.y) };
|
|
@@ -9038,7 +9622,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9038
9622
|
if (this.state.activeLayerId === id) this.state.activeTarget = "pixels";
|
|
9039
9623
|
});
|
|
9040
9624
|
}
|
|
9041
|
-
/** Changes any layer mask's density, feather or
|
|
9625
|
+
/** Changes any layer mask's density, feather, enabled or linked flag (pixels kept). Returns the mask. */
|
|
9042
9626
|
setLayerMaskProps(id, props, commitToHistory = true) {
|
|
9043
9627
|
const layer = requireLayer(this.state.layers, id).layer;
|
|
9044
9628
|
if (!layer.mask) throw new LayerOperationError(`Layer "${layer.name || id}" has no mask; add one with add_layer_mask.`);
|
|
@@ -9078,7 +9662,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9078
9662
|
const next = { ...layer, surface: out };
|
|
9079
9663
|
delete next.mask;
|
|
9080
9664
|
delete next.source;
|
|
9081
|
-
this.commitLayers(
|
|
9665
|
+
this.commitLayers(_chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, id, () => next), () => {
|
|
9082
9666
|
if (this.state.activeLayerId === id) this.state.activeTarget = "pixels";
|
|
9083
9667
|
});
|
|
9084
9668
|
}
|
|
@@ -9093,7 +9677,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9093
9677
|
const layer = loc.layer;
|
|
9094
9678
|
if (layer.type !== "pixel") throw new LayerOperationError(`Layer via copy needs a pixel layer; "${id}" is a ${layer.type} layer.`);
|
|
9095
9679
|
const sel = this.state.selection;
|
|
9096
|
-
if (!_optionalChain([sel, 'optionalAccess',
|
|
9680
|
+
if (!_optionalChain([sel, 'optionalAccess', _197 => _197.bounds])) throw new LayerOperationError("Nothing is selected; select the pixels to copy first.");
|
|
9097
9681
|
if (options.cut) requireUnlocked(layer, "pixels", "cut from it");
|
|
9098
9682
|
const surface = this.surfaceOf(layer);
|
|
9099
9683
|
const sb = sel.bounds;
|
|
@@ -9111,18 +9695,18 @@ var ImageEditorController = (_class7 = class {
|
|
|
9111
9695
|
const copy = {
|
|
9112
9696
|
type: "pixel",
|
|
9113
9697
|
id: newLayerId(),
|
|
9114
|
-
name: _optionalChain([options, 'access',
|
|
9698
|
+
name: _optionalChain([options, 'access', _198 => _198.name, 'optionalAccess', _199 => _199.trim, 'call', _200 => _200()]) || `${layer.name || "Layer"} ${options.cut ? "cut" : "copy"}`,
|
|
9115
9699
|
visible: true,
|
|
9116
9700
|
opacity: 1,
|
|
9117
9701
|
blend: "normal",
|
|
9118
9702
|
surface: _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width: src.width, height: src.height, data: px2 }, 4, src.x, src.y),
|
|
9119
9703
|
offset: { ...layer.offset }
|
|
9120
9704
|
};
|
|
9121
|
-
let next =
|
|
9705
|
+
let next = _chunkWT6ZAWJPcjs.insertLayer.call(void 0, this.state.layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _201 => _201.parent, 'optionalAccess', _202 => _202.id]), () => ( null)), loc.index + 1);
|
|
9122
9706
|
if (kept) {
|
|
9123
9707
|
const cutLayer = { ...layer, surface: _chunkCRMAXIUVcjs.writeRegion.call(void 0, surface, src, kept) };
|
|
9124
9708
|
delete cutLayer.source;
|
|
9125
|
-
next =
|
|
9709
|
+
next = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, next, id, () => cutLayer);
|
|
9126
9710
|
}
|
|
9127
9711
|
this.commitLayers(next, () => {
|
|
9128
9712
|
this.state.activeLayerId = copy.id;
|
|
@@ -9130,24 +9714,152 @@ var ImageEditorController = (_class7 = class {
|
|
|
9130
9714
|
});
|
|
9131
9715
|
return copy.id;
|
|
9132
9716
|
}
|
|
9717
|
+
// --- Free Transform ---
|
|
9718
|
+
__init52() {this.openTransform = null}
|
|
9719
|
+
/** The Free Transform in progress (see `beginFreeTransform`), or `null`. */
|
|
9720
|
+
getFreeTransform() {
|
|
9721
|
+
if (this.openTransform && !this.openTransform.isOpen) this.openTransform = null;
|
|
9722
|
+
return this.openTransform;
|
|
9723
|
+
}
|
|
9724
|
+
transformHost() {
|
|
9725
|
+
return {
|
|
9726
|
+
layers: () => this.state.layers,
|
|
9727
|
+
activeLayerId: () => this.state.activeLayerId,
|
|
9728
|
+
activeTarget: () => this.state.activeTarget,
|
|
9729
|
+
selection: () => _optionalChain([this, 'access', _203 => _203.state, 'access', _204 => _204.selection, 'optionalAccess', _205 => _205.bounds]) ? this.state.selection : null,
|
|
9730
|
+
canvas: () => this.naturalSize,
|
|
9731
|
+
pixelsOf: (layer) => this.surfaceOf(layer),
|
|
9732
|
+
capture: () => this.captureHistoryEntry(),
|
|
9733
|
+
show: (layers, selection, active) => {
|
|
9734
|
+
this.state.layers = layers;
|
|
9735
|
+
this.state.selection = selection;
|
|
9736
|
+
if (active !== this.state.activeLayerId) {
|
|
9737
|
+
this.state.activeLayerId = active;
|
|
9738
|
+
this.state.activeTarget = "pixels";
|
|
9739
|
+
}
|
|
9740
|
+
this.notify();
|
|
9741
|
+
},
|
|
9742
|
+
record: (before) => {
|
|
9743
|
+
if (this.isApplyingHistory) return;
|
|
9744
|
+
this.undoStack.push(before);
|
|
9745
|
+
if (this.undoStack.length > this.maxHistoryDepth) this.undoStack.shift();
|
|
9746
|
+
this.redoStack = [];
|
|
9747
|
+
this.trimHistoryBytes();
|
|
9748
|
+
this.notify();
|
|
9749
|
+
},
|
|
9750
|
+
restore: (before) => {
|
|
9751
|
+
const e = before;
|
|
9752
|
+
this.state.layers = e.layers;
|
|
9753
|
+
this.state.selection = e.selection;
|
|
9754
|
+
this.state.activeLayerId = e.activeLayerId;
|
|
9755
|
+
this.state.activeTarget = e.activeTarget;
|
|
9756
|
+
this.notify();
|
|
9757
|
+
}
|
|
9758
|
+
};
|
|
9759
|
+
}
|
|
9760
|
+
/**
|
|
9761
|
+
* Starts a Free Transform (Edit › Free Transform, Transform Selection, or a transform of a Layer
|
|
9762
|
+
* via Copy): of the layer's pixels with its linked mask, an unlinked mask alone, the selected
|
|
9763
|
+
* pixels or just the selection outline (see `FreeTransformInit`). Change the geometry with
|
|
9764
|
+
* `session.update` (live preview, no history), then `commit()` (one undo step) or `cancel()`.
|
|
9765
|
+
* Refused while another transform is open.
|
|
9766
|
+
*/
|
|
9767
|
+
beginFreeTransform(init = {}) {
|
|
9768
|
+
if (this.getFreeTransform()) throw new LayerOperationError("A Free Transform is already open; commit or cancel it first.");
|
|
9769
|
+
const session = new FreeTransformSession(this.transformHost(), init);
|
|
9770
|
+
this.openTransform = session;
|
|
9771
|
+
this.notify();
|
|
9772
|
+
return session;
|
|
9773
|
+
}
|
|
9774
|
+
/**
|
|
9775
|
+
* Transforms in one step (agents, scripts): begins a Free Transform for `spec`, sets its corners
|
|
9776
|
+
* from exactly one of `matrix` (document-space affine), `corners` (where the frame's corners go:
|
|
9777
|
+
* distort / perspective) or `params` (scale, rotate, skew and move about a reference point), and
|
|
9778
|
+
* commits it as one undo step. Returns what changed and the new bounds.
|
|
9779
|
+
*/
|
|
9780
|
+
transformLayer(spec) {
|
|
9781
|
+
const given = [spec.matrix, spec.corners, spec.params].filter((v) => v !== void 0).length;
|
|
9782
|
+
if (given > 1) throw new LayerOperationError("Give only one of matrix, corners and params.");
|
|
9783
|
+
if (!given && spec.warp === void 0) throw new LayerOperationError("Give matrix, corners or params (or a warp).");
|
|
9784
|
+
if (spec.matrix && !(Array.isArray(spec.matrix) && spec.matrix.length === 6 && spec.matrix.every(Number.isFinite))) {
|
|
9785
|
+
throw new LayerOperationError("matrix must be six finite numbers [a, b, c, d, e, f] (x' = a\xB7x + c\xB7y + e, y' = b\xB7x + d\xB7y + f).");
|
|
9786
|
+
}
|
|
9787
|
+
if (spec.matrix) {
|
|
9788
|
+
const [a, b, c, d] = spec.matrix;
|
|
9789
|
+
if (Math.abs(a * d - b * c) < 1e-9) throw new LayerOperationError("matrix is singular (it collapses the layer to a line); its determinant a\xB7d \u2212 b\xB7c must not be 0.");
|
|
9790
|
+
}
|
|
9791
|
+
const session = this.beginFreeTransform(spec);
|
|
9792
|
+
try {
|
|
9793
|
+
const g = identityTransform(session.box);
|
|
9794
|
+
const corners = spec.matrix ? cornersFromMatrix(session.box, spec.matrix) : spec.corners ? spec.corners : spec.params ? applyParams(g, spec.params) : g.corners;
|
|
9795
|
+
let warp = null;
|
|
9796
|
+
if (spec.warp) {
|
|
9797
|
+
if ("style" in spec.warp) {
|
|
9798
|
+
if (!_chunkDWGZUSEScjs.WARP_STYLES.includes(spec.warp.style)) throw new LayerOperationError(`Unknown warp style "${String(spec.warp.style)}". Styles: ${_chunkDWGZUSEScjs.WARP_STYLES.join(", ")}.`);
|
|
9799
|
+
warp = presetWarp(session.box, spec.warp);
|
|
9800
|
+
} else {
|
|
9801
|
+
if (!isValidWarp(spec.warp)) throw new LayerOperationError("mesh must have us and vs (knots from 0 to 1, increasing) and (3\xB7columns + 1) \xD7 (3\xB7rows + 1) finite points, row by row.");
|
|
9802
|
+
warp = spec.warp;
|
|
9803
|
+
}
|
|
9804
|
+
}
|
|
9805
|
+
session.update({ corners, warp }, false);
|
|
9806
|
+
return session.commit();
|
|
9807
|
+
} catch (e) {
|
|
9808
|
+
session.cancel();
|
|
9809
|
+
throw e;
|
|
9810
|
+
}
|
|
9811
|
+
}
|
|
9812
|
+
/** Flips the layer (or its selected pixels, or the outline) about the frame's centre, exactly (one undo step). */
|
|
9813
|
+
flipLayer(axis, init = {}) {
|
|
9814
|
+
if (axis !== "horizontal" && axis !== "vertical") throw new LayerOperationError(`axis must be horizontal or vertical, got "${String(axis)}".`);
|
|
9815
|
+
const session = this.beginFreeTransform({ interpolation: "nearest", ...init });
|
|
9816
|
+
try {
|
|
9817
|
+
session.update({ corners: flipCorners(identityTransform(session.box), axis) }, false);
|
|
9818
|
+
return session.commit();
|
|
9819
|
+
} catch (e) {
|
|
9820
|
+
session.cancel();
|
|
9821
|
+
throw e;
|
|
9822
|
+
}
|
|
9823
|
+
}
|
|
9824
|
+
/**
|
|
9825
|
+
* Rotates by a quarter turn (90 clockwise, −90 counter-clockwise) or 180 about the frame's
|
|
9826
|
+
* centre, snapped so pixels land on whole pixels: exact, no resampling (one undo step).
|
|
9827
|
+
*/
|
|
9828
|
+
rotateLayer90(turn, init = {}) {
|
|
9829
|
+
if (turn !== 90 && turn !== -90 && turn !== 180) throw new LayerOperationError(`turn must be 90, -90 or 180, got ${String(turn)}.`);
|
|
9830
|
+
const session = this.beginFreeTransform({ interpolation: "nearest", ...init });
|
|
9831
|
+
try {
|
|
9832
|
+
const b = session.box;
|
|
9833
|
+
const cx = b.x + b.width / 2;
|
|
9834
|
+
const cy = b.y + b.height / 2;
|
|
9835
|
+
const ox = turn === 180 ? 0 : Math.round(cx - b.height / 2) - (cx - b.height / 2);
|
|
9836
|
+
const oy = turn === 180 ? 0 : Math.round(cy - b.width / 2) - (cy - b.width / 2);
|
|
9837
|
+
const m = turn === 90 ? [0, 1, -1, 0, cx + cy + ox, cy - cx + oy] : turn === -90 ? [0, -1, 1, 0, cx - cy + ox, cy + cx + oy] : [-1, 0, 0, -1, 2 * cx, 2 * cy];
|
|
9838
|
+
session.update({ corners: cornersFromMatrix(b, m) }, false);
|
|
9839
|
+
return session.commit();
|
|
9840
|
+
} catch (e) {
|
|
9841
|
+
session.cancel();
|
|
9842
|
+
throw e;
|
|
9843
|
+
}
|
|
9844
|
+
}
|
|
9133
9845
|
/** Adds a `develop` or `blur` filter to a pixel layer (one undo step). Returns the layer's filters. */
|
|
9134
9846
|
addLayerFilter(id, filter) {
|
|
9135
9847
|
const f = normalizeFilter(filter);
|
|
9136
9848
|
const next = addLayerFilter(this.state.layers, id, f);
|
|
9137
9849
|
this.commitLayers(next);
|
|
9138
|
-
return _nullishCoalesce(
|
|
9850
|
+
return _nullishCoalesce(_chunkWT6ZAWJPcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
|
|
9139
9851
|
}
|
|
9140
9852
|
/** Changes one filter (one undo step, or none with `commitToHistory = false` during a drag). Returns the filters. */
|
|
9141
9853
|
updateLayerFilter(id, filterId, changes, commitToHistory = true) {
|
|
9142
9854
|
const next = updateLayerFilter(this.state.layers, id, filterId, changes);
|
|
9143
9855
|
this.commitLayers(next, void 0, commitToHistory);
|
|
9144
|
-
return _nullishCoalesce(
|
|
9856
|
+
return _nullishCoalesce(_chunkWT6ZAWJPcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
|
|
9145
9857
|
}
|
|
9146
9858
|
/** Removes one filter (one undo step). Returns the remaining filters. */
|
|
9147
9859
|
removeLayerFilter(id, filterId) {
|
|
9148
9860
|
const next = removeLayerFilter(this.state.layers, id, filterId);
|
|
9149
9861
|
this.commitLayers(next);
|
|
9150
|
-
return _nullishCoalesce(
|
|
9862
|
+
return _nullishCoalesce(_chunkWT6ZAWJPcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
|
|
9151
9863
|
}
|
|
9152
9864
|
// --- Layer effects ---
|
|
9153
9865
|
/** A layer's effects (an empty, enabled list when it has none). */
|
|
@@ -9183,7 +9895,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9183
9895
|
this.commitLayers(setLayerEffects(this.state.layers, id, effects), void 0, commitToHistory);
|
|
9184
9896
|
return this.getLayerEffects(id);
|
|
9185
9897
|
}
|
|
9186
|
-
|
|
9898
|
+
__init53() {this.patternIds = /* @__PURE__ */ new WeakMap()}
|
|
9187
9899
|
/** Changes whenever the document's pattern list is replaced (the compositor then drops its caches). */
|
|
9188
9900
|
patternsVersion() {
|
|
9189
9901
|
const list2 = this.state.patterns;
|
|
@@ -9201,7 +9913,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9201
9913
|
}
|
|
9202
9914
|
/** The light effects with "use global light" follow. */
|
|
9203
9915
|
getGlobalLight() {
|
|
9204
|
-
return { ..._nullishCoalesce(this.state.globalLight, () => (
|
|
9916
|
+
return { ..._nullishCoalesce(this.state.globalLight, () => ( _chunkWT6ZAWJPcjs.DEFAULT_GLOBAL_LIGHT)) };
|
|
9205
9917
|
}
|
|
9206
9918
|
/** Sets the global light (one undo step). `angle` -360..360°, `altitude` 0..90°. Returns it. */
|
|
9207
9919
|
setGlobalLight(light, commitToHistory = true) {
|
|
@@ -9209,7 +9921,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9209
9921
|
if (!(Number.isFinite(next.angle) && next.angle >= -360 && next.angle <= 360)) throw new LayerOperationError(`angle must be from -360 to 360 degrees, got ${next.angle}.`);
|
|
9210
9922
|
if (!(Number.isFinite(next.altitude) && next.altitude >= 0 && next.altitude <= 90)) throw new LayerOperationError(`altitude must be from 0 to 90 degrees, got ${next.altitude}.`);
|
|
9211
9923
|
if (commitToHistory) this.recordHistory();
|
|
9212
|
-
if (next.angle ===
|
|
9924
|
+
if (next.angle === _chunkWT6ZAWJPcjs.DEFAULT_GLOBAL_LIGHT.angle && next.altitude === _chunkWT6ZAWJPcjs.DEFAULT_GLOBAL_LIGHT.altitude) delete this.state.globalLight;
|
|
9213
9925
|
else this.state.globalLight = next;
|
|
9214
9926
|
this.notify();
|
|
9215
9927
|
return this.getGlobalLight();
|
|
@@ -9217,7 +9929,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9217
9929
|
/** Composites `layers` (in isolation) over `rect` into a surface, loading depth maps first. */
|
|
9218
9930
|
async compositeToSurface(layers, rect) {
|
|
9219
9931
|
const { width, height } = this.naturalSize;
|
|
9220
|
-
if (
|
|
9932
|
+
if (_chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers).some((l) => l.type === "annotation" && l.visible) && !this.renderer.canRasterize()) {
|
|
9221
9933
|
throw new LayerOperationError("Merging annotation layers needs a canvas (a browser); hide or delete them first, or merge in the browser.");
|
|
9222
9934
|
}
|
|
9223
9935
|
await this.renderer.prepareLayerAssets(layers, width, height);
|
|
@@ -9257,7 +9969,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9257
9969
|
requireUnlocked(upper, "all", "merge it");
|
|
9258
9970
|
requireUnlocked(lower, "pixels", "merge into it");
|
|
9259
9971
|
let rect = _nullishCoalesce(unionRect(this.paintBounds(lower), upper.type === "adjustment" ? null : this.paintBounds(upper)), () => ( { x: 0, y: 0, width: 1, height: 1 }));
|
|
9260
|
-
const reach = Math.max(
|
|
9972
|
+
const reach = Math.max(_chunkWT6ZAWJPcjs.effectsMargin.call(void 0, lower.effects), upper.type === "adjustment" ? 0 : _chunkWT6ZAWJPcjs.effectsMargin.call(void 0, upper.effects));
|
|
9261
9973
|
if (reach) rect = { x: rect.x - reach, y: rect.y - reach, width: rect.width + 2 * reach, height: rect.height + 2 * reach };
|
|
9262
9974
|
const base = { ...lower, blend: "normal", opacity: 1 };
|
|
9263
9975
|
delete base.clipped;
|
|
@@ -9268,8 +9980,8 @@ var ImageEditorController = (_class7 = class {
|
|
|
9268
9980
|
delete merged.filters;
|
|
9269
9981
|
delete merged.source;
|
|
9270
9982
|
delete merged.effects;
|
|
9271
|
-
let next =
|
|
9272
|
-
next =
|
|
9983
|
+
let next = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, id, () => null);
|
|
9984
|
+
next = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, next, lower.id, () => merged);
|
|
9273
9985
|
this.commitLayers(next, () => {
|
|
9274
9986
|
this.state.activeLayerId = merged.id;
|
|
9275
9987
|
this.state.activeTarget = "pixels";
|
|
@@ -9326,7 +10038,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9326
10038
|
});
|
|
9327
10039
|
return bg.id;
|
|
9328
10040
|
}
|
|
9329
|
-
|
|
10041
|
+
__init54() {this.thumbCache = /* @__PURE__ */ new WeakMap()}
|
|
9330
10042
|
/**
|
|
9331
10043
|
* A small RGBA preview of a pixel layer over the canvas (or of its mask with `mask: true`),
|
|
9332
10044
|
* longest side `maxSide` px, point-sampled; `null` for layers without pixels.
|
|
@@ -9345,7 +10057,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9345
10057
|
const oy = layer.type === "pixel" ? layer.offset.y : 0;
|
|
9346
10058
|
const key = `${tw}x${th}:${ox},${oy}`;
|
|
9347
10059
|
let byKey = this.thumbCache.get(surface);
|
|
9348
|
-
const hit = _optionalChain([byKey, 'optionalAccess',
|
|
10060
|
+
const hit = _optionalChain([byKey, 'optionalAccess', _206 => _206.get, 'call', _207 => _207(key)]);
|
|
9349
10061
|
if (hit) return hit;
|
|
9350
10062
|
const out = new Uint8ClampedArray(tw * th * 4);
|
|
9351
10063
|
for (let y = 0; y < th; y++) {
|
|
@@ -9433,7 +10145,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9433
10145
|
if (!layer.visible) throw new LayerOperationError(`Layer "${layer.name || id}" is hidden; show it before you ${action}.`);
|
|
9434
10146
|
const offset = layer.type === "pixel" ? layer.offset : { x: 0, y: 0 };
|
|
9435
10147
|
const surface = ch === "mask" ? layer.mask.surface : this.surfaceOf(layer);
|
|
9436
|
-
const lockTransparency = ch === "pixels" && Boolean(_optionalChain([layer, 'access',
|
|
10148
|
+
const lockTransparency = ch === "pixels" && Boolean(_optionalChain([layer, 'access', _208 => _208.locks, 'optionalAccess', _209 => _209.transparency]));
|
|
9437
10149
|
return { id, layer, channel: ch, offset, surface, lockTransparency };
|
|
9438
10150
|
}
|
|
9439
10151
|
/** The layer with its pixels (or mask) replaced by `surface`. */
|
|
@@ -9470,7 +10182,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9470
10182
|
opacity: brush.opacity,
|
|
9471
10183
|
blend: target.channel === "mask" ? "normal" : brush.blend,
|
|
9472
10184
|
lockTransparency: target.lockTransparency,
|
|
9473
|
-
selection: _optionalChain([this, 'access',
|
|
10185
|
+
selection: _optionalChain([this, 'access', _210 => _210.state, 'access', _211 => _211.selection, 'optionalAccess', _212 => _212.bounds]) ? this.state.selection : null,
|
|
9474
10186
|
offset: target.offset
|
|
9475
10187
|
};
|
|
9476
10188
|
if (tool === "mixer") return new PaintStrokeSession(this, target, this.mixerStroke(init, brush), apply);
|
|
@@ -9495,12 +10207,12 @@ var ImageEditorController = (_class7 = class {
|
|
|
9495
10207
|
}
|
|
9496
10208
|
/** @internal Shows a stroke's live surface (no history). */
|
|
9497
10209
|
_strokeUpdate(layerId, channel, surface, rects) {
|
|
9498
|
-
this.state.layers =
|
|
10210
|
+
this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => this.withSurface(l, channel, surface));
|
|
9499
10211
|
this.notify(rects);
|
|
9500
10212
|
}
|
|
9501
10213
|
/** @internal Commits a finished stroke as one undo step (`before` is the pre-stroke state). */
|
|
9502
10214
|
_strokeCommit(before, layerId, channel, surface) {
|
|
9503
|
-
if (surface) this.state.layers =
|
|
10215
|
+
if (surface) this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => this.withSurface(l, channel, surface));
|
|
9504
10216
|
else this.state.layers = before.layers;
|
|
9505
10217
|
if (surface && !this.isApplyingHistory) {
|
|
9506
10218
|
this.undoStack.push(before);
|
|
@@ -9522,7 +10234,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9522
10234
|
paintStroke(init) {
|
|
9523
10235
|
if (!Array.isArray(init.points) || !init.points.length) throw new LayerOperationError("points must hold at least one { x, y } point.");
|
|
9524
10236
|
for (const p of init.points) {
|
|
9525
|
-
if (!Number.isFinite(_optionalChain([p, 'optionalAccess',
|
|
10237
|
+
if (!Number.isFinite(_optionalChain([p, 'optionalAccess', _213 => _213.x])) || !Number.isFinite(_optionalChain([p, 'optionalAccess', _214 => _214.y]))) throw new LayerOperationError("Every point needs finite x and y (document pixels).");
|
|
9526
10238
|
}
|
|
9527
10239
|
const session = this.beginStroke(init);
|
|
9528
10240
|
session.push(init.points);
|
|
@@ -9550,8 +10262,8 @@ var ImageEditorController = (_class7 = class {
|
|
|
9550
10262
|
const opacity = _nullishCoalesce(options.opacity, () => ( 1));
|
|
9551
10263
|
if (!(opacity >= 0 && opacity <= 1)) throw new LayerOperationError("opacity must be from 0 to 1.");
|
|
9552
10264
|
const blend = _nullishCoalesce(parseBlend(options.blend), () => ( "normal"));
|
|
9553
|
-
const sel = options.useSelection !== false && _optionalChain([this, 'access',
|
|
9554
|
-
const region = _nullishCoalesce(_optionalChain([sel, 'optionalAccess',
|
|
10265
|
+
const sel = options.useSelection !== false && _optionalChain([this, 'access', _215 => _215.state, 'access', _216 => _216.selection, 'optionalAccess', _217 => _217.bounds]) ? this.state.selection : null;
|
|
10266
|
+
const region = _nullishCoalesce(_optionalChain([sel, 'optionalAccess', _218 => _218.bounds]), () => ( { x: 0, y: 0, width, height }));
|
|
9555
10267
|
const coverage = new (0, _chunkZZOTHJ4Kcjs.CoverageMap)();
|
|
9556
10268
|
const ones = new Float32Array(region.width * region.height);
|
|
9557
10269
|
if (sel) {
|
|
@@ -9577,7 +10289,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9577
10289
|
offset: target.offset
|
|
9578
10290
|
};
|
|
9579
10291
|
const surface = paintCoverageInto(target.surface, coverage, apply, [region]);
|
|
9580
|
-
const next =
|
|
10292
|
+
const next = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => this.withSurface(l, target.channel, surface));
|
|
9581
10293
|
this.commitLayers(next);
|
|
9582
10294
|
return { layerId: target.id, channel: target.channel, bounds: region, dabs: 0 };
|
|
9583
10295
|
}
|
|
@@ -9599,12 +10311,12 @@ var ImageEditorController = (_class7 = class {
|
|
|
9599
10311
|
const target = this.developLayer();
|
|
9600
10312
|
let layers = this.state.layers;
|
|
9601
10313
|
if (target && (DEVELOP_KEYS.some((k) => k in partial) || "process" in partial)) {
|
|
9602
|
-
layers =
|
|
10314
|
+
layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, target.id, (l) => withDevelop(l, partial));
|
|
9603
10315
|
}
|
|
9604
10316
|
if ("blur" in partial && typeof partial.blur === "number") {
|
|
9605
10317
|
const blur = Math.max(0, partial.blur);
|
|
9606
10318
|
if (this.state.legacyOutputBlur !== void 0) this.state.legacyOutputBlur = blur;
|
|
9607
|
-
else if (target) layers =
|
|
10319
|
+
else if (target) layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, target.id, (l) => withBlur(l, blur));
|
|
9608
10320
|
}
|
|
9609
10321
|
if ("opacity" in partial && typeof partial.opacity === "number") {
|
|
9610
10322
|
this.state.outputOpacity = Math.min(1, Math.max(0, partial.opacity));
|
|
@@ -9634,7 +10346,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9634
10346
|
this.recordHistory();
|
|
9635
10347
|
const target = this.developLayer();
|
|
9636
10348
|
if (target) {
|
|
9637
|
-
this.state.layers =
|
|
10349
|
+
this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0,
|
|
9638
10350
|
this.state.layers,
|
|
9639
10351
|
target.id,
|
|
9640
10352
|
(l) => withBlur(withDevelop(l, { ...DEFAULT_ADJUSTMENTS, process: LATEST_PROCESS_VERSION }), 0)
|
|
@@ -9654,7 +10366,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9654
10366
|
return this.getAdjustmentLayers().find((l) => l.id === id);
|
|
9655
10367
|
}
|
|
9656
10368
|
adjustmentNodes(layers = this.state.layers) {
|
|
9657
|
-
return
|
|
10369
|
+
return _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "adjustment");
|
|
9658
10370
|
}
|
|
9659
10371
|
/**
|
|
9660
10372
|
* Where a new layer goes when no position is given: directly above the topmost layer that is
|
|
@@ -9668,26 +10380,26 @@ var ImageEditorController = (_class7 = class {
|
|
|
9668
10380
|
/** Inserts `node` by `aboveId` / `parentId` / adjustment index / default position. */
|
|
9669
10381
|
placeLayer(layers, node, where) {
|
|
9670
10382
|
if (where.aboveId) {
|
|
9671
|
-
const loc =
|
|
9672
|
-
if (loc) return
|
|
10383
|
+
const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, where.aboveId);
|
|
10384
|
+
if (loc) return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _219 => _219.parent, 'optionalAccess', _220 => _220.id]), () => ( null)), loc.index + 1);
|
|
9673
10385
|
}
|
|
9674
10386
|
if (where.parentId) {
|
|
9675
|
-
const loc =
|
|
9676
|
-
if (loc && loc.layer.type === "group") return
|
|
10387
|
+
const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, where.parentId);
|
|
10388
|
+
if (loc && loc.layer.type === "group") return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, node, loc.layer.id);
|
|
9677
10389
|
}
|
|
9678
10390
|
if (where.adjustmentIndex !== void 0) {
|
|
9679
10391
|
const nodes = this.adjustmentNodes(layers);
|
|
9680
10392
|
const at = Math.max(0, Math.min(nodes.length, Math.round(where.adjustmentIndex)));
|
|
9681
10393
|
if (at < nodes.length) {
|
|
9682
|
-
const loc =
|
|
9683
|
-
return
|
|
10394
|
+
const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, nodes[at].id);
|
|
10395
|
+
return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _221 => _221.parent, 'optionalAccess', _222 => _222.id]), () => ( null)), loc.index);
|
|
9684
10396
|
}
|
|
9685
10397
|
if (nodes.length) {
|
|
9686
|
-
const loc =
|
|
9687
|
-
return
|
|
10398
|
+
const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, nodes[nodes.length - 1].id);
|
|
10399
|
+
return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _223 => _223.parent, 'optionalAccess', _224 => _224.id]), () => ( null)), loc.index + 1);
|
|
9688
10400
|
}
|
|
9689
10401
|
}
|
|
9690
|
-
return
|
|
10402
|
+
return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, layers, node, null, this.defaultInsertIndex(layers));
|
|
9691
10403
|
}
|
|
9692
10404
|
/** `setAdjustments({ layers })`: updates nodes by id in place, removes missing ones, adds new ones. */
|
|
9693
10405
|
replaceAdjustmentNodes(layers, next) {
|
|
@@ -9696,7 +10408,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9696
10408
|
let out = layers;
|
|
9697
10409
|
for (const node of this.adjustmentNodes(layers)) {
|
|
9698
10410
|
const update = byId.get(node.id);
|
|
9699
|
-
out =
|
|
10411
|
+
out = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, out, node.id, () => update ? mergeAdjustmentNode(node, update, width, height) : null);
|
|
9700
10412
|
}
|
|
9701
10413
|
const existing = new Set(this.adjustmentNodes(out).map((n) => n.id));
|
|
9702
10414
|
for (const l of next) {
|
|
@@ -9715,7 +10427,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9715
10427
|
*/
|
|
9716
10428
|
addAdjustmentLayer(init, index) {
|
|
9717
10429
|
const spec = typeof init === "string" ? { kind: init } : init;
|
|
9718
|
-
const ids = new Set(
|
|
10430
|
+
const ids = new Set(_chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.id));
|
|
9719
10431
|
const layer = createAdjustmentLayer(spec.kind, {
|
|
9720
10432
|
id: spec.id && !ids.has(spec.id) ? spec.id : void 0,
|
|
9721
10433
|
name: spec.name,
|
|
@@ -9744,7 +10456,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9744
10456
|
* Returns false for an unknown id.
|
|
9745
10457
|
*/
|
|
9746
10458
|
updateAdjustmentLayer(id, update, commitToHistory = true) {
|
|
9747
|
-
const loc =
|
|
10459
|
+
const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, this.state.layers, id);
|
|
9748
10460
|
if (!loc || loc.layer.type !== "adjustment") return false;
|
|
9749
10461
|
const { width, height } = this.naturalSize;
|
|
9750
10462
|
const node = loc.layer;
|
|
@@ -9772,16 +10484,16 @@ var ImageEditorController = (_class7 = class {
|
|
|
9772
10484
|
if (mask) next.mask = mask;
|
|
9773
10485
|
else delete next.mask;
|
|
9774
10486
|
}
|
|
9775
|
-
this.state.layers =
|
|
10487
|
+
this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, id, () => next);
|
|
9776
10488
|
this.notify();
|
|
9777
10489
|
return true;
|
|
9778
10490
|
}
|
|
9779
10491
|
/** Removes a layer as one undo step. Returns false for an unknown id. */
|
|
9780
10492
|
removeAdjustmentLayer(id) {
|
|
9781
|
-
const loc =
|
|
10493
|
+
const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, this.state.layers, id);
|
|
9782
10494
|
if (!loc || loc.layer.type !== "adjustment") return false;
|
|
9783
10495
|
this.recordHistory();
|
|
9784
|
-
this.state.layers =
|
|
10496
|
+
this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, id, () => null);
|
|
9785
10497
|
if (this.state.activeLayerId === id) this.state.activeLayerId = null;
|
|
9786
10498
|
this.notify();
|
|
9787
10499
|
return true;
|
|
@@ -9794,9 +10506,9 @@ var ImageEditorController = (_class7 = class {
|
|
|
9794
10506
|
if (to === from) return layers;
|
|
9795
10507
|
const node = nodes[from];
|
|
9796
10508
|
const anchor = nodes[to];
|
|
9797
|
-
const without =
|
|
9798
|
-
const loc =
|
|
9799
|
-
return
|
|
10509
|
+
const without = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, id, () => null);
|
|
10510
|
+
const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, without, anchor.id);
|
|
10511
|
+
return _chunkWT6ZAWJPcjs.insertLayer.call(void 0, without, node, _nullishCoalesce(_optionalChain([loc, 'access', _225 => _225.parent, 'optionalAccess', _226 => _226.id]), () => ( null)), to > from ? loc.index + 1 : loc.index);
|
|
9800
10512
|
}
|
|
9801
10513
|
/** Moves a layer to `toIndex` among the adjustment layers (0 = bottom) as one undo step. Returns false if nothing moved. */
|
|
9802
10514
|
moveAdjustmentLayer(id, toIndex) {
|
|
@@ -9821,7 +10533,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9821
10533
|
if (!nodes.length) return;
|
|
9822
10534
|
this.recordHistory();
|
|
9823
10535
|
let layers = this.state.layers;
|
|
9824
|
-
for (const n of nodes) layers =
|
|
10536
|
+
for (const n of nodes) layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, n.id, () => null);
|
|
9825
10537
|
this.state.layers = layers;
|
|
9826
10538
|
if (nodes.some((n) => n.id === this.state.activeLayerId)) this.state.activeLayerId = null;
|
|
9827
10539
|
this.notify();
|
|
@@ -9832,7 +10544,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9832
10544
|
return _nullishCoalesce(this.state.selection, () => ( null));
|
|
9833
10545
|
}
|
|
9834
10546
|
get hasSelection() {
|
|
9835
|
-
return Boolean(_optionalChain([this, 'access',
|
|
10547
|
+
return Boolean(_optionalChain([this, 'access', _227 => _227.state, 'access', _228 => _228.selection, 'optionalAccess', _229 => _229.bounds]));
|
|
9836
10548
|
}
|
|
9837
10549
|
get naturalSize() {
|
|
9838
10550
|
return {
|
|
@@ -9922,13 +10634,13 @@ var ImageEditorController = (_class7 = class {
|
|
|
9922
10634
|
try {
|
|
9923
10635
|
const canvas = await this.renderSource();
|
|
9924
10636
|
const ctx = canvas.getContext("2d");
|
|
9925
|
-
const data2 = _optionalChain([ctx, 'optionalAccess',
|
|
10637
|
+
const data2 = _optionalChain([ctx, 'optionalAccess', _230 => _230.getImageData, 'optionalCall', _231 => _231(0, 0, width, height)]);
|
|
9926
10638
|
if (data2 && data2.data && data2.data.length >= width * height * 4) {
|
|
9927
10639
|
base = { width, height, data: data2.data };
|
|
9928
10640
|
this.samplePixels = base;
|
|
9929
10641
|
this.samplePixelsOverride = false;
|
|
9930
10642
|
}
|
|
9931
|
-
} catch (
|
|
10643
|
+
} catch (e26) {
|
|
9932
10644
|
base = null;
|
|
9933
10645
|
}
|
|
9934
10646
|
}
|
|
@@ -9988,7 +10700,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9988
10700
|
/** Select › Modify: grow, shrink, feather, border or smooth by `radius` pixels (one undo step). */
|
|
9989
10701
|
modifySelection(op, radius) {
|
|
9990
10702
|
const sel = this.state.selection;
|
|
9991
|
-
if (!_optionalChain([sel, 'optionalAccess',
|
|
10703
|
+
if (!_optionalChain([sel, 'optionalAccess', _232 => _232.bounds])) return false;
|
|
9992
10704
|
return this.setSelection(modifySelection(sel, op, radius));
|
|
9993
10705
|
}
|
|
9994
10706
|
/**
|
|
@@ -9997,7 +10709,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
9997
10709
|
*/
|
|
9998
10710
|
async refineSelection(params, options = {}) {
|
|
9999
10711
|
const sel = this.state.selection;
|
|
10000
|
-
if (!_optionalChain([sel, 'optionalAccess',
|
|
10712
|
+
if (!_optionalChain([sel, 'optionalAccess', _233 => _233.bounds])) return false;
|
|
10001
10713
|
const pixels = (_nullishCoalesce(params.radius, () => ( 0))) > 0 ? await this.requirePixels(options) : null;
|
|
10002
10714
|
return this.setSelection(refineSelection(pixels, sel, params));
|
|
10003
10715
|
}
|
|
@@ -10014,7 +10726,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10014
10726
|
const canvas = this.renderer.createCanvas(w, h);
|
|
10015
10727
|
const ctx = canvas.getContext("2d");
|
|
10016
10728
|
if (ctx) ctx.drawImage(img, 0, 0, w, h);
|
|
10017
|
-
const data = _optionalChain([ctx, 'optionalAccess',
|
|
10729
|
+
const data = _optionalChain([ctx, 'optionalAccess', _234 => _234.getImageData, 'optionalCall', _235 => _235(0, 0, w, h)]);
|
|
10018
10730
|
if (!data) throw new Error("The mask image pixels are not available (no canvas access); pass pixels.");
|
|
10019
10731
|
pixels = { width: w, height: h, data: data.data };
|
|
10020
10732
|
} else {
|
|
@@ -10042,14 +10754,14 @@ var ImageEditorController = (_class7 = class {
|
|
|
10042
10754
|
*/
|
|
10043
10755
|
applySelectionAsLayerMask(layerId, props = {}) {
|
|
10044
10756
|
const sel = this.state.selection;
|
|
10045
|
-
if (!_optionalChain([sel, 'optionalAccess',
|
|
10757
|
+
if (!_optionalChain([sel, 'optionalAccess', _236 => _236.bounds]) || !this.getAdjustmentLayer(layerId)) return false;
|
|
10046
10758
|
return this.setLayerMask(layerId, this.maskFromSelection(sel, props));
|
|
10047
10759
|
}
|
|
10048
10760
|
setLayerMask(layerId, mask, commitToHistory = true) {
|
|
10049
|
-
const loc =
|
|
10761
|
+
const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, this.state.layers, layerId);
|
|
10050
10762
|
if (!loc) return false;
|
|
10051
10763
|
if (commitToHistory) this.recordHistory();
|
|
10052
|
-
this.state.layers =
|
|
10764
|
+
this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => {
|
|
10053
10765
|
const next = { ...l };
|
|
10054
10766
|
if (mask) next.mask = mask;
|
|
10055
10767
|
else delete next.mask;
|
|
@@ -10073,7 +10785,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10073
10785
|
/** Load Selection from a layer mask (its pixels; density and feather are not applied). */
|
|
10074
10786
|
selectionFromLayerMask(layerId, mode = "replace") {
|
|
10075
10787
|
const layer = this.getLayer(layerId);
|
|
10076
|
-
if (!_optionalChain([layer, 'optionalAccess',
|
|
10788
|
+
if (!_optionalChain([layer, 'optionalAccess', _237 => _237.mask]) || layer.mask.source) return false;
|
|
10077
10789
|
const { width, height } = this.naturalSize;
|
|
10078
10790
|
const ox = layer.type === "pixel" ? layer.offset.x : 0;
|
|
10079
10791
|
const oy = layer.type === "pixel" ? layer.offset.y : 0;
|
|
@@ -10106,10 +10818,10 @@ var ImageEditorController = (_class7 = class {
|
|
|
10106
10818
|
if (target) {
|
|
10107
10819
|
const merged = { ...this.state.depthMask, ...partial };
|
|
10108
10820
|
merged.depthRange = [...merged.depthRange];
|
|
10109
|
-
this.state.layers =
|
|
10821
|
+
this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => {
|
|
10110
10822
|
const next = { ...l };
|
|
10111
10823
|
if (isDefaultDepthMask(merged)) {
|
|
10112
|
-
if (_optionalChain([next, 'access',
|
|
10824
|
+
if (_optionalChain([next, 'access', _238 => _238.mask, 'optionalAccess', _239 => _239.source])) delete next.mask;
|
|
10113
10825
|
} else next.mask = depthRasterMask(merged);
|
|
10114
10826
|
return next;
|
|
10115
10827
|
});
|
|
@@ -10119,8 +10831,8 @@ var ImageEditorController = (_class7 = class {
|
|
|
10119
10831
|
resetDepthMask() {
|
|
10120
10832
|
this.recordHistory();
|
|
10121
10833
|
const target = this.developLayer();
|
|
10122
|
-
if (_optionalChain([target, 'optionalAccess',
|
|
10123
|
-
this.state.layers =
|
|
10834
|
+
if (_optionalChain([target, 'optionalAccess', _240 => _240.mask, 'optionalAccess', _241 => _241.source])) {
|
|
10835
|
+
this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => {
|
|
10124
10836
|
const next = { ...l };
|
|
10125
10837
|
delete next.mask;
|
|
10126
10838
|
return next;
|
|
@@ -10130,7 +10842,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10130
10842
|
}
|
|
10131
10843
|
// --- Annotations & Layers ---
|
|
10132
10844
|
annotationLayer(id) {
|
|
10133
|
-
return
|
|
10845
|
+
return _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).find(
|
|
10134
10846
|
(l) => l.type === "annotation" && l.annotation.id === id
|
|
10135
10847
|
);
|
|
10136
10848
|
}
|
|
@@ -10140,8 +10852,8 @@ var ImageEditorController = (_class7 = class {
|
|
|
10140
10852
|
const id = `ann_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`;
|
|
10141
10853
|
const fullAnnotation = { ...annotation, id };
|
|
10142
10854
|
const layer = annotationLayerFor(fullAnnotation);
|
|
10143
|
-
const loc = placement.aboveId ?
|
|
10144
|
-
this.state.layers = loc ?
|
|
10855
|
+
const loc = placement.aboveId ? _chunkWT6ZAWJPcjs.findLayer.call(void 0, this.state.layers, placement.aboveId) : null;
|
|
10856
|
+
this.state.layers = loc ? _chunkWT6ZAWJPcjs.insertLayer.call(void 0, this.state.layers, layer, _nullishCoalesce(_optionalChain([loc, 'access', _242 => _242.parent, 'optionalAccess', _243 => _243.id]), () => ( null)), loc.index + 1) : _chunkWT6ZAWJPcjs.insertLayer.call(void 0, this.state.layers, layer, null);
|
|
10145
10857
|
this.state.selectedAnnotationId = id;
|
|
10146
10858
|
this.notify();
|
|
10147
10859
|
return id;
|
|
@@ -10154,14 +10866,14 @@ var ImageEditorController = (_class7 = class {
|
|
|
10154
10866
|
if (layer) {
|
|
10155
10867
|
const annotation = { ...layer.annotation, ...partial, id };
|
|
10156
10868
|
const name = layer.name === annotationLayerName(layer.annotation) ? annotationLayerName(annotation) : layer.name;
|
|
10157
|
-
this.state.layers =
|
|
10869
|
+
this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, layer.id, () => ({ ...layer, annotation, name }));
|
|
10158
10870
|
}
|
|
10159
10871
|
this.notify();
|
|
10160
10872
|
}
|
|
10161
10873
|
removeAnnotation(id) {
|
|
10162
10874
|
this.recordHistory();
|
|
10163
10875
|
const layer = this.annotationLayer(id);
|
|
10164
|
-
if (layer) this.state.layers =
|
|
10876
|
+
if (layer) this.state.layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, layer.id, () => null);
|
|
10165
10877
|
if (this.state.selectedAnnotationId === id) {
|
|
10166
10878
|
this.state.selectedAnnotationId = null;
|
|
10167
10879
|
}
|
|
@@ -10170,7 +10882,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10170
10882
|
clearAnnotations() {
|
|
10171
10883
|
this.recordHistory();
|
|
10172
10884
|
let layers = this.state.layers;
|
|
10173
|
-
for (const l of
|
|
10885
|
+
for (const l of _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers)) if (l.type === "annotation") layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, l.id, () => null);
|
|
10174
10886
|
this.state.layers = layers;
|
|
10175
10887
|
this.state.selectedAnnotationId = null;
|
|
10176
10888
|
this.notify();
|
|
@@ -10210,7 +10922,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10210
10922
|
this.notify();
|
|
10211
10923
|
}
|
|
10212
10924
|
// --- Rendering & Export ---
|
|
10213
|
-
|
|
10925
|
+
__init55() {this.blankSource = null}
|
|
10214
10926
|
/**
|
|
10215
10927
|
* What the renderer draws from: the source image, or, for a document without one (an opened
|
|
10216
10928
|
* PSD, a v3 document loaded on its own), a transparent canvas of the document size, since every
|
|
@@ -10238,7 +10950,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10238
10950
|
dirty: dirty === "all" ? void 0 : dirty,
|
|
10239
10951
|
checkpointLayerId: this.state.activeLayerId
|
|
10240
10952
|
});
|
|
10241
|
-
} catch (
|
|
10953
|
+
} catch (e27) {
|
|
10242
10954
|
}
|
|
10243
10955
|
}
|
|
10244
10956
|
async renderExport(options) {
|
|
@@ -10247,9 +10959,9 @@ var ImageEditorController = (_class7 = class {
|
|
|
10247
10959
|
return this.renderer.createCanvas(1, 1);
|
|
10248
10960
|
}
|
|
10249
10961
|
this.syncViews();
|
|
10250
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10962
|
+
if (_optionalChain([options, 'optionalAccess', _244 => _244.layerIds])) {
|
|
10251
10963
|
const keep = new Set(options.layerIds);
|
|
10252
|
-
const layers =
|
|
10964
|
+
const layers = _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).filter((l) => keep.has(l.id));
|
|
10253
10965
|
return this.renderer.renderExport(source, { ...this.state, layers }, options);
|
|
10254
10966
|
}
|
|
10255
10967
|
return this.renderer.renderExport(source, this.state, options);
|
|
@@ -10359,10 +11071,10 @@ var ImageEditorController = (_class7 = class {
|
|
|
10359
11071
|
/** No source image, and no layer reading one (an opened PSD): the layers are the whole document. */
|
|
10360
11072
|
isSourceless() {
|
|
10361
11073
|
if (this.imageElement || this.state.sourceUrl || !this.state.layers.length) return false;
|
|
10362
|
-
return !
|
|
11074
|
+
return !_chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).some((l) => l.type === "pixel" && l.source === "document");
|
|
10363
11075
|
}
|
|
10364
11076
|
get isMultiLayer() {
|
|
10365
|
-
return
|
|
11077
|
+
return _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.state.layers).filter((l) => l.type === "pixel" || l.type === "group").length > 1;
|
|
10366
11078
|
}
|
|
10367
11079
|
/**
|
|
10368
11080
|
* Applies an inpainted result (natural image space, see `toSourceDataURL`) as ONE undoable step.
|
|
@@ -10380,7 +11092,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10380
11092
|
let px2 = await this.decodeImage(newDataUrl);
|
|
10381
11093
|
if (px2.width !== width || px2.height !== height) px2 = resizePixels(px2, width, height);
|
|
10382
11094
|
const data = new Uint8ClampedArray(px2.data);
|
|
10383
|
-
const sel = _optionalChain([this, 'access',
|
|
11095
|
+
const sel = _optionalChain([this, 'access', _245 => _245.state, 'access', _246 => _246.selection, 'optionalAccess', _247 => _247.bounds]) ? this.state.selection : null;
|
|
10384
11096
|
if (sel) for (let p = 0, i = 3; p < width * height; p++, i += 4) data[i] = Math.round(data[i] * sel.data[p] / 255);
|
|
10385
11097
|
return this.addPixelLayer({ name: "Inpaint", pixels: { width, height, data } });
|
|
10386
11098
|
}
|
|
@@ -10432,7 +11144,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10432
11144
|
if (layer.locks) next.locks = layer.locks;
|
|
10433
11145
|
if (this.state.selectedAnnotationId === layer.annotation.id) this.state.selectedAnnotationId = null;
|
|
10434
11146
|
} else if (layer.type === "pixel") {
|
|
10435
|
-
if (!_optionalChain([layer, 'access',
|
|
11147
|
+
if (!_optionalChain([layer, 'access', _248 => _248.filters, 'optionalAccess', _249 => _249.length])) throw new LayerOperationError(`Layer "${layer.name || id}" is already pixels with no filters to bake.`);
|
|
10436
11148
|
requireUnlocked(layer, "pixels", "rasterize it");
|
|
10437
11149
|
const spatial = layer.filters.some((f) => f.enabled && f.kind === "blur");
|
|
10438
11150
|
const content = { ...layer, visible: true, opacity: 1, blend: "normal" };
|
|
@@ -10450,7 +11162,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10450
11162
|
} else {
|
|
10451
11163
|
throw new LayerOperationError(`Only annotation layers and pixel layers with filters rasterize; "${layer.name || id}" is a ${layer.type} layer. Merge it down or flatten instead.`);
|
|
10452
11164
|
}
|
|
10453
|
-
this.commitLayers(
|
|
11165
|
+
this.commitLayers(_chunkWT6ZAWJPcjs.mapLayer.call(void 0, this.state.layers, id, () => next));
|
|
10454
11166
|
return id;
|
|
10455
11167
|
}
|
|
10456
11168
|
// --- PSD ---
|
|
@@ -10477,7 +11189,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10477
11189
|
delete s.legacyOutputBlur;
|
|
10478
11190
|
s.selection = null;
|
|
10479
11191
|
s.selectedAnnotationId = null;
|
|
10480
|
-
const pixels =
|
|
11192
|
+
const pixels = _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, result.layers).filter((l) => l.type === "pixel");
|
|
10481
11193
|
s.activeLayerId = pixels.length ? pixels[pixels.length - 1].id : null;
|
|
10482
11194
|
s.activeTarget = "pixels";
|
|
10483
11195
|
this.psdResolution = result.resolution;
|
|
@@ -10488,7 +11200,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10488
11200
|
this.lastLoadProblems = result.warnings;
|
|
10489
11201
|
this.notify();
|
|
10490
11202
|
return {
|
|
10491
|
-
layerIds:
|
|
11203
|
+
layerIds: _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, result.layers).map((l) => l.id),
|
|
10492
11204
|
warnings: result.warnings,
|
|
10493
11205
|
width: result.width,
|
|
10494
11206
|
height: result.height,
|
|
@@ -10506,15 +11218,15 @@ var ImageEditorController = (_class7 = class {
|
|
|
10506
11218
|
const canvas = { x: 0, y: 0, width, height };
|
|
10507
11219
|
const warnings = [];
|
|
10508
11220
|
const note = /* @__PURE__ */ new Map();
|
|
10509
|
-
const
|
|
11221
|
+
const add2 = (msg, name) => note.set(msg, [..._nullishCoalesce(note.get(msg), () => ( [])), name]);
|
|
10510
11222
|
const canRasterize = this.renderer.canRasterize();
|
|
10511
11223
|
await this.renderer.prepareLayerAssets(this.state.layers, width, height);
|
|
10512
11224
|
const sources = this.renderer.compositorSources(width, height);
|
|
10513
11225
|
const compositor = new LayerCompositor();
|
|
10514
11226
|
const bakeMask = (layer) => {
|
|
10515
11227
|
const mask = layer.mask;
|
|
10516
|
-
if (!_optionalChain([mask, 'optionalAccess',
|
|
10517
|
-
|
|
11228
|
+
if (!_optionalChain([mask, 'optionalAccess', _250 => _250.source])) return mask;
|
|
11229
|
+
add2("Parametric (depth) masks were baked into pixel masks", layer.name);
|
|
10518
11230
|
const plain3 = { ...layer, mask: { ...mask, density: 1, feather: 0, enabled: true } };
|
|
10519
11231
|
const ox = layer.type === "pixel" ? layer.offset.x : 0;
|
|
10520
11232
|
const oy = layer.type === "pixel" ? layer.offset.y : 0;
|
|
@@ -10530,7 +11242,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10530
11242
|
};
|
|
10531
11243
|
const prepare = async (layer) => {
|
|
10532
11244
|
const p = await prepareLayer(layer);
|
|
10533
|
-
if (_optionalChain([p, 'optionalAccess',
|
|
11245
|
+
if (_optionalChain([p, 'optionalAccess', _251 => _251.blend]) === "pigment") add2("The Pigment blend mode has no PSD equivalent and was written as Normal", layer.name);
|
|
10534
11246
|
return p;
|
|
10535
11247
|
};
|
|
10536
11248
|
const prepareLayer = async (layer) => {
|
|
@@ -10545,10 +11257,10 @@ var ImageEditorController = (_class7 = class {
|
|
|
10545
11257
|
if (layer.type === "adjustment") return { ...layer, mask: bakeMask(layer) };
|
|
10546
11258
|
if (layer.type === "annotation") {
|
|
10547
11259
|
if (!canRasterize) {
|
|
10548
|
-
|
|
11260
|
+
add2("Annotation layers need a canvas (a browser) to rasterize and were left out", layer.name);
|
|
10549
11261
|
return null;
|
|
10550
11262
|
}
|
|
10551
|
-
|
|
11263
|
+
add2("Annotation layers were written as pixel layers", layer.name);
|
|
10552
11264
|
const blend = layer.blend === "normal" && layer.annotation.blend ? layer.annotation.blend : layer.blend;
|
|
10553
11265
|
const content = { ...layer, visible: true, opacity: 1, blend: "normal", annotation: { ...layer.annotation, blend: void 0 } };
|
|
10554
11266
|
delete content.mask;
|
|
@@ -10577,9 +11289,9 @@ var ImageEditorController = (_class7 = class {
|
|
|
10577
11289
|
out.surface = this.surfaceOf(layer);
|
|
10578
11290
|
delete out.source;
|
|
10579
11291
|
}
|
|
10580
|
-
const active = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
11292
|
+
const active = _nullishCoalesce(_optionalChain([layer, 'access', _252 => _252.filters, 'optionalAccess', _253 => _253.filter, 'call', _254 => _254(isActiveFilter)]), () => ( []));
|
|
10581
11293
|
if (active.length) {
|
|
10582
|
-
|
|
11294
|
+
add2("Layer filters (develop, blur) were baked into the pixels", layer.name);
|
|
10583
11295
|
const content = { ...out, visible: true, opacity: 1, blend: "normal" };
|
|
10584
11296
|
delete content.mask;
|
|
10585
11297
|
delete content.clipped;
|
|
@@ -10588,7 +11300,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10588
11300
|
const data = compositor.composite([content], canvas, sources);
|
|
10589
11301
|
out = { ...out, surface: _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width, height, data }, 4, -layer.offset.x, -layer.offset.y) };
|
|
10590
11302
|
}
|
|
10591
|
-
if (_optionalChain([layer, 'access',
|
|
11303
|
+
if (_optionalChain([layer, 'access', _255 => _255.filters, 'optionalAccess', _256 => _256.some, 'call', _257 => _257((f) => !f.enabled)])) add2("Disabled layer filters were left out", layer.name);
|
|
10592
11304
|
delete out.filters;
|
|
10593
11305
|
const mask = bakeMask(layer);
|
|
10594
11306
|
if (mask) out.mask = mask;
|
|
@@ -10641,16 +11353,16 @@ var ImageEditorController = (_class7 = class {
|
|
|
10641
11353
|
);
|
|
10642
11354
|
}
|
|
10643
11355
|
layers = resizeLegacyMasks(layers, prev, next.dimensions);
|
|
10644
|
-
for (const l of
|
|
11356
|
+
for (const l of _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers)) {
|
|
10645
11357
|
if (l.type === "annotation") {
|
|
10646
|
-
layers =
|
|
11358
|
+
layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, l.id, () => ({ ...l, annotation: scaleAnnotation(l.annotation, sx, sy) }));
|
|
10647
11359
|
}
|
|
10648
11360
|
}
|
|
10649
11361
|
}
|
|
10650
11362
|
const bg = developTarget(layers, null);
|
|
10651
|
-
if (bg && bg.source !== "document") layers =
|
|
11363
|
+
if (bg && bg.source !== "document") layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, bg.id, () => ({ ...bg, source: "document" }));
|
|
10652
11364
|
if (clearAnnotations) {
|
|
10653
|
-
for (const l of
|
|
11365
|
+
for (const l of _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers)) if (l.type === "annotation") layers = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, layers, l.id, () => null);
|
|
10654
11366
|
this.state.selectedAnnotationId = null;
|
|
10655
11367
|
}
|
|
10656
11368
|
this.state.layers = layers;
|
|
@@ -10658,7 +11370,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10658
11370
|
}
|
|
10659
11371
|
toJSON(options) {
|
|
10660
11372
|
const out = this.serializeState();
|
|
10661
|
-
if (_optionalChain([this, 'access',
|
|
11373
|
+
if (_optionalChain([this, 'access', _258 => _258.state, 'access', _259 => _259.selection, 'optionalAccess', _260 => _260.bounds])) out.selection = serializeSelection(this.state.selection);
|
|
10662
11374
|
if (!options || out.version !== LAYERED_SCHEMA_VERSION) return options ? Promise.resolve(out) : out;
|
|
10663
11375
|
return serializeLayersExternal(this.state.layers, options.store).then(({ layers, assets }) => ({ ...out, layers, assets }));
|
|
10664
11376
|
}
|
|
@@ -10685,7 +11397,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10685
11397
|
if (data.selection) {
|
|
10686
11398
|
try {
|
|
10687
11399
|
selection = normalizeSelection(deserializeSelection(data.selection));
|
|
10688
|
-
} catch (
|
|
11400
|
+
} catch (e28) {
|
|
10689
11401
|
selection = null;
|
|
10690
11402
|
}
|
|
10691
11403
|
}
|
|
@@ -10694,7 +11406,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10694
11406
|
this.notify();
|
|
10695
11407
|
}
|
|
10696
11408
|
/** Problems found by the last `loadJSON` / `initialState` of a v3 document (unreadable layers or assets). */
|
|
10697
|
-
|
|
11409
|
+
__init56() {this.lastLoadProblems = []}
|
|
10698
11410
|
applyStored(raw) {
|
|
10699
11411
|
const s = this.state;
|
|
10700
11412
|
const data = migrateSerializedImageEditorState(raw);
|
|
@@ -10708,7 +11420,7 @@ var ImageEditorController = (_class7 = class {
|
|
|
10708
11420
|
s.outputOpacity = data.opacity;
|
|
10709
11421
|
if (typeof data.legacyOutputBlur === "number" && data.legacyOutputBlur >= 0) s.legacyOutputBlur = data.legacyOutputBlur;
|
|
10710
11422
|
else delete s.legacyOutputBlur;
|
|
10711
|
-
s.activeLayerId = data.activeLayerId &&
|
|
11423
|
+
s.activeLayerId = data.activeLayerId && _chunkWT6ZAWJPcjs.findLayer.call(void 0, s.layers, data.activeLayerId) ? data.activeLayerId : null;
|
|
10712
11424
|
const light = data.globalLight;
|
|
10713
11425
|
if (light && Number.isFinite(light.angle) && Number.isFinite(light.altitude)) s.globalLight = { angle: light.angle, altitude: Math.min(90, Math.max(0, light.altitude)) };
|
|
10714
11426
|
else delete s.globalLight;
|
|
@@ -10739,10 +11451,10 @@ var ImageEditorController = (_class7 = class {
|
|
|
10739
11451
|
serializeState() {
|
|
10740
11452
|
const { width, height } = this.naturalSize;
|
|
10741
11453
|
const view = legacyView(this.stack(), width, height, null);
|
|
10742
|
-
if (view.exact && !this.state.globalLight && !_optionalChain([this, 'access',
|
|
11454
|
+
if (view.exact && !this.state.globalLight && !_optionalChain([this, 'access', _261 => _261.state, 'access', _262 => _262.patterns, 'optionalAccess', _263 => _263.length])) {
|
|
10743
11455
|
return {
|
|
10744
11456
|
// States without adjustment layers keep schema 1, so they round-trip unchanged.
|
|
10745
|
-
version: _optionalChain([view, 'access',
|
|
11457
|
+
version: _optionalChain([view, 'access', _264 => _264.adjustments, 'access', _265 => _265.layers, 'optionalAccess', _266 => _266.length]) ? 2 : 1,
|
|
10746
11458
|
crop: this.state.crop ? { ...this.state.crop } : null,
|
|
10747
11459
|
transform: { ...this.state.transform },
|
|
10748
11460
|
adjustments: serializeAdjustments(view.adjustments),
|
|
@@ -10767,13 +11479,13 @@ var ImageEditorController = (_class7 = class {
|
|
|
10767
11479
|
};
|
|
10768
11480
|
if (this.state.legacyOutputBlur !== void 0) out.legacyOutputBlur = this.state.legacyOutputBlur;
|
|
10769
11481
|
if (this.state.globalLight) out.globalLight = { ...this.state.globalLight };
|
|
10770
|
-
if (_optionalChain([this, 'access',
|
|
11482
|
+
if (_optionalChain([this, 'access', _267 => _267.state, 'access', _268 => _268.patterns, 'optionalAccess', _269 => _269.length])) out.patterns = serializePatterns(this.state.patterns);
|
|
10771
11483
|
return out;
|
|
10772
11484
|
}
|
|
10773
|
-
},
|
|
11485
|
+
}, _class8);
|
|
10774
11486
|
function serializeAdjustments(adjustments) {
|
|
10775
11487
|
const out = { ...adjustments };
|
|
10776
|
-
if (_optionalChain([out, 'access',
|
|
11488
|
+
if (_optionalChain([out, 'access', _270 => _270.layers, 'optionalAccess', _271 => _271.length])) out.layers = JSON.parse(JSON.stringify(out.layers));
|
|
10777
11489
|
else delete out.layers;
|
|
10778
11490
|
if (normalizeProcessVersion(out.process) === LEGACY_PROCESS_VERSION) {
|
|
10779
11491
|
delete out.process;
|
|
@@ -10809,11 +11521,11 @@ function withDevelop(layer, partial) {
|
|
|
10809
11521
|
return { ...layer, filters };
|
|
10810
11522
|
}
|
|
10811
11523
|
function withBlur(layer, radius) {
|
|
10812
|
-
const existing = _optionalChain([layer, 'access',
|
|
11524
|
+
const existing = _optionalChain([layer, 'access', _272 => _272.filters, 'optionalAccess', _273 => _273.find, 'call', _274 => _274((f) => f.kind === "blur")]);
|
|
10813
11525
|
const filters = (_nullishCoalesce(layer.filters, () => ( []))).filter((f) => f.kind !== "blur");
|
|
10814
11526
|
if (radius > 0) {
|
|
10815
11527
|
filters.push({
|
|
10816
|
-
id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess',
|
|
11528
|
+
id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _275 => _275.id]), () => ( (layer.source === "document" ? BLUR_FILTER_ID : newLayerId("flt")))),
|
|
10817
11529
|
kind: "blur",
|
|
10818
11530
|
enabled: true,
|
|
10819
11531
|
radius
|
|
@@ -10868,6 +11580,10 @@ function withMaskProps(mask, props) {
|
|
|
10868
11580
|
if (props.enabled) delete next.enabled;
|
|
10869
11581
|
else next.enabled = false;
|
|
10870
11582
|
}
|
|
11583
|
+
if (props.linked !== void 0) {
|
|
11584
|
+
if (props.linked) delete next.linked;
|
|
11585
|
+
else next.linked = false;
|
|
11586
|
+
}
|
|
10871
11587
|
return next;
|
|
10872
11588
|
}
|
|
10873
11589
|
function resizeLegacyMasks(layers, from, to) {
|
|
@@ -10877,12 +11593,12 @@ function resizeLegacyMasks(layers, from, to) {
|
|
|
10877
11593
|
const th = Math.max(1, Math.round(to.height));
|
|
10878
11594
|
if (fw === tw && fh === th) return layers;
|
|
10879
11595
|
let out = layers;
|
|
10880
|
-
for (const l of
|
|
11596
|
+
for (const l of _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers)) {
|
|
10881
11597
|
if (l.type !== "adjustment" || !l.mask || l.mask.source) continue;
|
|
10882
11598
|
const old = l.mask;
|
|
10883
11599
|
const mask = rasterMaskFromLegacy(legacyMaskOf(old, fw, fh), tw, th);
|
|
10884
11600
|
if (!mask) continue;
|
|
10885
|
-
out =
|
|
11601
|
+
out = _chunkWT6ZAWJPcjs.mapLayer.call(void 0, out, l.id, (n) => ({ ...n, mask: { ...mask, density: old.density, feather: old.feather, enabled: old.enabled } }));
|
|
10886
11602
|
}
|
|
10887
11603
|
return out;
|
|
10888
11604
|
}
|
|
@@ -10895,7 +11611,7 @@ function isOpaqueInside(surface, width, height) {
|
|
|
10895
11611
|
return true;
|
|
10896
11612
|
}
|
|
10897
11613
|
function collectStateTiles(layers, into) {
|
|
10898
|
-
for (const l of
|
|
11614
|
+
for (const l of _chunkWT6ZAWJPcjs.flattenLayers.call(void 0, layers)) {
|
|
10899
11615
|
if (l.type === "pixel" && l.source !== "document") _chunkCRMAXIUVcjs.collectTiles.call(void 0, l.surface, into);
|
|
10900
11616
|
if (l.mask && !l.mask.source) _chunkCRMAXIUVcjs.collectTiles.call(void 0, l.mask.surface, into);
|
|
10901
11617
|
}
|
|
@@ -10905,7 +11621,7 @@ function pixelsOnly(layers) {
|
|
|
10905
11621
|
for (const l of layers) {
|
|
10906
11622
|
if (l.type === "adjustment") continue;
|
|
10907
11623
|
if (l.type === "group") out.push({ ...l, children: pixelsOnly(l.children) });
|
|
10908
|
-
else if (l.type === "pixel" && _optionalChain([l, 'access',
|
|
11624
|
+
else if (l.type === "pixel" && _optionalChain([l, 'access', _276 => _276.filters, 'optionalAccess', _277 => _277.length])) {
|
|
10909
11625
|
const p = { ...l };
|
|
10910
11626
|
delete p.filters;
|
|
10911
11627
|
out.push(p);
|
|
@@ -10963,7 +11679,7 @@ function toHex2(c) {
|
|
|
10963
11679
|
return "#" + [c[0], c[1], c[2]].map((v) => Math.round(v).toString(16).padStart(2, "0")).join("");
|
|
10964
11680
|
}
|
|
10965
11681
|
function normalizeSelection(mask) {
|
|
10966
|
-
return _optionalChain([mask, 'optionalAccess',
|
|
11682
|
+
return _optionalChain([mask, 'optionalAccess', _278 => _278.bounds]) ? mask : null;
|
|
10967
11683
|
}
|
|
10968
11684
|
function sameSelection(a, b) {
|
|
10969
11685
|
if (a.width !== b.width || a.height !== b.height) return false;
|
|
@@ -11068,7 +11784,7 @@ function loadImageEditorDocument(input) {
|
|
|
11068
11784
|
if (typeof input === "string") {
|
|
11069
11785
|
try {
|
|
11070
11786
|
parsed = JSON.parse(input);
|
|
11071
|
-
} catch (
|
|
11787
|
+
} catch (e29) {
|
|
11072
11788
|
parsed = input;
|
|
11073
11789
|
}
|
|
11074
11790
|
}
|
|
@@ -11124,7 +11840,7 @@ function loadImageEditorDocument(input) {
|
|
|
11124
11840
|
}
|
|
11125
11841
|
const state = { version: 1, ...result.value };
|
|
11126
11842
|
if (isV2) {
|
|
11127
|
-
if (_optionalChain([state, 'access',
|
|
11843
|
+
if (_optionalChain([state, 'access', _279 => _279.adjustments, 'access', _280 => _280.layers, 'optionalAccess', _281 => _281.length])) state.version = 2;
|
|
11128
11844
|
result.report.version = 2;
|
|
11129
11845
|
}
|
|
11130
11846
|
if (state.selection === void 0) delete state.selection;
|
|
@@ -11324,7 +12040,7 @@ function findAdjustmentControl(id) {
|
|
|
11324
12040
|
}
|
|
11325
12041
|
function findLayerControl(kind, id) {
|
|
11326
12042
|
if (id === "opacity") return ADJUSTMENT_LAYER_OPACITY_CONTROL;
|
|
11327
|
-
return _optionalChain([ADJUSTMENT_LAYER_CONTROLS, 'access',
|
|
12043
|
+
return _optionalChain([ADJUSTMENT_LAYER_CONTROLS, 'access', _282 => _282[kind], 'optionalAccess', _283 => _283.find, 'call', _284 => _284((c) => c.id === id)]);
|
|
11328
12044
|
}
|
|
11329
12045
|
function clampControlValue(spec, v) {
|
|
11330
12046
|
if (typeof v !== "number" || !Number.isFinite(v)) return spec.default;
|
|
@@ -11443,7 +12159,7 @@ function summary(controller) {
|
|
|
11443
12159
|
const area = selectionArea(sel);
|
|
11444
12160
|
return {
|
|
11445
12161
|
empty: !sel,
|
|
11446
|
-
bounds: _nullishCoalesce(_optionalChain([sel, 'optionalAccess',
|
|
12162
|
+
bounds: _nullishCoalesce(_optionalChain([sel, 'optionalAccess', _285 => _285.bounds]), () => ( null)),
|
|
11447
12163
|
/** Σ coverage in pixels. */
|
|
11448
12164
|
area: Math.round(area),
|
|
11449
12165
|
percent: Math.round(area / Math.max(1, width * height) * 1e4) / 100,
|
|
@@ -11687,7 +12403,7 @@ async function renderImageRegion(controller, request) {
|
|
|
11687
12403
|
if (request.includeOverlays) {
|
|
11688
12404
|
const s = request.scale;
|
|
11689
12405
|
const selection = state.selection;
|
|
11690
|
-
if (_optionalChain([selection, 'optionalAccess',
|
|
12406
|
+
if (_optionalChain([selection, 'optionalAccess', _286 => _286.bounds]) && selection.width === state.imageDimensions.width && selection.height === state.imageDimensions.height) {
|
|
11691
12407
|
const shade = selectionShade(selection, document);
|
|
11692
12408
|
if (shade) context.drawImage(shade, rect.x, rect.y, rect.width, rect.height, 0, 0, out.width, out.height);
|
|
11693
12409
|
}
|
|
@@ -11712,7 +12428,7 @@ function createImageCaptureSurface(controller) {
|
|
|
11712
12428
|
return {
|
|
11713
12429
|
units: "image pixels",
|
|
11714
12430
|
content: whole,
|
|
11715
|
-
selection: () => ({ rect: _nullishCoalesce(_optionalChain([controller, 'access',
|
|
12431
|
+
selection: () => ({ rect: _nullishCoalesce(_optionalChain([controller, 'access', _287 => _287.getState, 'call', _288 => _288(), 'access', _289 => _289.selection, 'optionalAccess', _290 => _290.bounds]), () => ( null)) }),
|
|
11716
12432
|
overlays: "a shade over unselected pixels and the crop box outline",
|
|
11717
12433
|
maxScale: 8,
|
|
11718
12434
|
render: (request) => renderImageRegion(controller, request)
|
|
@@ -11985,6 +12701,7 @@ function maskSummary(mask) {
|
|
|
11985
12701
|
const out = {
|
|
11986
12702
|
kind: mask.source ? "depth" : "raster",
|
|
11987
12703
|
enabled: mask.enabled !== false,
|
|
12704
|
+
linked: mask.linked !== false,
|
|
11988
12705
|
density: _nullishCoalesce(mask.density, () => ( 1)),
|
|
11989
12706
|
feather: _nullishCoalesce(mask.feather, () => ( 0))
|
|
11990
12707
|
};
|
|
@@ -12049,11 +12766,11 @@ function placementFrom(args) {
|
|
|
12049
12766
|
function createImageLayerTools(controller) {
|
|
12050
12767
|
const describe = (id) => {
|
|
12051
12768
|
const s = controller.getState();
|
|
12052
|
-
const loc =
|
|
12769
|
+
const loc = _chunkWT6ZAWJPcjs.findLayer.call(void 0, s.layers, id);
|
|
12053
12770
|
if (!loc) return null;
|
|
12054
12771
|
return {
|
|
12055
12772
|
...describeLayer(loc.layer, s.activeLayerId, (x) => controller.getLayerBounds(x.id)),
|
|
12056
|
-
parentId: _nullishCoalesce(_optionalChain([loc, 'access',
|
|
12773
|
+
parentId: _nullishCoalesce(_optionalChain([loc, 'access', _291 => _291.parent, 'optionalAccess', _292 => _292.id]), () => ( null)),
|
|
12057
12774
|
index: loc.index
|
|
12058
12775
|
};
|
|
12059
12776
|
};
|
|
@@ -12361,23 +13078,29 @@ function createImageLayerTools(controller) {
|
|
|
12361
13078
|
const maskProps = {
|
|
12362
13079
|
name: "set_layer_mask_properties",
|
|
12363
13080
|
title: "Set layer mask properties",
|
|
12364
|
-
description: "Changes a layer mask's density (0..1), feather (px) or
|
|
13081
|
+
description: "Changes a layer mask's density (0..1), feather (px), enabled flag or linked flag; its pixels are kept. An unlinked mask (linked false) stays in place when the layer is moved, transformed or warped; transform it alone with transform_layer target mask. One undo step. Returns the mask summary.",
|
|
12365
13082
|
inputSchema: {
|
|
12366
13083
|
type: "object",
|
|
12367
13084
|
properties: {
|
|
12368
13085
|
layerId: LAYER_ID2,
|
|
12369
13086
|
density: { type: "number", minimum: 0, maximum: 1, description: "Density 0..1." },
|
|
12370
13087
|
feather: { type: "number", minimum: 0, maximum: 1e3, description: "Feather \u03C3 in px." },
|
|
12371
|
-
enabled: { type: "boolean", description: "false ignores the mask but keeps it." }
|
|
13088
|
+
enabled: { type: "boolean", description: "false ignores the mask but keeps it." },
|
|
13089
|
+
linked: { type: "boolean", description: "false unlinks the mask from the layer pixels (it stays put when they move or transform); true links it again." }
|
|
12372
13090
|
},
|
|
12373
13091
|
required: ["layerId"],
|
|
12374
13092
|
additionalProperties: false
|
|
12375
13093
|
},
|
|
12376
13094
|
annotations: { title: "Set layer mask properties", ...WRITE_IDEMPOTENT2 },
|
|
12377
|
-
handler: ({ layerId, density, feather, enabled }) => {
|
|
13095
|
+
handler: ({ layerId, density, feather, enabled, linked }) => {
|
|
12378
13096
|
const id = exists(layerId);
|
|
12379
|
-
if ([density, feather, enabled].every((v) => v === void 0)) throw new LayerOperationError("Give density, feather or
|
|
12380
|
-
const mask = controller.setLayerMaskProps(id, {
|
|
13097
|
+
if ([density, feather, enabled, linked].every((v) => v === void 0)) throw new LayerOperationError("Give density, feather, enabled or linked.");
|
|
13098
|
+
const mask = controller.setLayerMaskProps(id, {
|
|
13099
|
+
density,
|
|
13100
|
+
feather,
|
|
13101
|
+
enabled,
|
|
13102
|
+
linked
|
|
13103
|
+
});
|
|
12381
13104
|
return { layerId: id, mask: maskSummary(mask) };
|
|
12382
13105
|
}
|
|
12383
13106
|
};
|
|
@@ -12701,8 +13424,8 @@ function settingsSchema(forUpdate) {
|
|
|
12701
13424
|
}
|
|
12702
13425
|
function patternList(controller) {
|
|
12703
13426
|
const doc = controller.getDocumentPatterns().map((p) => ({ id: p.id, name: p.name, width: p.width, height: p.height, builtin: false }));
|
|
12704
|
-
const builtins =
|
|
12705
|
-
const p =
|
|
13427
|
+
const builtins = _chunkWT6ZAWJPcjs.builtinPatternIds.call(void 0, ).map((id) => {
|
|
13428
|
+
const p = _chunkWT6ZAWJPcjs.builtinPattern.call(void 0, id);
|
|
12706
13429
|
return { id, name: p.name, width: p.width, height: p.height, builtin: true };
|
|
12707
13430
|
});
|
|
12708
13431
|
return [...doc, ...builtins];
|
|
@@ -12711,9 +13434,9 @@ function describeLayerEffects(effects) {
|
|
|
12711
13434
|
return {
|
|
12712
13435
|
enabled: effects.enabled,
|
|
12713
13436
|
scale: _nullishCoalesce(effects.scale, () => ( 1)),
|
|
12714
|
-
margin:
|
|
13437
|
+
margin: _chunkWT6ZAWJPcjs.effectsMargin.call(void 0, effects),
|
|
12715
13438
|
fromPsd: Boolean(effects.psd),
|
|
12716
|
-
effects: effects.items.map((e) => ({ ...JSON.parse(JSON.stringify(e)), label:
|
|
13439
|
+
effects: effects.items.map((e) => ({ ...JSON.parse(JSON.stringify(e)), label: _chunkWT6ZAWJPcjs.layerEffectLabel.call(void 0, e.kind) }))
|
|
12717
13440
|
};
|
|
12718
13441
|
}
|
|
12719
13442
|
function createImageEffectTools(controller) {
|
|
@@ -12729,9 +13452,9 @@ function createImageEffectTools(controller) {
|
|
|
12729
13452
|
description: "Returns a layer's effects: the master switch (enabled), Scale Effects (scale, 1 = 100 %), margin (px the effects reach beyond the shape), whether they came from a PSD, and every effect with its id, kind, label and all settings. Also returns the document global light and the pattern ids pattern effects can use.",
|
|
12730
13453
|
inputSchema: { type: "object", properties: { layerId: LAYER_ID3 }, required: ["layerId"], additionalProperties: false },
|
|
12731
13454
|
annotations: { title: "List layer effects", ...READ3 },
|
|
12732
|
-
handler: ({ layerId }) => result(layerArg(layerId), { globalLight: controller.getGlobalLight(), patterns: patternList(controller), kinds: [...
|
|
13455
|
+
handler: ({ layerId }) => result(layerArg(layerId), { globalLight: controller.getGlobalLight(), patterns: patternList(controller), kinds: [..._chunkWT6ZAWJPcjs.LAYER_EFFECT_KINDS] })
|
|
12733
13456
|
};
|
|
12734
|
-
const
|
|
13457
|
+
const add2 = {
|
|
12735
13458
|
name: "add_layer_effect",
|
|
12736
13459
|
title: "Add a layer effect",
|
|
12737
13460
|
description: "Adds a live effect to a pixel, annotation or group layer with Photoshop's defaults, changed by settings: drop-shadow, inner-shadow, outer-glow, inner-glow, bevel-emboss, satin, color-overlay, gradient-overlay, pattern-overlay or stroke. Several of one kind are allowed (the first listed is on top). One undo step. Returns the new effect's id and the layer's effects.",
|
|
@@ -12740,7 +13463,7 @@ function createImageEffectTools(controller) {
|
|
|
12740
13463
|
$defs: DEFS,
|
|
12741
13464
|
properties: {
|
|
12742
13465
|
layerId: LAYER_ID3,
|
|
12743
|
-
kind: { type: "string", enum: [...
|
|
13466
|
+
kind: { type: "string", enum: [..._chunkWT6ZAWJPcjs.LAYER_EFFECT_KINDS], description: "Effect kind." },
|
|
12744
13467
|
settings: settingsSchema(false),
|
|
12745
13468
|
index: { type: "integer", minimum: 0, description: "Position in the layer's effect list (default the end)." }
|
|
12746
13469
|
},
|
|
@@ -12750,7 +13473,7 @@ function createImageEffectTools(controller) {
|
|
|
12750
13473
|
annotations: { title: "Add a layer effect", ...WRITE3 },
|
|
12751
13474
|
handler: ({ layerId, kind, settings, index }) => {
|
|
12752
13475
|
const id = layerArg(layerId);
|
|
12753
|
-
if (!
|
|
13476
|
+
if (!_chunkWT6ZAWJPcjs.isLayerEffectKind.call(void 0, kind)) throw new LayerOperationError(`kind must be one of ${_chunkWT6ZAWJPcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
|
|
12754
13477
|
const { effect } = controller.addLayerEffect(id, kind, _nullishCoalesce(settings, () => ( {})), index);
|
|
12755
13478
|
return result(id, { effectId: effect.id });
|
|
12756
13479
|
}
|
|
@@ -12829,7 +13552,7 @@ function createImageEffectTools(controller) {
|
|
|
12829
13552
|
return { globalLight: controller.setGlobalLight(next) };
|
|
12830
13553
|
}
|
|
12831
13554
|
};
|
|
12832
|
-
return [list2,
|
|
13555
|
+
return [list2, add2, update, remove, setEnabled, light];
|
|
12833
13556
|
}
|
|
12834
13557
|
|
|
12835
13558
|
// src/image-editor/layers/paint-ui.ts
|
|
@@ -12909,15 +13632,15 @@ function pointerPressure(e) {
|
|
|
12909
13632
|
if (e.pointerType === "pen" && typeof e.pressure === "number" && e.pressure > 0) return Math.min(1, e.pressure);
|
|
12910
13633
|
return 1;
|
|
12911
13634
|
}
|
|
12912
|
-
var PaintGesture = (
|
|
12913
|
-
constructor(controller) {;
|
|
13635
|
+
var PaintGesture = (_class9 = class {
|
|
13636
|
+
constructor(controller) {;_class9.prototype.__init57.call(this);_class9.prototype.__init58.call(this);_class9.prototype.__init59.call(this);
|
|
12914
13637
|
this.controller = controller;
|
|
12915
13638
|
}
|
|
12916
13639
|
|
|
12917
|
-
|
|
12918
|
-
|
|
13640
|
+
__init57() {this.stroke = null}
|
|
13641
|
+
__init58() {this.move = null}
|
|
12919
13642
|
/** The last refusal (e.g. "layer is locked"), for the editor to show. */
|
|
12920
|
-
|
|
13643
|
+
__init59() {this.error = null}
|
|
12921
13644
|
get active() {
|
|
12922
13645
|
return Boolean(this.stroke || this.move);
|
|
12923
13646
|
}
|
|
@@ -12929,7 +13652,7 @@ var PaintGesture = (_class8 = class {
|
|
|
12929
13652
|
const layer = this.controller.getActiveLayer();
|
|
12930
13653
|
if (!layer) throw new Error("Select a layer to move in the Layers panel.");
|
|
12931
13654
|
if (layer.type !== "pixel") throw new Error(`Only pixel layers move; "${layer.name}" is a ${layer.type} layer.`);
|
|
12932
|
-
if (_optionalChain([layer, 'access',
|
|
13655
|
+
if (_optionalChain([layer, 'access', _293 => _293.locks, 'optionalAccess', _294 => _294.all]) || _optionalChain([layer, 'access', _295 => _295.locks, 'optionalAccess', _296 => _296.position])) throw new Error(`Layer "${layer.name}" has its position locked.`);
|
|
12933
13656
|
this.move = { id: layer.id, start: { x: sample.x, y: sample.y }, origin: { ...layer.offset }, moved: false };
|
|
12934
13657
|
return null;
|
|
12935
13658
|
}
|
|
@@ -12978,11 +13701,11 @@ var PaintGesture = (_class8 = class {
|
|
|
12978
13701
|
this.move = null;
|
|
12979
13702
|
}
|
|
12980
13703
|
cancel() {
|
|
12981
|
-
_optionalChain([this, 'access',
|
|
13704
|
+
_optionalChain([this, 'access', _297 => _297.stroke, 'optionalAccess', _298 => _298.cancel, 'call', _299 => _299()]);
|
|
12982
13705
|
this.stroke = null;
|
|
12983
13706
|
this.move = null;
|
|
12984
13707
|
}
|
|
12985
|
-
},
|
|
13708
|
+
}, _class9);
|
|
12986
13709
|
|
|
12987
13710
|
// src/image-editor/paint-tools.ts
|
|
12988
13711
|
var READ4 = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
@@ -13174,7 +13897,7 @@ function psdBytesFromBase64(data) {
|
|
|
13174
13897
|
if (typeof data !== "string" || !data.trim()) throw new PsdError("data is required: the PSD file as base64.");
|
|
13175
13898
|
const body = data.trim().replace(/^data:[^,]*;base64,/i, "");
|
|
13176
13899
|
if (!/^[A-Za-z0-9+/=_\s-]+$/.test(body)) throw new PsdError("data is not base64; send the PSD file bytes base64-encoded.");
|
|
13177
|
-
const bytes =
|
|
13900
|
+
const bytes = _chunkWT6ZAWJPcjs.base64ToBytes.call(void 0, body);
|
|
13178
13901
|
if (bytes.length < 26) throw new PsdError(`data decodes to ${bytes.length} bytes, too short for a PSD (at least 26).`);
|
|
13179
13902
|
return bytes;
|
|
13180
13903
|
}
|
|
@@ -13225,7 +13948,7 @@ function createImagePsdTools(controller) {
|
|
|
13225
13948
|
handler: async () => {
|
|
13226
13949
|
const res = await controller.toPsd();
|
|
13227
13950
|
return {
|
|
13228
|
-
data:
|
|
13951
|
+
data: _chunkWT6ZAWJPcjs.bytesToBase64.call(void 0, res.bytes),
|
|
13229
13952
|
mimeType: "image/vnd.adobe.photoshop",
|
|
13230
13953
|
size: res.bytes.length,
|
|
13231
13954
|
psb: res.psb,
|
|
@@ -13238,6 +13961,248 @@ function createImagePsdTools(controller) {
|
|
|
13238
13961
|
return [inspect, open, save];
|
|
13239
13962
|
}
|
|
13240
13963
|
|
|
13964
|
+
// src/image-editor/transform-tools.ts
|
|
13965
|
+
var READ6 = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
13966
|
+
var WRITE5 = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
|
|
13967
|
+
var round4 = (n, digits = 3) => Math.round(n * 10 ** digits) / 10 ** digits;
|
|
13968
|
+
var roundPoint = (p) => ({ x: round4(p.x), y: round4(p.y) });
|
|
13969
|
+
var POINT = {
|
|
13970
|
+
type: "object",
|
|
13971
|
+
properties: { x: { type: "number", description: "Document pixels from the left." }, y: { type: "number", description: "Document pixels from the top." } },
|
|
13972
|
+
required: ["x", "y"],
|
|
13973
|
+
additionalProperties: false
|
|
13974
|
+
};
|
|
13975
|
+
var TARGET2 = {
|
|
13976
|
+
layerId: { type: "string", description: "Layer to transform (from list_layers; default the active layer)." },
|
|
13977
|
+
content: {
|
|
13978
|
+
type: "string",
|
|
13979
|
+
enum: FREE_TRANSFORM_CONTENTS.filter((c) => c !== "selection-outline"),
|
|
13980
|
+
description: "What moves: layer (all its pixels with a linked mask), selection (only the selected pixels, committed back into the layer; the outline moves too), selection-copy (Layer via Copy: the selected pixels on a new layer above, then transformed; the original stays) or auto (default: selection when something is selected, else layer)."
|
|
13981
|
+
},
|
|
13982
|
+
channel: {
|
|
13983
|
+
type: "string",
|
|
13984
|
+
enum: ["pixels", "mask"],
|
|
13985
|
+
description: "pixels (default) moves the pixels and a linked mask; mask moves an unlinked mask alone (a linked mask always moves with its pixels)."
|
|
13986
|
+
},
|
|
13987
|
+
interpolation: { type: "string", enum: _chunkWT6ZAWJPcjs.INTERPOLATIONS, description: "Resampling: nearest (hard pixels), bilinear or bicubic (default, Photoshop\u2019s Bicubic)." }
|
|
13988
|
+
};
|
|
13989
|
+
var GEOMETRY = {
|
|
13990
|
+
scaleX: { type: "number", description: "Width in percent of the frame (default 100; negative flips horizontally)." },
|
|
13991
|
+
scaleY: { type: "number", description: "Height in percent of the frame (default 100; negative flips vertically)." },
|
|
13992
|
+
rotate: { type: "number", description: "Rotation in degrees, clockwise (default 0)." },
|
|
13993
|
+
skewX: { type: "number", minimum: -89, maximum: 89, description: "Horizontal skew in degrees: vertical edges lean right for positive angles (default 0)." },
|
|
13994
|
+
skewY: { type: "number", minimum: -89, maximum: 89, description: "Vertical skew in degrees: horizontal edges lean down for positive angles (default 0)." },
|
|
13995
|
+
dx: { type: "number", description: "Move right after scaling and rotating, in document pixels (default 0)." },
|
|
13996
|
+
dy: { type: "number", description: "Move down after scaling and rotating, in document pixels (default 0)." },
|
|
13997
|
+
reference: {
|
|
13998
|
+
description: "Fixed point of scale, skew and rotate: an anchor of the frame (top-left, top, top-right, left, center, right, bottom-left, bottom, bottom-right; default center) or a document point {x, y}.",
|
|
13999
|
+
anyOf: [{ type: "string", enum: TRANSFORM_ANCHORS }, POINT]
|
|
14000
|
+
},
|
|
14001
|
+
matrix: {
|
|
14002
|
+
type: "array",
|
|
14003
|
+
items: { type: "number" },
|
|
14004
|
+
minItems: 6,
|
|
14005
|
+
maxItems: 6,
|
|
14006
|
+
description: "Instead of the numeric fields: an affine matrix [a, b, c, d, e, f] in document pixels (x' = a\xB7x + c\xB7y + e, y' = b\xB7x + d\xB7y + f)."
|
|
14007
|
+
},
|
|
14008
|
+
corners: {
|
|
14009
|
+
type: "array",
|
|
14010
|
+
items: POINT,
|
|
14011
|
+
minItems: 4,
|
|
14012
|
+
maxItems: 4,
|
|
14013
|
+
description: "Instead of the numeric fields: where the frame\u2019s corners go, [top-left, top-right, bottom-right, bottom-left] in document pixels (Distort; for Perspective move a pair of corners symmetrically). The quad must stay convex. Get the frame and its corners from get_transform_frame."
|
|
14014
|
+
}
|
|
14015
|
+
};
|
|
14016
|
+
var NUMERIC = ["scaleX", "scaleY", "rotate", "skewX", "skewY", "dx", "dy", "reference"];
|
|
14017
|
+
function geometryFrom(args) {
|
|
14018
|
+
const numeric = NUMERIC.filter((k) => args[k] !== void 0);
|
|
14019
|
+
const ways = [numeric.length > 0, args.matrix !== void 0, args.corners !== void 0].filter(Boolean).length;
|
|
14020
|
+
if (ways === 0) throw new LayerOperationError("Give the transform one way: numeric fields (scaleX, scaleY, rotate, skewX, skewY, dx, dy, reference), matrix, or corners.");
|
|
14021
|
+
if (ways > 1) throw new LayerOperationError("Give the transform only one way: numeric fields, matrix or corners, not a mix.");
|
|
14022
|
+
if (args.matrix !== void 0) return { matrix: args.matrix };
|
|
14023
|
+
if (args.corners !== void 0) return { corners: args.corners };
|
|
14024
|
+
const params = {};
|
|
14025
|
+
for (const k of NUMERIC) if (args[k] !== void 0) params[k] = args[k];
|
|
14026
|
+
if (params.scaleX === 0 || params.scaleY === 0) throw new LayerOperationError("scaleX and scaleY must not be 0 (that collapses the layer to a line).");
|
|
14027
|
+
if (typeof params.reference === "string" && !isTransformAnchor(params.reference)) throw new LayerOperationError(`Unknown reference "${params.reference}". Use ${TRANSFORM_ANCHORS.join(", ")} or {x, y}.`);
|
|
14028
|
+
return { params };
|
|
14029
|
+
}
|
|
14030
|
+
function targetFrom(args) {
|
|
14031
|
+
const init = {};
|
|
14032
|
+
if (typeof args.layerId === "string") init.layerId = args.layerId;
|
|
14033
|
+
if (args.content !== void 0) init.content = args.content;
|
|
14034
|
+
init.channel = _nullishCoalesce(args.channel, () => ( "pixels"));
|
|
14035
|
+
if (args.interpolation !== void 0) init.interpolation = args.interpolation;
|
|
14036
|
+
return init;
|
|
14037
|
+
}
|
|
14038
|
+
function summary2(res) {
|
|
14039
|
+
return {
|
|
14040
|
+
layerId: res.layerId,
|
|
14041
|
+
content: res.content,
|
|
14042
|
+
moved: res.moved,
|
|
14043
|
+
changed: res.changed,
|
|
14044
|
+
frame: { ...res.box },
|
|
14045
|
+
corners: res.corners.map(roundPoint),
|
|
14046
|
+
bounds: res.bounds
|
|
14047
|
+
};
|
|
14048
|
+
}
|
|
14049
|
+
function createImageTransformTools(controller) {
|
|
14050
|
+
const getFrame = {
|
|
14051
|
+
name: "get_transform_frame",
|
|
14052
|
+
title: "Get the Free Transform frame",
|
|
14053
|
+
description: "Returns what a transform would move and its frame: content (layer, selection, selection-copy or selection-outline), moved (pixels, mask, selection), the frame (document bounds of the content), its corners [top-left, top-right, bottom-right, bottom-left] and centre. Pass meshColumns / meshRows to also get the identity warp mesh over the frame to edit for warp_layer. Changes nothing.",
|
|
14054
|
+
inputSchema: {
|
|
14055
|
+
type: "object",
|
|
14056
|
+
properties: {
|
|
14057
|
+
layerId: TARGET2.layerId,
|
|
14058
|
+
content: { type: "string", enum: FREE_TRANSFORM_CONTENTS, description: `${TARGET2.content.description} selection-outline frames the selection outline alone.` },
|
|
14059
|
+
channel: TARGET2.channel,
|
|
14060
|
+
meshColumns: { type: "integer", minimum: 1, maximum: 16, description: "Patch columns of an identity warp mesh to return (omit for none)." },
|
|
14061
|
+
meshRows: { type: "integer", minimum: 1, maximum: 16, description: "Patch rows of an identity warp mesh to return (default meshColumns)." }
|
|
14062
|
+
},
|
|
14063
|
+
additionalProperties: false
|
|
14064
|
+
},
|
|
14065
|
+
annotations: { title: "Get the Free Transform frame", ...READ6 },
|
|
14066
|
+
handler: (args) => {
|
|
14067
|
+
const init = targetFrom(args);
|
|
14068
|
+
if (init.content === "selection-copy") init.content = "selection";
|
|
14069
|
+
const s = controller.beginFreeTransform(init);
|
|
14070
|
+
const out = {
|
|
14071
|
+
layerId: s.layerId,
|
|
14072
|
+
content: args.content === "selection-copy" ? "selection-copy" : s.content,
|
|
14073
|
+
moved: [...s.moves],
|
|
14074
|
+
frame: { ...s.box },
|
|
14075
|
+
corners: identityTransform(s.box).corners.map(roundPoint),
|
|
14076
|
+
center: roundPoint({ x: s.box.x + s.box.width / 2, y: s.box.y + s.box.height / 2 })
|
|
14077
|
+
};
|
|
14078
|
+
s.cancel();
|
|
14079
|
+
if (args.meshColumns !== void 0) {
|
|
14080
|
+
const cols = args.meshColumns;
|
|
14081
|
+
const rows = _nullishCoalesce(args.meshRows, () => ( cols));
|
|
14082
|
+
const mesh = _chunkDWGZUSEScjs.identityWarpMesh.call(void 0, s.box, cols, rows);
|
|
14083
|
+
out.mesh = { columns: cols, rows, pointsPerRow: _chunkDWGZUSEScjs.warpMeshColumns.call(void 0, mesh), pointRows: _chunkDWGZUSEScjs.warpMeshRows.call(void 0, mesh), points: mesh.points.map(roundPoint) };
|
|
14084
|
+
}
|
|
14085
|
+
return out;
|
|
14086
|
+
}
|
|
14087
|
+
};
|
|
14088
|
+
const transformLayer = {
|
|
14089
|
+
name: "transform_layer",
|
|
14090
|
+
title: "Free Transform a layer",
|
|
14091
|
+
description: "Edit \u203A Free Transform: scales, rotates, skews, moves, distorts or puts in perspective a pixel layer (with its linked mask), the selected pixels, a copy of them on a new layer, or an unlinked mask. Give the transform one way: the numeric fields (as Photoshop\u2019s options bar, about a reference point), a matrix, or the frame\u2019s new corners (distort / perspective; read the frame with get_transform_frame). Resamples once, tile by tile; one undo step. Returns layerId (the new layer for selection-copy), what moved, the frame, the corners and the new document bounds.",
|
|
14092
|
+
inputSchema: {
|
|
14093
|
+
type: "object",
|
|
14094
|
+
properties: { ...TARGET2, ...GEOMETRY },
|
|
14095
|
+
additionalProperties: false
|
|
14096
|
+
},
|
|
14097
|
+
annotations: { title: "Free Transform a layer", ...WRITE5 },
|
|
14098
|
+
handler: (args) => summary2(controller.transformLayer({ ...targetFrom(args), ...geometryFrom(args) }))
|
|
14099
|
+
};
|
|
14100
|
+
const warpLayer = {
|
|
14101
|
+
name: "warp_layer",
|
|
14102
|
+
title: "Warp a layer",
|
|
14103
|
+
description: "Edit \u203A Transform \u203A Warp: bends a pixel layer (with its linked mask), the selected pixels, a copy of them, or an unlinked mask through a preset (style with bend and distortions in percent) or a B\xE9zier mesh over the frame (get the frame and an identity mesh to edit from get_transform_frame with meshColumns). Give style or mesh, not both. One undo step. Returns what moved and the new document bounds.",
|
|
14104
|
+
inputSchema: {
|
|
14105
|
+
type: "object",
|
|
14106
|
+
properties: {
|
|
14107
|
+
...TARGET2,
|
|
14108
|
+
style: { type: "string", enum: _chunkDWGZUSEScjs.WARP_STYLES, description: "Preset warp (Photoshop\u2019s menu): arc, arcLower, arcUpper, arch, bulge, shellLower, shellUpper, flag, wave, fish, rise, fisheye, inflate, squeeze, twist." },
|
|
14109
|
+
bend: { type: "number", minimum: -100, maximum: 100, description: "Preset bend in percent, \u2212100..100 (default 50)." },
|
|
14110
|
+
horizontal: { type: "number", minimum: -100, maximum: 100, description: "Preset horizontal distortion in percent, \u2212100..100 (default 0)." },
|
|
14111
|
+
vertical: { type: "number", minimum: -100, maximum: 100, description: "Preset vertical distortion in percent, \u2212100..100 (default 0)." },
|
|
14112
|
+
orientation: { type: "string", enum: ["horizontal", "vertical"], description: "Bend along the horizontal (default) or vertical axis." },
|
|
14113
|
+
mesh: {
|
|
14114
|
+
type: "object",
|
|
14115
|
+
description: "A custom warp: patch columns and rows, and the (3\xB7columns + 1) \xD7 (3\xB7rows + 1) control points row by row in document pixels (anchors where both indices are multiples of 3, B\xE9zier handles between). Start from get_transform_frame\u2019s identity mesh.",
|
|
14116
|
+
properties: {
|
|
14117
|
+
columns: { type: "integer", minimum: 1, maximum: 16, description: "Patch columns." },
|
|
14118
|
+
rows: { type: "integer", minimum: 1, maximum: 16, description: "Patch rows." },
|
|
14119
|
+
points: { type: "array", items: POINT, minItems: 16, description: "Control points, row by row, document pixels." }
|
|
14120
|
+
},
|
|
14121
|
+
required: ["columns", "rows", "points"],
|
|
14122
|
+
additionalProperties: false
|
|
14123
|
+
}
|
|
14124
|
+
},
|
|
14125
|
+
additionalProperties: false
|
|
14126
|
+
},
|
|
14127
|
+
annotations: { title: "Warp a layer", ...WRITE5 },
|
|
14128
|
+
handler: (args) => {
|
|
14129
|
+
const hasPreset = ["style", "bend", "horizontal", "vertical", "orientation"].some((k) => args[k] !== void 0);
|
|
14130
|
+
if (hasPreset && args.mesh !== void 0) throw new LayerOperationError("Give a preset (style, bend, horizontal, vertical, orientation) or a mesh, not both.");
|
|
14131
|
+
if (!hasPreset && args.mesh === void 0) throw new LayerOperationError("Give a preset style or a mesh.");
|
|
14132
|
+
let warp;
|
|
14133
|
+
if (hasPreset) {
|
|
14134
|
+
if (args.style === void 0) throw new LayerOperationError(`style is required with a preset. Styles: ${_chunkDWGZUSEScjs.WARP_STYLES.join(", ")}.`);
|
|
14135
|
+
warp = {
|
|
14136
|
+
style: args.style,
|
|
14137
|
+
bend: _nullishCoalesce(args.bend, () => ( 50)),
|
|
14138
|
+
horizontal: args.horizontal,
|
|
14139
|
+
vertical: args.vertical,
|
|
14140
|
+
orientation: args.orientation
|
|
14141
|
+
};
|
|
14142
|
+
} else {
|
|
14143
|
+
const m = args.mesh;
|
|
14144
|
+
const want = (3 * m.columns + 1) * (3 * m.rows + 1);
|
|
14145
|
+
if (m.points.length !== want) throw new LayerOperationError(`A ${m.columns} \xD7 ${m.rows} mesh needs (3\xB7${m.columns} + 1) \xD7 (3\xB7${m.rows} + 1) = ${want} points, got ${m.points.length}.`);
|
|
14146
|
+
const knots = (n) => Array.from({ length: n + 1 }, (_, i) => i / n);
|
|
14147
|
+
warp = { us: knots(m.columns), vs: knots(m.rows), points: m.points.map((p) => ({ x: p.x, y: p.y })) };
|
|
14148
|
+
}
|
|
14149
|
+
return summary2(controller.transformLayer({ ...targetFrom(args), warp }));
|
|
14150
|
+
}
|
|
14151
|
+
};
|
|
14152
|
+
const transformSelection = {
|
|
14153
|
+
name: "transform_selection",
|
|
14154
|
+
title: "Transform the selection outline",
|
|
14155
|
+
description: "Select \u203A Transform Selection: scales, rotates, skews, moves or distorts only the selection outline; no pixels change. Give the transform one way: the numeric fields (about a reference point of the selection\u2019s bounds), a matrix, or the new corners of its bounds. Needs a selection. One undo step. Returns the new selection bounds.",
|
|
14156
|
+
inputSchema: {
|
|
14157
|
+
type: "object",
|
|
14158
|
+
properties: { interpolation: { ...TARGET2.interpolation, description: "Resampling of soft edges: nearest, bilinear or bicubic (default)." }, ...GEOMETRY },
|
|
14159
|
+
additionalProperties: false
|
|
14160
|
+
},
|
|
14161
|
+
annotations: { title: "Transform the selection outline", ...WRITE5 },
|
|
14162
|
+
handler: (args) => {
|
|
14163
|
+
const res = controller.transformLayer({ content: "selection-outline", interpolation: args.interpolation, ...geometryFrom(args) });
|
|
14164
|
+
return { changed: res.changed, frame: { ...res.box }, corners: res.corners.map(roundPoint), bounds: res.bounds };
|
|
14165
|
+
}
|
|
14166
|
+
};
|
|
14167
|
+
const flipLayer = {
|
|
14168
|
+
name: "flip_layer",
|
|
14169
|
+
title: "Flip a layer",
|
|
14170
|
+
description: "Edit \u203A Transform \u203A Flip Horizontal or Vertical: mirrors a pixel layer (with its linked mask), the selected pixels or a copy of them about the centre of their frame, exactly (no resampling). To flip the whole image use flip_image. One undo step. Returns the new bounds.",
|
|
14171
|
+
inputSchema: {
|
|
14172
|
+
type: "object",
|
|
14173
|
+
properties: {
|
|
14174
|
+
axis: { type: "string", enum: ["horizontal", "vertical"], description: "horizontal mirrors left \u2194 right, vertical top \u2194 bottom." },
|
|
14175
|
+
layerId: TARGET2.layerId,
|
|
14176
|
+
content: TARGET2.content,
|
|
14177
|
+
channel: TARGET2.channel
|
|
14178
|
+
},
|
|
14179
|
+
required: ["axis"],
|
|
14180
|
+
additionalProperties: false
|
|
14181
|
+
},
|
|
14182
|
+
annotations: { title: "Flip a layer", ...WRITE5 },
|
|
14183
|
+
handler: (args) => summary2(controller.flipLayer(args.axis, targetFrom(args)))
|
|
14184
|
+
};
|
|
14185
|
+
const rotate90 = {
|
|
14186
|
+
name: "rotate_layer_90",
|
|
14187
|
+
title: "Rotate a layer by quarter turns",
|
|
14188
|
+
description: "Edit \u203A Transform \u203A Rotate 90\xB0 / 180\xB0: turns a pixel layer (with its linked mask), the selected pixels or a copy of them about the centre of their frame, exactly (pixels land on whole pixels; no resampling). To rotate the whole image use set_rotation. One undo step. Returns the new bounds.",
|
|
14189
|
+
inputSchema: {
|
|
14190
|
+
type: "object",
|
|
14191
|
+
properties: {
|
|
14192
|
+
turn: { type: "integer", enum: [90, -90, 180], description: "Degrees: 90 clockwise, -90 counter-clockwise, or 180." },
|
|
14193
|
+
layerId: TARGET2.layerId,
|
|
14194
|
+
content: TARGET2.content,
|
|
14195
|
+
channel: TARGET2.channel
|
|
14196
|
+
},
|
|
14197
|
+
required: ["turn"],
|
|
14198
|
+
additionalProperties: false
|
|
14199
|
+
},
|
|
14200
|
+
annotations: { title: "Rotate a layer by quarter turns", ...WRITE5 },
|
|
14201
|
+
handler: (args) => summary2(controller.rotateLayer90(args.turn, targetFrom(args)))
|
|
14202
|
+
};
|
|
14203
|
+
return [getFrame, transformLayer, warpLayer, transformSelection, flipLayer, rotate90];
|
|
14204
|
+
}
|
|
14205
|
+
|
|
13241
14206
|
// src/image-editor/tools.ts
|
|
13242
14207
|
var LAYER_PATH = /^layers\.([^.]+)\.(.+)$/;
|
|
13243
14208
|
function adjustmentsSummary(adjustments) {
|
|
@@ -13410,7 +14375,7 @@ function createImageEditorToolProvider(controller, options = {}) {
|
|
|
13410
14375
|
for (const ref of [aboveId, parentId]) {
|
|
13411
14376
|
if (ref !== void 0 && !controller.getLayer(ref)) throw new Error(`Unknown layer "${ref}". Call list_layers for ids.`);
|
|
13412
14377
|
}
|
|
13413
|
-
if (parentId !== void 0 && _optionalChain([controller, 'access',
|
|
14378
|
+
if (parentId !== void 0 && _optionalChain([controller, 'access', _300 => _300.getLayer, 'call', _301 => _301(parentId), 'optionalAccess', _302 => _302.type]) !== "group") throw new Error(`Layer "${parentId}" is not a group.`);
|
|
13414
14379
|
const id = controller.addAdjustmentLayer({ kind, params, opacity, blend, name, aboveId, parentId });
|
|
13415
14380
|
const layer = controller.getAdjustmentLayer(id);
|
|
13416
14381
|
return { layer: JSON.parse(JSON.stringify(layer)), index: controller.getAdjustmentLayers().findIndex((l) => l.id === id) };
|
|
@@ -13475,6 +14440,7 @@ function createImageEditorToolProvider(controller, options = {}) {
|
|
|
13475
14440
|
...createImageSelectionTools(controller),
|
|
13476
14441
|
...createImageEditTools(controller),
|
|
13477
14442
|
...createImageLayerTools(controller),
|
|
14443
|
+
...createImageTransformTools(controller),
|
|
13478
14444
|
...createImageEffectTools(controller),
|
|
13479
14445
|
...createImagePaintTools(controller),
|
|
13480
14446
|
..._chunkZZOTHJ4Kcjs.createPigmentTools.call(void 0, ),
|
|
@@ -13538,19 +14504,19 @@ function removeCurvePoint(points, index) {
|
|
|
13538
14504
|
var round22 = (v) => Math.round(v * 100) / 100;
|
|
13539
14505
|
|
|
13540
14506
|
// src/image-editor/selection/gesture.ts
|
|
13541
|
-
var SelectionGesture = (
|
|
13542
|
-
constructor(controller, getOptions) {;
|
|
14507
|
+
var SelectionGesture = (_class10 = class {
|
|
14508
|
+
constructor(controller, getOptions) {;_class10.prototype.__init60.call(this);_class10.prototype.__init61.call(this);_class10.prototype.__init62.call(this);_class10.prototype.__init63.call(this);_class10.prototype.__init64.call(this);
|
|
13543
14509
|
this.controller = controller;
|
|
13544
14510
|
this.getOptions = getOptions;
|
|
13545
14511
|
}
|
|
13546
14512
|
|
|
13547
14513
|
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
14514
|
+
__init60() {this.start = null}
|
|
14515
|
+
__init61() {this.points = []}
|
|
14516
|
+
__init62() {this.current = null}
|
|
14517
|
+
__init63() {this.modifiers = {}}
|
|
13552
14518
|
/** The last error (e.g. pixels unavailable for the wand), for the UI to show. */
|
|
13553
|
-
|
|
14519
|
+
__init64() {this.error = null}
|
|
13554
14520
|
get active() {
|
|
13555
14521
|
return this.start !== null;
|
|
13556
14522
|
}
|
|
@@ -13638,7 +14604,7 @@ var SelectionGesture = (_class9 = class {
|
|
|
13638
14604
|
this.current = null;
|
|
13639
14605
|
this.points = [];
|
|
13640
14606
|
}
|
|
13641
|
-
},
|
|
14607
|
+
}, _class10);
|
|
13642
14608
|
|
|
13643
14609
|
// src/image-editor/mosaic-filter.ts
|
|
13644
14610
|
function resolveMosaicRegionBounds(region, imgWidth, imgHeight) {
|
|
@@ -13821,7 +14787,7 @@ function dropZone(fraction, isGroup) {
|
|
|
13821
14787
|
}
|
|
13822
14788
|
function dropPlacement(layers, dragId, targetId, zone) {
|
|
13823
14789
|
if (dragId === targetId) return null;
|
|
13824
|
-
const target =
|
|
14790
|
+
const target = _chunkWT6ZAWJPcjs.findLayer.call(void 0, layers, targetId);
|
|
13825
14791
|
if (!target) return null;
|
|
13826
14792
|
if (zone === "inside" && target.layer.type === "group") return { parentId: targetId };
|
|
13827
14793
|
return zone === "above" ? { aboveId: targetId } : { belowId: targetId };
|
|
@@ -13829,35 +14795,36 @@ function dropPlacement(layers, dragId, targetId, zone) {
|
|
|
13829
14795
|
function layerMenu(controller) {
|
|
13830
14796
|
const s = controller.getState();
|
|
13831
14797
|
const active = controller.getActiveLayer();
|
|
13832
|
-
const loc = active ?
|
|
14798
|
+
const loc = active ? _chunkWT6ZAWJPcjs.findLayer.call(void 0, s.layers, active.id) : null;
|
|
13833
14799
|
const siblings = loc ? loc.parent ? loc.parent.children : s.layers : [];
|
|
13834
14800
|
const below = loc ? siblings[loc.index - 1] : void 0;
|
|
13835
14801
|
const hasSel = controller.hasSelection;
|
|
13836
|
-
const isPixel = _optionalChain([active, 'optionalAccess',
|
|
14802
|
+
const isPixel = _optionalChain([active, 'optionalAccess', _303 => _303.type]) === "pixel";
|
|
13837
14803
|
return [
|
|
13838
14804
|
{ action: "new-layer", label: "New Layer", enabled: true },
|
|
13839
14805
|
{ action: "new-group", label: "New Group", enabled: true },
|
|
13840
14806
|
{ action: "duplicate", label: "Duplicate Layer", enabled: Boolean(active) },
|
|
13841
14807
|
{ action: "delete", label: "Delete Layer", enabled: Boolean(active) },
|
|
13842
14808
|
{ action: "group-selected", label: "Group Layer", enabled: Boolean(active) },
|
|
13843
|
-
{ action: "ungroup", label: "Ungroup", enabled: _optionalChain([active, 'optionalAccess',
|
|
13844
|
-
{ action: "merge-down", label: "Merge Down", enabled: Boolean(_optionalChain([active, 'optionalAccess',
|
|
14809
|
+
{ action: "ungroup", label: "Ungroup", enabled: _optionalChain([active, 'optionalAccess', _304 => _304.type]) === "group" },
|
|
14810
|
+
{ action: "merge-down", label: "Merge Down", enabled: Boolean(_optionalChain([active, 'optionalAccess', _305 => _305.visible]) && _optionalChain([below, 'optionalAccess', _306 => _306.type]) === "pixel") },
|
|
13845
14811
|
{ action: "merge-visible", label: "Merge Visible", enabled: s.layers.some((l) => l.visible) },
|
|
13846
14812
|
{ action: "flatten", label: "Flatten Image", enabled: s.layers.length > 0 },
|
|
13847
14813
|
{ action: "via-copy", label: "Layer via Copy", enabled: isPixel && hasSel },
|
|
13848
14814
|
{ action: "via-cut", label: "Layer via Cut", enabled: isPixel && hasSel },
|
|
13849
14815
|
{ action: "add-mask", label: "Add Layer Mask", enabled: Boolean(active) },
|
|
13850
14816
|
{ action: "add-mask-selection", label: "Add Mask from Selection", enabled: Boolean(active) && hasSel },
|
|
13851
|
-
{ action: "apply-mask", label: "Apply Layer Mask", enabled: isPixel && Boolean(_optionalChain([active, 'optionalAccess',
|
|
13852
|
-
{ action: "delete-mask", label: "Delete Layer Mask", enabled: Boolean(_optionalChain([active, 'optionalAccess',
|
|
13853
|
-
{ action: "toggle-mask", label: _optionalChain([active, 'optionalAccess',
|
|
13854
|
-
{ action: "
|
|
13855
|
-
{ action: "
|
|
14817
|
+
{ action: "apply-mask", label: "Apply Layer Mask", enabled: isPixel && Boolean(_optionalChain([active, 'optionalAccess', _307 => _307.mask])) },
|
|
14818
|
+
{ action: "delete-mask", label: "Delete Layer Mask", enabled: Boolean(_optionalChain([active, 'optionalAccess', _308 => _308.mask])) },
|
|
14819
|
+
{ action: "toggle-mask", label: _optionalChain([active, 'optionalAccess', _309 => _309.mask, 'optionalAccess', _310 => _310.enabled]) === false ? "Enable Layer Mask" : "Disable Layer Mask", enabled: Boolean(_optionalChain([active, 'optionalAccess', _311 => _311.mask])) },
|
|
14820
|
+
{ action: "toggle-mask-link", label: _optionalChain([active, 'optionalAccess', _312 => _312.mask, 'optionalAccess', _313 => _313.linked]) === false ? "Link Layer Mask" : "Unlink Layer Mask", enabled: Boolean(_optionalChain([active, 'optionalAccess', _314 => _314.mask]) && !active.mask.source) },
|
|
14821
|
+
{ action: "rasterize", label: "Rasterize Layer", enabled: _optionalChain([active, 'optionalAccess', _315 => _315.type]) === "annotation" || isPixel && Boolean(_optionalChain([active, 'optionalAccess', _316 => _316.type]) === "pixel" && _optionalChain([active, 'access', _317 => _317.filters, 'optionalAccess', _318 => _318.length])) },
|
|
14822
|
+
{ action: "toggle-clip", label: _optionalChain([active, 'optionalAccess', _319 => _319.clipped]) ? "Release Clipping Mask" : "Create Clipping Mask", enabled: Boolean(loc && loc.index > 0) }
|
|
13856
14823
|
];
|
|
13857
14824
|
}
|
|
13858
14825
|
async function runLayerMenuAction(controller, action) {
|
|
13859
14826
|
const active = controller.getActiveLayer();
|
|
13860
|
-
const id = _optionalChain([active, 'optionalAccess',
|
|
14827
|
+
const id = _optionalChain([active, 'optionalAccess', _320 => _320.id]);
|
|
13861
14828
|
try {
|
|
13862
14829
|
switch (action) {
|
|
13863
14830
|
case "new-layer":
|
|
@@ -13904,13 +14871,16 @@ async function runLayerMenuAction(controller, action) {
|
|
|
13904
14871
|
if (id) controller.removeLayerMask(id);
|
|
13905
14872
|
break;
|
|
13906
14873
|
case "toggle-mask":
|
|
13907
|
-
if (id && _optionalChain([active, 'optionalAccess',
|
|
14874
|
+
if (id && _optionalChain([active, 'optionalAccess', _321 => _321.mask])) controller.setLayerMaskProps(id, { enabled: active.mask.enabled === false });
|
|
14875
|
+
break;
|
|
14876
|
+
case "toggle-mask-link":
|
|
14877
|
+
if (id && _optionalChain([active, 'optionalAccess', _322 => _322.mask])) controller.setLayerMaskProps(id, { linked: active.mask.linked === false });
|
|
13908
14878
|
break;
|
|
13909
14879
|
case "rasterize":
|
|
13910
14880
|
if (id) await controller.rasterizeLayer(id);
|
|
13911
14881
|
break;
|
|
13912
14882
|
case "toggle-clip":
|
|
13913
|
-
if (id) controller.setLayerProperties(id, { clipped: !_optionalChain([active, 'optionalAccess',
|
|
14883
|
+
if (id) controller.setLayerProperties(id, { clipped: !_optionalChain([active, 'optionalAccess', _323 => _323.clipped]) });
|
|
13914
14884
|
break;
|
|
13915
14885
|
}
|
|
13916
14886
|
return null;
|
|
@@ -13925,25 +14895,25 @@ function layerEffectsPanel(layer) {
|
|
|
13925
14895
|
if (!layer) return { ...empty, available: false, reason: "Select a layer to add effects." };
|
|
13926
14896
|
if (layer.type === "adjustment") return { ...empty, available: false, reason: "Adjustment layers cannot have effects." };
|
|
13927
14897
|
const fx = layer.effects;
|
|
13928
|
-
const readOnly = Boolean(_optionalChain([layer, 'access',
|
|
14898
|
+
const readOnly = Boolean(_optionalChain([layer, 'access', _324 => _324.locks, 'optionalAccess', _325 => _325.all]));
|
|
13929
14899
|
return {
|
|
13930
14900
|
available: true,
|
|
13931
14901
|
readOnly,
|
|
13932
14902
|
reason: readOnly ? "The layer is locked; unlock it to change its effects." : void 0,
|
|
13933
|
-
enabled: _nullishCoalesce(_optionalChain([fx, 'optionalAccess',
|
|
13934
|
-
scale: _nullishCoalesce(_optionalChain([fx, 'optionalAccess',
|
|
13935
|
-
rows: (_nullishCoalesce(_optionalChain([fx, 'optionalAccess',
|
|
14903
|
+
enabled: _nullishCoalesce(_optionalChain([fx, 'optionalAccess', _326 => _326.enabled]), () => ( true)),
|
|
14904
|
+
scale: _nullishCoalesce(_optionalChain([fx, 'optionalAccess', _327 => _327.scale]), () => ( 1)),
|
|
14905
|
+
rows: (_nullishCoalesce(_optionalChain([fx, 'optionalAccess', _328 => _328.items]), () => ( []))).map((e) => ({ id: e.id, kind: e.kind, label: _chunkWT6ZAWJPcjs.layerEffectLabel.call(void 0, e.kind), enabled: e.enabled }))
|
|
13936
14906
|
};
|
|
13937
14907
|
}
|
|
13938
14908
|
function layerEffectsBadge(layer) {
|
|
13939
|
-
if (!_optionalChain([layer, 'access',
|
|
13940
|
-
return
|
|
14909
|
+
if (!_optionalChain([layer, 'access', _329 => _329.effects, 'optionalAccess', _330 => _330.items, 'access', _331 => _331.length])) return null;
|
|
14910
|
+
return _chunkWT6ZAWJPcjs.hasActiveEffects.call(void 0, layer.effects) ? "on" : "off";
|
|
13941
14911
|
}
|
|
13942
|
-
var LAYER_EFFECT_MENU =
|
|
14912
|
+
var LAYER_EFFECT_MENU = _chunkWT6ZAWJPcjs.LAYER_EFFECT_KINDS.map((kind) => ({ kind, label: _chunkWT6ZAWJPcjs.layerEffectLabel.call(void 0, kind) }));
|
|
13943
14913
|
var BLENDS = _chunkCRMAXIUVcjs.BLEND_MODES.filter((m) => m.id !== "pigment").map((m) => ({ value: m.id, label: m.label }));
|
|
13944
14914
|
var opt = (...pairs) => pairs.map(([value, label]) => ({ value, label }));
|
|
13945
14915
|
function patternOptions(patterns) {
|
|
13946
|
-
return [...patterns.map((p) => ({ value: p.id, label: p.name || p.id })), ...
|
|
14916
|
+
return [...patterns.map((p) => ({ value: p.id, label: p.name || p.id })), ..._chunkWT6ZAWJPcjs.builtinPatternIds.call(void 0, ).map((id) => ({ value: id, label: _chunkWT6ZAWJPcjs.builtinPattern.call(void 0, id).name }))];
|
|
13947
14917
|
}
|
|
13948
14918
|
function getPath(o, path) {
|
|
13949
14919
|
let v = o;
|
|
@@ -13981,8 +14951,8 @@ function fillControls(f, allowPattern, patterns) {
|
|
|
13981
14951
|
}
|
|
13982
14952
|
function gradientControls(prefix, g) {
|
|
13983
14953
|
return [
|
|
13984
|
-
{ key: `${prefix}.stops.0.color`, label: "Start colour", type: "color", value: _nullishCoalesce(_optionalChain([g, 'access',
|
|
13985
|
-
{ key: `${prefix}.stops.last.color`, label: "End colour", type: "color", value: _nullishCoalesce(_optionalChain([g, 'access',
|
|
14954
|
+
{ key: `${prefix}.stops.0.color`, label: "Start colour", type: "color", value: _nullishCoalesce(_optionalChain([g, 'access', _332 => _332.stops, 'access', _333 => _333[0], 'optionalAccess', _334 => _334.color]), () => ( "#000000")) },
|
|
14955
|
+
{ key: `${prefix}.stops.last.color`, label: "End colour", type: "color", value: _nullishCoalesce(_optionalChain([g, 'access', _335 => _335.stops, 'access', _336 => _336[g.stops.length - 1], 'optionalAccess', _337 => _337.color]), () => ( "#ffffff")) },
|
|
13986
14956
|
{ key: `${prefix}.style`, label: "Style", type: "select", value: g.style, options: opt(["linear", "Linear"], ["radial", "Radial"], ["angle", "Angle"], ["reflected", "Reflected"], ["diamond", "Diamond"]) },
|
|
13987
14957
|
{ key: `${prefix}.angle`, label: "Angle", type: "range", min: -180, max: 180, step: 1, value: g.angle, unit: "\xB0" },
|
|
13988
14958
|
{ key: `${prefix}.scale`, label: "Scale", type: "range", min: 0.1, max: 1.5, step: 0.01, value: g.scale, percent: true, unit: "%" },
|
|
@@ -14073,20 +15043,20 @@ function layerEffectControls(e, patterns = []) {
|
|
|
14073
15043
|
}
|
|
14074
15044
|
}
|
|
14075
15045
|
function fillOfType(current, type, patterns) {
|
|
14076
|
-
if (type === "gradient") return { type: "gradient", gradient:
|
|
14077
|
-
if (type === "pattern") return { type: "pattern", patternId: _nullishCoalesce(_optionalChain([patterns, 'access',
|
|
15046
|
+
if (type === "gradient") return { type: "gradient", gradient: _chunkWT6ZAWJPcjs.defaultEffectGradient.call(void 0, ) };
|
|
15047
|
+
if (type === "pattern") return { type: "pattern", patternId: _nullishCoalesce(_optionalChain([patterns, 'access', _338 => _338[0], 'optionalAccess', _339 => _339.id]), () => ( "checker")), scale: 1 };
|
|
14078
15048
|
return { type: "color", color: current.type === "color" ? current.color : "#000000" };
|
|
14079
15049
|
}
|
|
14080
15050
|
function effectControlChange(effect, key, value, patterns = []) {
|
|
14081
15051
|
const [top, ...rest] = key.split(".");
|
|
14082
15052
|
if (top === "fill" && rest[0] === "type") return { fill: fillOfType(effect.fill, String(value), patterns) };
|
|
14083
15053
|
if (top === "patternId" && !rest.length) {
|
|
14084
|
-
const name = _optionalChain([patternOptions, 'call',
|
|
15054
|
+
const name = _optionalChain([patternOptions, 'call', _340 => _340(patterns), 'access', _341 => _341.find, 'call', _342 => _342((o) => o.value === value), 'optionalAccess', _343 => _343.label]);
|
|
14085
15055
|
return name ? { patternId: value, name } : { patternId: value };
|
|
14086
15056
|
}
|
|
14087
15057
|
if (!rest.length) return { [top]: value };
|
|
14088
15058
|
if (top === "fill" && rest[0] === "patternId") {
|
|
14089
|
-
const name = _optionalChain([patternOptions, 'call',
|
|
15059
|
+
const name = _optionalChain([patternOptions, 'call', _344 => _344(patterns), 'access', _345 => _345.find, 'call', _346 => _346((o) => o.value === value), 'optionalAccess', _347 => _347.label]);
|
|
14090
15060
|
return { fill: { ...effect.fill, patternId: value, ...name ? { name } : {} } };
|
|
14091
15061
|
}
|
|
14092
15062
|
return { [top]: setPath(getPath(effect, top), rest, value) };
|
|
@@ -14125,6 +15095,501 @@ async function downloadPsd(controller, name = "image") {
|
|
|
14125
15095
|
return { fileName, warnings: res.warnings };
|
|
14126
15096
|
}
|
|
14127
15097
|
|
|
15098
|
+
// src/image-editor/layers/transform-ui.ts
|
|
15099
|
+
var CORNERS = ["nw", "ne", "se", "sw"];
|
|
15100
|
+
var SIDES = ["n", "e", "s", "w"];
|
|
15101
|
+
var CORNER_INDEX = { nw: 0, ne: 1, se: 2, sw: 3 };
|
|
15102
|
+
var SIDE_CORNERS = { n: [0, 1], e: [1, 2], s: [2, 3], w: [3, 0] };
|
|
15103
|
+
var HANDLE_FRACTION = { nw: [0, 0], n: [0.5, 0], ne: [1, 0], e: [1, 0.5], se: [1, 1], s: [0.5, 1], sw: [0, 1], w: [0, 0.5] };
|
|
15104
|
+
var ANCHOR_FRACTION2 = {
|
|
15105
|
+
"top-left": [0, 0],
|
|
15106
|
+
top: [0.5, 0],
|
|
15107
|
+
"top-right": [1, 0],
|
|
15108
|
+
left: [0, 0.5],
|
|
15109
|
+
center: [0.5, 0.5],
|
|
15110
|
+
right: [1, 0.5],
|
|
15111
|
+
"bottom-left": [0, 1],
|
|
15112
|
+
bottom: [0.5, 1],
|
|
15113
|
+
"bottom-right": [1, 1]
|
|
15114
|
+
};
|
|
15115
|
+
var FREE_TRANSFORM_MODE_OPTIONS = [
|
|
15116
|
+
{ id: "scale", label: "Free", title: "Free Transform: corners scale, outside rotates, Ctrl/Cmd distorts" },
|
|
15117
|
+
{ id: "rotate", label: "Rotate", title: "Every handle rotates about the reference point" },
|
|
15118
|
+
{ id: "skew", label: "Skew", title: "Sides slide along themselves" },
|
|
15119
|
+
{ id: "distort", label: "Distort", title: "Each corner moves freely" },
|
|
15120
|
+
{ id: "perspective", label: "Perspective", title: "A corner and its partner move symmetrically" }
|
|
15121
|
+
];
|
|
15122
|
+
var FREE_TRANSFORM_FIELDS = [
|
|
15123
|
+
{ id: "x", label: "X", unit: "px", title: "Reference point X (document pixels)" },
|
|
15124
|
+
{ id: "y", label: "Y", unit: "px", title: "Reference point Y (document pixels)" },
|
|
15125
|
+
{ id: "scaleX", label: "W", unit: "%", title: "Width in percent of the original" },
|
|
15126
|
+
{ id: "scaleY", label: "H", unit: "%", title: "Height in percent of the original" },
|
|
15127
|
+
{ id: "rotate", label: "\u2220", unit: "\xB0", title: "Rotation in degrees, clockwise" },
|
|
15128
|
+
{ id: "skewX", label: "H skew", unit: "\xB0", title: "Horizontal skew in degrees" },
|
|
15129
|
+
{ id: "skewY", label: "V skew", unit: "\xB0", title: "Vertical skew in degrees" }
|
|
15130
|
+
];
|
|
15131
|
+
var CURSOR = {
|
|
15132
|
+
nw: "nwse-resize",
|
|
15133
|
+
se: "nwse-resize",
|
|
15134
|
+
ne: "nesw-resize",
|
|
15135
|
+
sw: "nesw-resize",
|
|
15136
|
+
n: "ns-resize",
|
|
15137
|
+
s: "ns-resize",
|
|
15138
|
+
e: "ew-resize",
|
|
15139
|
+
w: "ew-resize",
|
|
15140
|
+
reference: "move",
|
|
15141
|
+
inside: "move",
|
|
15142
|
+
outside: "alias"
|
|
15143
|
+
};
|
|
15144
|
+
var mod = (m) => Boolean(m.ctrlKey || m.metaKey);
|
|
15145
|
+
var add = (a, b) => ({ x: a.x + b.x, y: a.y + b.y });
|
|
15146
|
+
var sub = (a, b) => ({ x: a.x - b.x, y: a.y - b.y });
|
|
15147
|
+
function rotateAbout(p, c, rad) {
|
|
15148
|
+
const cos = Math.cos(rad);
|
|
15149
|
+
const sin = Math.sin(rad);
|
|
15150
|
+
const d = sub(p, c);
|
|
15151
|
+
return { x: c.x + d.x * cos - d.y * sin, y: c.y + d.x * sin + d.y * cos };
|
|
15152
|
+
}
|
|
15153
|
+
function insideQuad(q2, p) {
|
|
15154
|
+
let sign = 0;
|
|
15155
|
+
for (let i = 0; i < 4; i++) {
|
|
15156
|
+
const a = q2[i];
|
|
15157
|
+
const b = q2[(i + 1) % 4];
|
|
15158
|
+
const c = (b.x - a.x) * (p.y - a.y) - (b.y - a.y) * (p.x - a.x);
|
|
15159
|
+
if (Math.abs(c) < 1e-12) continue;
|
|
15160
|
+
const s = Math.sign(c);
|
|
15161
|
+
if (sign && s !== sign) return false;
|
|
15162
|
+
sign = s;
|
|
15163
|
+
}
|
|
15164
|
+
return true;
|
|
15165
|
+
}
|
|
15166
|
+
var FreeTransformTool = (_class11 = class {
|
|
15167
|
+
constructor(controller, options = {}) {;_class11.prototype.__init65.call(this);_class11.prototype.__init66.call(this);_class11.prototype.__init67.call(this);_class11.prototype.__init68.call(this);_class11.prototype.__init69.call(this);_class11.prototype.__init70.call(this);_class11.prototype.__init71.call(this);_class11.prototype.__init72.call(this);_class11.prototype.__init73.call(this);_class11.prototype.__init74.call(this);_class11.prototype.__init75.call(this);_class11.prototype.__init76.call(this);
|
|
15168
|
+
this.controller = controller;
|
|
15169
|
+
this.options = options;
|
|
15170
|
+
}
|
|
15171
|
+
|
|
15172
|
+
|
|
15173
|
+
__init65() {this.sessionRef = null}
|
|
15174
|
+
__init66() {this.modeValue = "scale"}
|
|
15175
|
+
/** The reference point in the untransformed frame's space (follows the transform). */
|
|
15176
|
+
__init67() {this.refBox = { x: 0, y: 0 }}
|
|
15177
|
+
__init68() {this.corners = null}
|
|
15178
|
+
__init69() {this.drag = null}
|
|
15179
|
+
__init70() {this.pending = false}
|
|
15180
|
+
__init71() {this.viewScale = 1}
|
|
15181
|
+
|
|
15182
|
+
/** Values typed into the options bar since the last drag (V skew is not recovered from the shape). */
|
|
15183
|
+
__init72() {this.typed = {}}
|
|
15184
|
+
/** Width and height scale together when typed (the chain icon). */
|
|
15185
|
+
__init73() {this.proportional = true}
|
|
15186
|
+
__init74() {this.error = null}
|
|
15187
|
+
__init75() {this.lastResult = null}
|
|
15188
|
+
get active() {
|
|
15189
|
+
return Boolean(_optionalChain([this, 'access', _348 => _348.sessionRef, 'optionalAccess', _349 => _349.isOpen]));
|
|
15190
|
+
}
|
|
15191
|
+
get session() {
|
|
15192
|
+
return this.active ? this.sessionRef : null;
|
|
15193
|
+
}
|
|
15194
|
+
get mode() {
|
|
15195
|
+
return this.modeValue;
|
|
15196
|
+
}
|
|
15197
|
+
get interpolation() {
|
|
15198
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _350 => _350.sessionRef, 'optionalAccess', _351 => _351.interpolation]), () => ( "bicubic"));
|
|
15199
|
+
}
|
|
15200
|
+
__init76() {this.listeners = /* @__PURE__ */ new Set()}
|
|
15201
|
+
/** Calls `listener` whenever the overlay, readout, mode or error changes. Returns the unsubscribe. */
|
|
15202
|
+
subscribe(listener) {
|
|
15203
|
+
this.listeners.add(listener);
|
|
15204
|
+
return () => {
|
|
15205
|
+
this.listeners.delete(listener);
|
|
15206
|
+
};
|
|
15207
|
+
}
|
|
15208
|
+
changed() {
|
|
15209
|
+
_optionalChain([this, 'access', _352 => _352.options, 'access', _353 => _353.onChange, 'optionalCall', _354 => _354()]);
|
|
15210
|
+
for (const l of this.listeners) l();
|
|
15211
|
+
}
|
|
15212
|
+
/** Opens a Free Transform (default: the selected pixels of the active layer, or the whole layer). Returns an error message or `null`. */
|
|
15213
|
+
begin(init = {}) {
|
|
15214
|
+
if (this.active) return null;
|
|
15215
|
+
try {
|
|
15216
|
+
if (!init.layerId && init.content !== "selection-outline" && !this.controller.getState().activeLayerId) {
|
|
15217
|
+
const top = [..._chunkWT6ZAWJPcjs.flattenLayers.call(void 0, this.controller.getState().layers)].reverse().find((l) => l.type === "pixel" && l.visible);
|
|
15218
|
+
if (top) this.controller.setActiveLayer(top.id);
|
|
15219
|
+
}
|
|
15220
|
+
const s = this.controller.beginFreeTransform(init);
|
|
15221
|
+
this.sessionRef = s;
|
|
15222
|
+
this.corners = s.geometry.corners;
|
|
15223
|
+
this.refBox = { x: s.box.x + s.box.width / 2, y: s.box.y + s.box.height / 2 };
|
|
15224
|
+
this.modeValue = "scale";
|
|
15225
|
+
this.typed = {};
|
|
15226
|
+
this.error = null;
|
|
15227
|
+
} catch (e) {
|
|
15228
|
+
this.error = e instanceof Error ? e.message : String(e);
|
|
15229
|
+
}
|
|
15230
|
+
this.changed();
|
|
15231
|
+
return this.error;
|
|
15232
|
+
}
|
|
15233
|
+
setMode(mode) {
|
|
15234
|
+
this.modeValue = mode;
|
|
15235
|
+
this.changed();
|
|
15236
|
+
}
|
|
15237
|
+
/** Sets the reference point to an anchor of the frame (the options bar's locator). */
|
|
15238
|
+
setReference(anchor) {
|
|
15239
|
+
const s = this.session;
|
|
15240
|
+
if (!s) return;
|
|
15241
|
+
const [fx, fy] = ANCHOR_FRACTION2[anchor];
|
|
15242
|
+
this.refBox = { x: s.box.x + fx * s.box.width, y: s.box.y + fy * s.box.height };
|
|
15243
|
+
this.changed();
|
|
15244
|
+
}
|
|
15245
|
+
setInterpolation(interpolation) {
|
|
15246
|
+
const s = this.session;
|
|
15247
|
+
if (!s) return;
|
|
15248
|
+
this.run(() => s.update({ interpolation }, false));
|
|
15249
|
+
}
|
|
15250
|
+
/** Screen pixels per document pixel and the visible document area, for previews. */
|
|
15251
|
+
setView(scale, clip) {
|
|
15252
|
+
this.viewScale = scale > 0 ? scale : 1;
|
|
15253
|
+
this.viewClip = clip;
|
|
15254
|
+
}
|
|
15255
|
+
homography() {
|
|
15256
|
+
const s = this.session;
|
|
15257
|
+
return s && this.corners ? _chunkMUUXNRU4cjs.rectToQuad.call(void 0, s.box, this.corners) : null;
|
|
15258
|
+
}
|
|
15259
|
+
/** The reference point in document pixels. */
|
|
15260
|
+
referencePoint() {
|
|
15261
|
+
const h = this.homography();
|
|
15262
|
+
return h ? _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, this.refBox) : null;
|
|
15263
|
+
}
|
|
15264
|
+
/** The outline, handles and reference point to draw, or `null` when no transform is open. */
|
|
15265
|
+
overlay() {
|
|
15266
|
+
const s = this.session;
|
|
15267
|
+
const h = this.homography();
|
|
15268
|
+
if (!s || !h || !this.corners) return null;
|
|
15269
|
+
const handles = [...CORNERS, ...SIDES].map((id) => {
|
|
15270
|
+
const [fx, fy] = HANDLE_FRACTION[id];
|
|
15271
|
+
const p = _nullishCoalesce(_chunkMUUXNRU4cjs.applyHomography.call(void 0, h, { x: s.box.x + fx * s.box.width, y: s.box.y + fy * s.box.height }), () => ( { x: 0, y: 0 }));
|
|
15272
|
+
return { id, x: p.x, y: p.y };
|
|
15273
|
+
});
|
|
15274
|
+
return { outline: this.corners.map((p) => ({ x: p.x, y: p.y })), handles, reference: _nullishCoalesce(this.referencePoint(), () => ( { x: 0, y: 0 })) };
|
|
15275
|
+
}
|
|
15276
|
+
/** What a document point is over (`tolerance` in document pixels: a few screen pixels / scale). */
|
|
15277
|
+
hit(p, tolerance) {
|
|
15278
|
+
const o = this.overlay();
|
|
15279
|
+
if (!o) return null;
|
|
15280
|
+
let best = null;
|
|
15281
|
+
let bestD = tolerance;
|
|
15282
|
+
for (const h of o.handles) {
|
|
15283
|
+
const d = Math.hypot(h.x - p.x, h.y - p.y);
|
|
15284
|
+
if (d <= bestD) {
|
|
15285
|
+
best = h.id;
|
|
15286
|
+
bestD = d;
|
|
15287
|
+
}
|
|
15288
|
+
}
|
|
15289
|
+
if (Math.hypot(o.reference.x - p.x, o.reference.y - p.y) < bestD) best = "reference";
|
|
15290
|
+
if (best) return best;
|
|
15291
|
+
return insideQuad(o.outline, p) ? "inside" : "outside";
|
|
15292
|
+
}
|
|
15293
|
+
/** The CSS cursor for a handle. */
|
|
15294
|
+
cursor(handle) {
|
|
15295
|
+
if (!handle) return "default";
|
|
15296
|
+
if (this.modeValue === "rotate" && handle !== "inside" && handle !== "reference") return CURSOR.outside;
|
|
15297
|
+
return CURSOR[handle];
|
|
15298
|
+
}
|
|
15299
|
+
/** Starts a drag on what `p` is over. */
|
|
15300
|
+
down(p, tolerance) {
|
|
15301
|
+
if (!this.session || !this.corners) return null;
|
|
15302
|
+
const handle = this.hit(p, tolerance);
|
|
15303
|
+
if (!handle) return null;
|
|
15304
|
+
this.drag = { handle, start: { x: p.x, y: p.y }, corners: this.corners, refBox: { ...this.refBox }, ref: _nullishCoalesce(this.referencePoint(), () => ( p)) };
|
|
15305
|
+
return handle;
|
|
15306
|
+
}
|
|
15307
|
+
/** Continues the drag to `p` with the modifiers held now. */
|
|
15308
|
+
move(p, m = {}) {
|
|
15309
|
+
const d = this.drag;
|
|
15310
|
+
const s = this.session;
|
|
15311
|
+
if (!d || !s) return;
|
|
15312
|
+
if (d.handle === "reference") {
|
|
15313
|
+
const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, s.box, d.corners);
|
|
15314
|
+
const inv = h && _chunkMUUXNRU4cjs.invertHomography.call(void 0, h);
|
|
15315
|
+
const q2 = inv && _chunkMUUXNRU4cjs.applyHomography.call(void 0, inv, p);
|
|
15316
|
+
if (q2) this.refBox = q2;
|
|
15317
|
+
this.changed();
|
|
15318
|
+
return;
|
|
15319
|
+
}
|
|
15320
|
+
const corners = this.dragCorners(d, p, m);
|
|
15321
|
+
if (corners) this.setCorners(corners);
|
|
15322
|
+
}
|
|
15323
|
+
/** Ends the drag (the transform stays open). */
|
|
15324
|
+
up() {
|
|
15325
|
+
this.drag = null;
|
|
15326
|
+
}
|
|
15327
|
+
dragCorners(d, p, m) {
|
|
15328
|
+
const s = this.session;
|
|
15329
|
+
const c0 = d.corners;
|
|
15330
|
+
let delta = sub(p, d.start);
|
|
15331
|
+
const map = (f) => c0.map(f);
|
|
15332
|
+
const handle = d.handle;
|
|
15333
|
+
const isCorner = handle in CORNER_INDEX;
|
|
15334
|
+
const isSide = handle in SIDE_CORNERS;
|
|
15335
|
+
const rotating = handle === "outside" || this.modeValue === "rotate" && (isCorner || isSide);
|
|
15336
|
+
if (handle === "inside") {
|
|
15337
|
+
if (m.shiftKey) delta = Math.abs(delta.x) >= Math.abs(delta.y) ? { x: delta.x, y: 0 } : { x: 0, y: delta.y };
|
|
15338
|
+
return map((q3) => add(q3, delta));
|
|
15339
|
+
}
|
|
15340
|
+
if (rotating) {
|
|
15341
|
+
const r = d.ref;
|
|
15342
|
+
let a = Math.atan2(p.y - r.y, p.x - r.x) - Math.atan2(d.start.y - r.y, d.start.x - r.x);
|
|
15343
|
+
if (m.shiftKey) a = Math.round(a / (Math.PI / 12)) * (Math.PI / 12);
|
|
15344
|
+
return map((q3) => rotateAbout(q3, r, a));
|
|
15345
|
+
}
|
|
15346
|
+
const perspective = this.modeValue === "perspective" || mod(m) && m.altKey && m.shiftKey;
|
|
15347
|
+
const distort = this.modeValue === "distort" || mod(m) && !perspective;
|
|
15348
|
+
const skew = this.modeValue === "skew" || mod(m) && isSide;
|
|
15349
|
+
if (isSide && (skew || perspective)) {
|
|
15350
|
+
const [i, j] = SIDE_CORNERS[handle];
|
|
15351
|
+
const dir = sub(c0[j], c0[i]);
|
|
15352
|
+
const len = Math.hypot(dir.x, dir.y) || 1;
|
|
15353
|
+
const t = (delta.x * dir.x + delta.y * dir.y) / len;
|
|
15354
|
+
const v = { x: dir.x / len * t, y: dir.y / len * t };
|
|
15355
|
+
const [oi, oj] = SIDE_CORNERS[{ n: "s", s: "n", e: "w", w: "e" }[handle]];
|
|
15356
|
+
return map((q3, k) => k === i || k === j ? add(q3, v) : m.altKey && (k === oi || k === oj) ? sub(q3, v) : q3);
|
|
15357
|
+
}
|
|
15358
|
+
if (isCorner && perspective) {
|
|
15359
|
+
const k = CORNER_INDEX[handle];
|
|
15360
|
+
if (Math.abs(delta.x) >= Math.abs(delta.y)) {
|
|
15361
|
+
const partner2 = [1, 0, 3, 2][k];
|
|
15362
|
+
return map((q3, i) => i === k ? { x: q3.x + delta.x, y: q3.y } : i === partner2 ? { x: q3.x - delta.x, y: q3.y } : q3);
|
|
15363
|
+
}
|
|
15364
|
+
const partner = [3, 2, 1, 0][k];
|
|
15365
|
+
return map((q3, i) => i === k ? { x: q3.x, y: q3.y + delta.y } : i === partner ? { x: q3.x, y: q3.y - delta.y } : q3);
|
|
15366
|
+
}
|
|
15367
|
+
if (distort || isCorner && this.modeValue === "skew") {
|
|
15368
|
+
if (isCorner) return map((q3, i2) => i2 === CORNER_INDEX[handle] ? add(q3, delta) : q3);
|
|
15369
|
+
const [i, j] = SIDE_CORNERS[handle];
|
|
15370
|
+
return map((q3, k) => k === i || k === j ? add(q3, delta) : q3);
|
|
15371
|
+
}
|
|
15372
|
+
const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, s.box, c0);
|
|
15373
|
+
const inv = h && _chunkMUUXNRU4cjs.invertHomography.call(void 0, h);
|
|
15374
|
+
if (!h || !inv) return null;
|
|
15375
|
+
const q2 = _chunkMUUXNRU4cjs.applyHomography.call(void 0, inv, p);
|
|
15376
|
+
const q0 = _chunkMUUXNRU4cjs.applyHomography.call(void 0, inv, d.start);
|
|
15377
|
+
if (!q2 || !q0) return null;
|
|
15378
|
+
const b = s.box;
|
|
15379
|
+
const [fx, fy] = HANDLE_FRACTION[handle];
|
|
15380
|
+
const grab = { x: b.x + fx * b.width, y: b.y + fy * b.height };
|
|
15381
|
+
const anchor = m.altKey ? d.refBox : { x: b.x + (1 - fx) * b.width, y: b.y + (1 - fy) * b.height };
|
|
15382
|
+
const target = add(grab, sub(q2, q0));
|
|
15383
|
+
const ax = grab.x - anchor.x;
|
|
15384
|
+
const ay = grab.y - anchor.y;
|
|
15385
|
+
let sx = isCorner || handle === "e" || handle === "w" ? Math.abs(ax) > 1e-9 ? (target.x - anchor.x) / ax : 1 : 1;
|
|
15386
|
+
let sy = isCorner || handle === "n" || handle === "s" ? Math.abs(ay) > 1e-9 ? (target.y - anchor.y) / ay : 1 : 1;
|
|
15387
|
+
if (isCorner && !m.shiftKey) {
|
|
15388
|
+
const k = Math.abs(sx) >= Math.abs(sy) ? sx : sy;
|
|
15389
|
+
sx = k;
|
|
15390
|
+
sy = k;
|
|
15391
|
+
}
|
|
15392
|
+
const scaled = [
|
|
15393
|
+
{ x: b.x, y: b.y },
|
|
15394
|
+
{ x: b.x + b.width, y: b.y },
|
|
15395
|
+
{ x: b.x + b.width, y: b.y + b.height },
|
|
15396
|
+
{ x: b.x, y: b.y + b.height }
|
|
15397
|
+
].map((c) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, { x: anchor.x + (c.x - anchor.x) * sx, y: anchor.y + (c.y - anchor.y) * sy }));
|
|
15398
|
+
return scaled.every(Boolean) ? scaled : null;
|
|
15399
|
+
}
|
|
15400
|
+
/** Sets new corners and refreshes the preview (scheduled). Invalid shapes keep the last good one. */
|
|
15401
|
+
setCorners(corners) {
|
|
15402
|
+
const s = this.session;
|
|
15403
|
+
if (!s) return;
|
|
15404
|
+
const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, s.box, corners);
|
|
15405
|
+
if (!h) return;
|
|
15406
|
+
this.corners = corners;
|
|
15407
|
+
this.typed = {};
|
|
15408
|
+
this.changed();
|
|
15409
|
+
this.preview();
|
|
15410
|
+
}
|
|
15411
|
+
preview() {
|
|
15412
|
+
if (this.pending) return;
|
|
15413
|
+
this.pending = true;
|
|
15414
|
+
const run = () => {
|
|
15415
|
+
this.pending = false;
|
|
15416
|
+
const s = this.session;
|
|
15417
|
+
if (!s || !this.corners) return;
|
|
15418
|
+
this.run(() => s.update({ corners: this.corners }, { scale: this.viewScale, clip: this.viewClip }));
|
|
15419
|
+
};
|
|
15420
|
+
if (this.options.schedule) this.options.schedule(run);
|
|
15421
|
+
else run();
|
|
15422
|
+
}
|
|
15423
|
+
run(fn) {
|
|
15424
|
+
try {
|
|
15425
|
+
fn();
|
|
15426
|
+
this.error = null;
|
|
15427
|
+
} catch (e) {
|
|
15428
|
+
this.error = e instanceof Error ? e.message : String(e);
|
|
15429
|
+
if (this.sessionRef && !this.sessionRef.isOpen) this.sessionRef = null;
|
|
15430
|
+
}
|
|
15431
|
+
this.changed();
|
|
15432
|
+
}
|
|
15433
|
+
/** The options bar's numbers for the current shape. */
|
|
15434
|
+
bar() {
|
|
15435
|
+
const s = this.session;
|
|
15436
|
+
if (!s || !this.corners) return null;
|
|
15437
|
+
const read = describeTransform({ box: s.box, corners: this.corners }, this.refBox);
|
|
15438
|
+
return {
|
|
15439
|
+
affine: read.affine,
|
|
15440
|
+
x: _nullishCoalesce(this.typed.x, () => ( read.x)),
|
|
15441
|
+
y: _nullishCoalesce(this.typed.y, () => ( read.y)),
|
|
15442
|
+
scaleX: _nullishCoalesce(this.typed.scaleX, () => ( read.scaleX)),
|
|
15443
|
+
scaleY: _nullishCoalesce(this.typed.scaleY, () => ( read.scaleY)),
|
|
15444
|
+
rotate: _nullishCoalesce(this.typed.rotate, () => ( read.rotate)),
|
|
15445
|
+
skewX: _nullishCoalesce(this.typed.skewX, () => ( read.skewX)),
|
|
15446
|
+
skewY: _nullishCoalesce(this.typed.skewY, () => ( 0))
|
|
15447
|
+
};
|
|
15448
|
+
}
|
|
15449
|
+
/** Applies a typed options-bar value (W and H together while `proportional`). */
|
|
15450
|
+
setField(field, value) {
|
|
15451
|
+
const s = this.session;
|
|
15452
|
+
const cur = this.bar();
|
|
15453
|
+
if (!s || !cur || !Number.isFinite(value)) return;
|
|
15454
|
+
const next = { ...cur, [field]: value };
|
|
15455
|
+
if (this.proportional && field === "scaleX") next.scaleY = cur.scaleY === 0 ? value : value / cur.scaleX * cur.scaleY;
|
|
15456
|
+
if (this.proportional && field === "scaleY") next.scaleX = cur.scaleX === 0 ? value : value / cur.scaleY * cur.scaleX;
|
|
15457
|
+
if (!next.scaleX || !next.scaleY) {
|
|
15458
|
+
this.error = "Width and height must not be 0 %.";
|
|
15459
|
+
this.changed();
|
|
15460
|
+
return;
|
|
15461
|
+
}
|
|
15462
|
+
const m = matrixFromParams(s.box, {
|
|
15463
|
+
scaleX: next.scaleX,
|
|
15464
|
+
scaleY: next.scaleY,
|
|
15465
|
+
rotate: next.rotate,
|
|
15466
|
+
skewX: next.skewX,
|
|
15467
|
+
skewY: next.skewY,
|
|
15468
|
+
reference: this.refBox,
|
|
15469
|
+
dx: next.x - this.refBox.x,
|
|
15470
|
+
dy: next.y - this.refBox.y
|
|
15471
|
+
});
|
|
15472
|
+
this.setCorners(cornersFromMatrix(s.box, m));
|
|
15473
|
+
this.typed = { scaleX: next.scaleX, scaleY: next.scaleY, rotate: next.rotate, skewX: next.skewX, skewY: next.skewY, x: next.x, y: next.y };
|
|
15474
|
+
this.changed();
|
|
15475
|
+
}
|
|
15476
|
+
/** Finishes with full-quality resampling (one undo step). */
|
|
15477
|
+
commit() {
|
|
15478
|
+
const s = this.session;
|
|
15479
|
+
if (!s) return null;
|
|
15480
|
+
let res = null;
|
|
15481
|
+
this.pending = false;
|
|
15482
|
+
this.run(() => {
|
|
15483
|
+
if (this.corners) s.update({ corners: this.corners }, false);
|
|
15484
|
+
res = s.commit();
|
|
15485
|
+
});
|
|
15486
|
+
this.lastResult = res;
|
|
15487
|
+
this.sessionRef = null;
|
|
15488
|
+
this.corners = null;
|
|
15489
|
+
this.drag = null;
|
|
15490
|
+
this.changed();
|
|
15491
|
+
return res;
|
|
15492
|
+
}
|
|
15493
|
+
/** Abandons the transform and restores everything. */
|
|
15494
|
+
cancel() {
|
|
15495
|
+
_optionalChain([this, 'access', _355 => _355.sessionRef, 'optionalAccess', _356 => _356.cancel, 'call', _357 => _357()]);
|
|
15496
|
+
this.sessionRef = null;
|
|
15497
|
+
this.corners = null;
|
|
15498
|
+
this.drag = null;
|
|
15499
|
+
this.pending = false;
|
|
15500
|
+
this.error = null;
|
|
15501
|
+
this.changed();
|
|
15502
|
+
}
|
|
15503
|
+
/**
|
|
15504
|
+
* Keyboard: Enter commits, Escape cancels, arrows nudge by 1 px (Shift: 10). Ctrl/Cmd+T opens a
|
|
15505
|
+
* Free Transform when none is open. Returns true when the key was used (prevent its default).
|
|
15506
|
+
*/
|
|
15507
|
+
key(e) {
|
|
15508
|
+
const t = e.target;
|
|
15509
|
+
const typing = Boolean(t && (t.isContentEditable || t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.tagName === "SELECT"));
|
|
15510
|
+
if (!this.active) {
|
|
15511
|
+
if ((e.ctrlKey || e.metaKey) && !e.altKey && e.key.toLowerCase() === "t" && !typing) {
|
|
15512
|
+
this.begin();
|
|
15513
|
+
return true;
|
|
15514
|
+
}
|
|
15515
|
+
return false;
|
|
15516
|
+
}
|
|
15517
|
+
if (e.key === "Enter") {
|
|
15518
|
+
this.commit();
|
|
15519
|
+
return true;
|
|
15520
|
+
}
|
|
15521
|
+
if (e.key === "Escape") {
|
|
15522
|
+
this.cancel();
|
|
15523
|
+
return true;
|
|
15524
|
+
}
|
|
15525
|
+
if (typing) return false;
|
|
15526
|
+
const step = e.shiftKey ? 10 : 1;
|
|
15527
|
+
const nudge = { ArrowLeft: { x: -step, y: 0 }, ArrowRight: { x: step, y: 0 }, ArrowUp: { x: 0, y: -step }, ArrowDown: { x: 0, y: step } };
|
|
15528
|
+
const v = nudge[e.key];
|
|
15529
|
+
if (v && this.corners) {
|
|
15530
|
+
this.setCorners(this.corners.map((q2) => add(q2, v)));
|
|
15531
|
+
return true;
|
|
15532
|
+
}
|
|
15533
|
+
return false;
|
|
15534
|
+
}
|
|
15535
|
+
}, _class11);
|
|
15536
|
+
|
|
15537
|
+
|
|
15538
|
+
|
|
15539
|
+
|
|
15540
|
+
|
|
15541
|
+
|
|
15542
|
+
|
|
15543
|
+
|
|
15544
|
+
|
|
15545
|
+
|
|
15546
|
+
|
|
15547
|
+
|
|
15548
|
+
|
|
15549
|
+
|
|
15550
|
+
|
|
15551
|
+
|
|
15552
|
+
|
|
15553
|
+
|
|
15554
|
+
|
|
15555
|
+
|
|
15556
|
+
|
|
15557
|
+
|
|
15558
|
+
|
|
15559
|
+
|
|
15560
|
+
|
|
15561
|
+
|
|
15562
|
+
|
|
15563
|
+
|
|
15564
|
+
|
|
15565
|
+
|
|
15566
|
+
|
|
15567
|
+
|
|
15568
|
+
|
|
15569
|
+
|
|
15570
|
+
|
|
15571
|
+
|
|
15572
|
+
|
|
15573
|
+
|
|
15574
|
+
|
|
15575
|
+
|
|
15576
|
+
|
|
15577
|
+
|
|
15578
|
+
|
|
15579
|
+
|
|
15580
|
+
|
|
15581
|
+
|
|
15582
|
+
|
|
15583
|
+
|
|
15584
|
+
|
|
15585
|
+
|
|
15586
|
+
|
|
15587
|
+
|
|
15588
|
+
|
|
15589
|
+
|
|
15590
|
+
|
|
15591
|
+
|
|
15592
|
+
|
|
14128
15593
|
|
|
14129
15594
|
|
|
14130
15595
|
|
|
@@ -14600,5 +16065,5 @@ async function downloadPsd(controller, name = "image") {
|
|
|
14600
16065
|
|
|
14601
16066
|
|
|
14602
16067
|
|
|
14603
|
-
exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.ADJUSTMENT_LAYER_CONTROLS = ADJUSTMENT_LAYER_CONTROLS; exports.ADJUSTMENT_LAYER_OPACITY_CONTROL = ADJUSTMENT_LAYER_OPACITY_CONTROL; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.BLEND_MODES = _chunkCRMAXIUVcjs.BLEND_MODES; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.BRUSH_OPTION_CONTROLS = BRUSH_OPTION_CONTROLS; exports.CoverageMap = _chunkZZOTHJ4Kcjs.CoverageMap; exports.D50 = D50; exports.D65 = D65; exports.DEFAULT_ADJUSTMENTS = DEFAULT_ADJUSTMENTS; exports.DEFAULT_BRUSH = _chunkZZOTHJ4Kcjs.DEFAULT_BRUSH; exports.DEFAULT_DEPTH_MASK = DEFAULT_DEPTH_MASK; exports.DEFAULT_GLOBAL_LIGHT = _chunk4AB5BHYKcjs.DEFAULT_GLOBAL_LIGHT; exports.DEFAULT_MIXER = _chunkZZOTHJ4Kcjs.DEFAULT_MIXER; exports.DEFAULT_REFINE_EDGE_PARAMS = DEFAULT_REFINE_EDGE_PARAMS; exports.DEFAULT_SELECTION_TOOL_OPTIONS = DEFAULT_SELECTION_TOOL_OPTIONS; exports.DEFAULT_TRANSFORM = DEFAULT_TRANSFORM; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.DIRECT_GAUSSIAN_MAX_SIGMA = _chunk4AB5BHYKcjs.DIRECT_GAUSSIAN_MAX_SIGMA; exports.DabWalker = _chunkZZOTHJ4Kcjs.DabWalker; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.EMPTY_MIXER_LOAD = _chunkZZOTHJ4Kcjs.EMPTY_MIXER_LOAD; exports.GUIDED_FILTER_EPS = GUIDED_FILTER_EPS; exports.HISTOGRAM_BINS = HISTOGRAM_BINS; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.IMAGE_ADJUSTMENT_CONTROLS = IMAGE_ADJUSTMENT_CONTROLS; exports.IMAGE_EDITOR_SCHEMA_VERSION = IMAGE_EDITOR_SCHEMA_VERSION; exports.IMAGE_EDITOR_STATE_VERSION = IMAGE_EDITOR_STATE_VERSION; exports.ImageEditorController = ImageEditorController; exports.ImageEditorRenderer = ImageEditorRenderer; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.LAYER_EFFECT_KINDS = _chunk4AB5BHYKcjs.LAYER_EFFECT_KINDS; exports.LAYER_EFFECT_MENU = LAYER_EFFECT_MENU; exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LUMA_709 = LUMA_709; exports.LayerCompositor = LayerCompositor; exports.LayerEffectError = _chunk4AB5BHYKcjs.LayerEffectError; exports.LayerOperationError = LayerOperationError; exports.MAX_BRUSH_SIZE = _chunkZZOTHJ4Kcjs.MAX_BRUSH_SIZE; exports.MAX_EFFECT_REACH = _chunk4AB5BHYKcjs.MAX_EFFECT_REACH; exports.MAX_KELVIN = MAX_KELVIN; exports.MIN_KELVIN = MIN_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.MIXER_DRAIN = _chunkZZOTHJ4Kcjs.MIXER_DRAIN; exports.MIXER_MIXING_OPTIONS = MIXER_MIXING_OPTIONS; exports.MIXER_OPTION_CONTROLS = MIXER_OPTION_CONTROLS; exports.MIXER_PICKUP_RATE = _chunkZZOTHJ4Kcjs.MIXER_PICKUP_RATE; exports.MIXING_MODELS = _chunkZZOTHJ4Kcjs.MIXING_MODELS; exports.MixerStroke = _chunkZZOTHJ4Kcjs.MixerStroke; exports.PAINT_TOOLS = PAINT_TOOLS; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.PIGMENT_BANDS = _chunkCRMAXIUVcjs.PIGMENT_BANDS; exports.PIGMENT_LAMBDA_MIN = _chunkCRMAXIUVcjs.PIGMENT_LAMBDA_MIN; exports.PIGMENT_LAMBDA_STEP = _chunkCRMAXIUVcjs.PIGMENT_LAMBDA_STEP; exports.PIGMENT_WAVELENGTHS = _chunkCRMAXIUVcjs.PIGMENT_WAVELENGTHS; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.PSD_FILE_ACCEPT = PSD_FILE_ACCEPT; exports.PaintGesture = PaintGesture; exports.PaintStrokeSession = PaintStrokeSession; exports.PatternPlacement = _chunk4AB5BHYKcjs.PatternPlacement; exports.PatternTile = _chunk4AB5BHYKcjs.PatternTile; exports.PsdError = PsdError; exports.REFINE_EDGE_CONTROLS = REFINE_EDGE_CONTROLS; exports.SELECTION_MODES = SELECTION_MODES; exports.SELECTION_MODE_LABELS = SELECTION_MODE_LABELS; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.SELECTION_TOOLS = SELECTION_TOOLS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.SelectionGesture = SelectionGesture; exports.StrokeCoverage = _chunkZZOTHJ4Kcjs.StrokeCoverage; exports.SurfaceDraft = _chunkCRMAXIUVcjs.SurfaceDraft; exports.TILE = _chunkCRMAXIUVcjs.TILE; exports.TILE_SHIFT = _chunkCRMAXIUVcjs.TILE_SHIFT; exports.TINT_SCALE = TINT_SCALE; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.TONE_RANGE_PRESETS = TONE_RANGE_PRESETS; exports.TiledSurface = _chunkCRMAXIUVcjs.TiledSurface; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.ZlibError = _chunk4AB5BHYKcjs.ZlibError; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.addLayerEffect = addLayerEffect; exports.addLayerFilter = addLayerFilter; exports.addToHistogram = addToHistogram; exports.adjustmentKindLabel = adjustmentKindLabel; exports.adjustmentLayersKey = adjustmentLayersKey; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.adler32 = _chunk4AB5BHYKcjs.adler32; exports.annotationLayerFor = annotationLayerFor; exports.annotationLayerName = annotationLayerName; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustments = applyAdjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyMatrix3 = applyMatrix3; exports.applyOutputStage = applyOutputStage; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyRegionBlur = applyRegionBlur; exports.applyRegionMosaic = applyRegionMosaic; exports.applyStrokeToTile = _chunkZZOTHJ4Kcjs.applyStrokeToTile; exports.backgroundLayer = backgroundLayer; exports.base64ToBytes = _chunk4AB5BHYKcjs.base64ToBytes; exports.baseProjection = baseProjection; exports.blackWhiteGray = blackWhiteGray; exports.blendChannel = _chunkCRMAXIUVcjs.blendChannel; exports.blendImageData = _chunkCRMAXIUVcjs.blendImageData; exports.blendLum = _chunkCRMAXIUVcjs.blendLum; exports.blendPixel = _chunkCRMAXIUVcjs.blendPixel; exports.blendRgb = _chunkCRMAXIUVcjs.blendRgb; exports.blendTile = _chunk4AB5BHYKcjs.blendTile; exports.blurFilter = blurFilter; exports.borderCoverage = borderCoverage; exports.boxMean = boxMean; exports.boxToCurvePoint = boxToCurvePoint; exports.bradfordAdaptation = bradfordAdaptation; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.buildToneLut = buildToneLut; exports.builtinPattern = _chunk4AB5BHYKcjs.builtinPattern; exports.builtinPatternIds = _chunk4AB5BHYKcjs.builtinPatternIds; exports.bytesToBase64 = _chunk4AB5BHYKcjs.bytesToBase64; exports.calculateCropDrag = calculateCropDrag; exports.canvasCompositeOperation = _chunkCRMAXIUVcjs.canvasCompositeOperation; exports.canvasToImagePoint = canvasToImagePoint; exports.changedTiles = _chunk4AB5BHYKcjs.changedTiles; exports.clampControlValue = clampControlValue; exports.clampCropToImage = clampCropToImage; exports.cleanMixer = _chunkZZOTHJ4Kcjs.cleanMixer; exports.collectTiles = _chunkCRMAXIUVcjs.collectTiles; exports.colorBalanceChannel = colorBalanceChannel; exports.colorRange = colorRange; exports.combineSelections = combineSelections; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.computeHistogram = computeHistogram; exports.computeSelectionBounds = computeSelectionBounds; exports.contentBounds = _chunkCRMAXIUVcjs.contentBounds; exports.contractCoverage = contractCoverage; exports.controlPosition = controlPosition; exports.controlTrackBackground = controlTrackBackground; exports.coverageTileCoord = _chunkZZOTHJ4Kcjs.coverageTileCoord; exports.coverageToByte = coverageToByte; exports.coveringRect = coveringRect; exports.createAdjustmentLayer = createAdjustmentLayer; exports.createImageCaptureSurface = createImageCaptureSurface; exports.createImageEditTools = createImageEditTools; exports.createImageEditorToolProvider = createImageEditorToolProvider; exports.createImageEffectTools = createImageEffectTools; exports.createImageLayerTools = createImageLayerTools; exports.createImagePaintTools = createImagePaintTools; exports.createImagePsdTools = createImagePsdTools; exports.createImageSelectionTools = createImageSelectionTools; exports.createPigment = _chunkCRMAXIUVcjs.createPigment; exports.createPigmentTools = _chunkZZOTHJ4Kcjs.createPigmentTools; exports.createSelectionMask = createSelectionMask; exports.curveLut = _chunk4AB5BHYKcjs.curveLut; exports.curveLutFromLevels = curveLutFromLevels; exports.curvePointToBox = curvePointToBox; exports.curveSvgPath = curveSvgPath; exports.dabCoverage = _chunkZZOTHJ4Kcjs.dabCoverage; exports.dabRect = _chunkZZOTHJ4Kcjs.dabRect; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeLayerMask = decodeLayerMask; exports.decodeMergedImage = decodeMergedImage; exports.decodePlanes = decodePlanes; exports.decodePng = _chunk4AB5BHYKcjs.decodePng; exports.decodePngDataUrl = decodePngDataUrl; exports.decodeSelectionRle = decodeSelectionRle; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.defaultEffectGradient = _chunk4AB5BHYKcjs.defaultEffectGradient; exports.defaultLayerEffect = _chunk4AB5BHYKcjs.defaultLayerEffect; exports.deflate = _chunk4AB5BHYKcjs.deflate; exports.deflateRaw = _chunk4AB5BHYKcjs.deflateRaw; exports.depthMaskAlpha = depthMaskAlpha; exports.depthRasterMask = depthRasterMask; exports.describeLayer = describeLayer; exports.describeLayerEffects = describeLayerEffects; exports.describeSelection = describeSelection; exports.deserializeEffects = deserializeEffects; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.deserializePatterns = deserializePatterns; exports.deserializeSelection = deserializeSelection; exports.developFilter = developFilter; exports.developFromAdjustments = developFromAdjustments; exports.developTarget = developTarget; exports.distanceTransform = distanceTransform; exports.downloadPsd = downloadPsd; exports.dropPlacement = dropPlacement; exports.dropZone = dropZone; exports.duplicateLayer = duplicateLayer; exports.edgeWidth = edgeWidth; exports.effectColorHex = _chunk4AB5BHYKcjs.effectColorHex; exports.effectControlChange = effectControlChange; exports.effectReach = _chunk4AB5BHYKcjs.effectReach; exports.effectsFingerprint = _chunk4AB5BHYKcjs.effectsFingerprint; exports.effectsMargin = _chunk4AB5BHYKcjs.effectsMargin; exports.effectsScale = _chunk4AB5BHYKcjs.effectsScale; exports.ellipsePoints = ellipsePoints; exports.ellipseSelection = ellipseSelection; exports.emptyHistogram = emptyHistogram; exports.emptySurface = _chunkCRMAXIUVcjs.emptySurface; exports.encodePng = _chunk4AB5BHYKcjs.encodePng; exports.encodeRle = encodeRle; exports.encodeSelectionRle = encodeSelectionRle; exports.encodeSurface = encodeSurface; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.expandCoverage = expandCoverage; exports.exportPsd = exportPsd; exports.featherCoverage = featherCoverage; exports.fillRect = _chunkCRMAXIUVcjs.fillRect; exports.findAdjustmentControl = findAdjustmentControl; exports.findLayer = _chunk4AB5BHYKcjs.findLayer; exports.findLayerControl = findLayerControl; exports.finishTile = _chunkCRMAXIUVcjs.finishTile; exports.flattenLayers = _chunk4AB5BHYKcjs.flattenLayers; exports.formatControlValue = formatControlValue; exports.fullSelection = fullSelection; exports.gaussianBlur = _chunk4AB5BHYKcjs.gaussianBlur; exports.getAnnotationBounds = getAnnotationBounds; exports.getControlPath = getControlPath; exports.getCropCursor = getCropCursor; exports.getRotatedSize = getRotatedSize; exports.getViewportMetrics = getViewportMetrics; exports.getViewportProjection = getViewportProjection; exports.globalImageCache = globalImageCache; exports.greyMorphology = greyMorphology; exports.groupLayers = groupLayers; exports.guidePlanes = guidePlanes; exports.guidedFilterColor = guidedFilterColor; exports.handlePaintShortcut = handlePaintShortcut; exports.hasActiveEffects = _chunk4AB5BHYKcjs.hasActiveEffects; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.hashMaskContent = hashMaskContent; exports.hashNoise = _chunk4AB5BHYKcjs.hashNoise; exports.hexToRgb = hexToRgb; exports.histogramPath = histogramPath; exports.hitTestAnnotation = hitTestAnnotation; exports.hitTestCrop = hitTestCrop; exports.hitTestCurvePoint = hitTestCurvePoint; exports.hslToRgb = hslToRgb; exports.hueRange = hueRange; exports.hueRangeTables = hueRangeTables; exports.hueRangeWeight = hueRangeWeight; exports.hueSaturation = hueSaturation; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.imageEditorStateMigrations = imageEditorStateMigrations; exports.imageToCanvasPoint = imageToCanvasPoint; exports.importPsd = importPsd; exports.inflate = _chunk4AB5BHYKcjs.inflate; exports.inflateRaw = _chunk4AB5BHYKcjs.inflateRaw; exports.insertCurvePoint = insertCurvePoint; exports.insertLayer = _chunk4AB5BHYKcjs.insertLayer; exports.invertMatrix3 = invertMatrix3; exports.invertSelection = invertSelection; exports.isActiveFilter = isActiveFilter; exports.isAdjustmentKind = isAdjustmentKind; exports.isBlendMode = _chunkCRMAXIUVcjs.isBlendMode; exports.isDefaultDepthMask = isDefaultDepthMask; exports.isLayerEffectKind = _chunk4AB5BHYKcjs.isLayerEffectKind; exports.isLayerLocked = _chunk4AB5BHYKcjs.isLayerLocked; exports.isLegacyShape = isLegacyShape; exports.isPaintTool = isPaintTool; exports.isPng = _chunk4AB5BHYKcjs.isPng; exports.isQuarterTurn = isQuarterTurn; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.isSelectionEmpty = isSelectionEmpty; exports.isSelectionMode = isSelectionMode; exports.isSeparableBlendMode = _chunkCRMAXIUVcjs.isSeparableBlendMode; exports.isSpatialFilter = isSpatialFilter; exports.kelvinToTemperature = kelvinToTemperature; exports.layerBadge = layerBadge; exports.layerEffectControls = layerEffectControls; exports.layerEffectFields = _chunk4AB5BHYKcjs.layerEffectFields; exports.layerEffectLabel = _chunk4AB5BHYKcjs.layerEffectLabel; exports.layerEffectsBadge = layerEffectsBadge; exports.layerEffectsOf = layerEffectsOf; exports.layerEffectsPanel = layerEffectsPanel; exports.layerLabel = layerLabel; exports.layerMaskCoverage = layerMaskCoverage; exports.layerMaskFromSelection = layerMaskFromSelection; exports.layerMaskKey = layerMaskKey; exports.layerMenu = layerMenu; exports.layerName = layerName; exports.layerPanelRows = layerPanelRows; exports.layerTree = layerTree; exports.layerTypeLabel = layerTypeLabel; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.legacyMaskOf = legacyMaskOf; exports.legacyView = legacyView; exports.lerpPigment = _chunkCRMAXIUVcjs.lerpPigment; exports.lerpPigmentInto = _chunkCRMAXIUVcjs.lerpPigmentInto; exports.levelsValue = levelsValue; exports.linearSrgbToXy = linearSrgbToXy; exports.linearToSrgb = linearToSrgb; exports.loadImageEditorDocument = loadImageEditorDocument; exports.loadMixer = _chunkZZOTHJ4Kcjs.loadMixer; exports.magicWand = magicWand; exports.mapCropHandle = mapCropHandle; exports.mapLayer = _chunk4AB5BHYKcjs.mapLayer; exports.maskSummary = maskSummary; exports.mergeLayerEffect = _chunk4AB5BHYKcjs.mergeLayerEffect; exports.migrateSerializedImageEditorState = migrateSerializedImageEditorState; exports.migrateToLayeredState = migrateToLayeredState; exports.mixPigment8 = _chunkCRMAXIUVcjs.mixPigment8; exports.mixPigmentRgb = _chunkCRMAXIUVcjs.mixPigmentRgb; exports.mixPigments = _chunkCRMAXIUVcjs.mixPigments; exports.mixerLoadResult = mixerLoadResult; exports.modifySelection = modifySelection; exports.moveCurvePoint = moveCurvePoint; exports.moveLayer = moveLayer; exports.mulMatrix3 = mulMatrix3; exports.needsLegacyBase = needsLegacyBase; exports.neutralHueRange = neutralHueRange; exports.newEffectId = _chunk4AB5BHYKcjs.newEffectId; exports.newLayerId = newLayerId; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.normalizeAngle = normalizeAngle; exports.normalizeBlendMode = _chunkCRMAXIUVcjs.normalizeBlendMode; exports.normalizeBrush = _chunkZZOTHJ4Kcjs.normalizeBrush; exports.normalizeFilter = normalizeFilter; exports.normalizeLayerEffects = _chunk4AB5BHYKcjs.normalizeLayerEffects; exports.normalizeLayerMask = normalizeLayerMask; exports.normalizeMixer = _chunkZZOTHJ4Kcjs.normalizeMixer; exports.normalizeProcessVersion = normalizeProcessVersion; exports.normalizeRect = normalizeRect; exports.normalizeRefineEdgeParams = normalizeRefineEdgeParams; exports.normalizeStoredAdjustments = normalizeStoredAdjustments; exports.offsetLayer = offsetLayer; exports.openPsdFile = openPsdFile; exports.packRgba = _chunkCRMAXIUVcjs.packRgba; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.parseBlend = parseBlend; exports.parseColor = parseColor; exports.parseDataUrl = _chunk4AB5BHYKcjs.parseDataUrl; exports.parseEffectColor = _chunk4AB5BHYKcjs.parseEffectColor; exports.parseLfx2 = parseLfx2; exports.parseLrfx = parseLrfx; exports.parsePatternBlock = parsePatternBlock; exports.parseSelectionMode = parseSelectionMode; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.photoFilterMatrix = photoFilterMatrix; exports.pixelLayerBounds = pixelLayerBounds; exports.pixelLayers = pixelLayers; exports.placeLayer = placeLayer; exports.pngDataUrl = _chunk4AB5BHYKcjs.pngDataUrl; exports.pointerPressure = pointerPressure; exports.polygonCoverage = polygonCoverage; exports.polygonSelection = polygonSelection; exports.posterizeValue = posterizeValue; exports.projectImagePoint = projectImagePoint; exports.projectImageRect = projectImageRect; exports.projectMaskCoverage = projectMaskCoverage; exports.projectQuarterTurn = projectQuarterTurn; exports.psdBytesFromBase64 = psdBytesFromBase64; exports.psdFileName = psdFileName; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.psdToLayers = psdToLayers; exports.quickMaskPixels = quickMaskPixels; exports.rangeLightness = rangeLightness; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.rasterizeDab = _chunkZZOTHJ4Kcjs.rasterizeDab; exports.readAdjustmentControls = readAdjustmentControls; exports.readPixel = _chunkCRMAXIUVcjs.readPixel; exports.readPsd = readPsd; exports.readRegion = _chunkCRMAXIUVcjs.readRegion; exports.rectSelection = rectSelection; exports.refineCoverage = refineCoverage; exports.refineEdgeHalo = refineEdgeHalo; exports.refineSelection = refineSelection; exports.reflectanceToRgb = _chunkCRMAXIUVcjs.reflectanceToRgb; exports.removeAlpha = removeAlpha; exports.removeCurvePoint = removeCurvePoint; exports.removeLayer = removeLayer; exports.removeLayerEffect = removeLayerEffect; exports.removeLayerFilter = removeLayerFilter; exports.renderLayerEffects = _chunk4AB5BHYKcjs.renderLayerEffects; exports.renderLayeredBase = renderLayeredBase; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.resizePixels = resizePixels; exports.resizeSelection = resizeSelection; exports.resolveExternalAssets = resolveExternalAssets; exports.resolveMosaicRegionBounds = resolveMosaicRegionBounds; exports.rgbToGray = rgbToGray; exports.rgbToHsl = rgbToHsl; exports.rgbToReflectance = _chunkCRMAXIUVcjs.rgbToReflectance; exports.rgbUnitToHex = rgbUnitToHex; exports.runLayerMenuAction = runLayerMenuAction; exports.sampleLut = sampleLut; exports.sampleToneLut = sampleToneLut; exports.scaleLayerEffect = _chunk4AB5BHYKcjs.scaleLayerEffect; exports.selectionArea = selectionArea; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionFromPixels = selectionFromPixels; exports.selectionModeFromModifiers = selectionModeFromModifiers; exports.selectionOutline = selectionOutline; exports.selectionToCoverage = selectionToCoverage; exports.selectionToPixels = selectionToPixels; exports.selectionValueAt = selectionValueAt; exports.serializeEffects = serializeEffects; exports.serializeLayer = serializeLayer; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.serializePatterns = serializePatterns; exports.serializeSelection = serializeSelection; exports.setControlPath = setControlPath; exports.setLayerEffects = setLayerEffects; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.setLayerMask = setLayerMask; exports.setLayerProperties = setLayerProperties; exports.setLum = _chunkCRMAXIUVcjs.setLum; exports.setPigmentColor = _chunkCRMAXIUVcjs.setPigmentColor; exports.shiftCoverage = shiftCoverage; exports.smoothCoverage = smoothCoverage; exports.smoothPoints = _chunkZZOTHJ4Kcjs.smoothPoints; exports.solidSurface = _chunkCRMAXIUVcjs.solidSurface; exports.splitOverlayAnnotations = splitOverlayAnnotations; exports.srgb8ToLab = srgb8ToLab; exports.srgbToLinear = srgbToLinear; exports.sumHistograms = sumHistograms; exports.surfaceBytes = _chunkCRMAXIUVcjs.surfaceBytes; exports.surfaceFromPixels = _chunkCRMAXIUVcjs.surfaceFromPixels; exports.surfacesEqual = _chunkCRMAXIUVcjs.surfacesEqual; exports.tempTintToXy = tempTintToXy; exports.temperatureToKelvin = temperatureToKelvin; exports.tileCoord = _chunkCRMAXIUVcjs.tileCoord; exports.tileKey = _chunkCRMAXIUVcjs.tileKey; exports.tileRect = _chunkCRMAXIUVcjs.tileRect; exports.tilesInRect = _chunkCRMAXIUVcjs.tilesInRect; exports.tipFalloff = _chunkZZOTHJ4Kcjs.tipFalloff; exports.tipReach = _chunkZZOTHJ4Kcjs.tipReach; exports.tipShape = _chunkZZOTHJ4Kcjs.tipShape; exports.toHex = toHex2; exports.toneCurve = toneCurve; exports.toneLuts = toneLuts; exports.toneRange = toneRange; exports.translateSurface = _chunkCRMAXIUVcjs.translateSurface; exports.ungroupLayer = ungroupLayer; exports.uniformTile = _chunkCRMAXIUVcjs.uniformTile; exports.unionRect = unionRect; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.updateLayerEffect = updateLayerEffect; exports.updateLayerFilter = updateLayerFilter; exports.updateLayerMaskProps = updateLayerMaskProps; exports.uvToXy = uvToXy; exports.validateEffectGradient = _chunk4AB5BHYKcjs.validateEffectGradient; exports.validateLayerEffect = _chunk4AB5BHYKcjs.validateLayerEffect; exports.validateLayerEffects = _chunk4AB5BHYKcjs.validateLayerEffects; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.walkDabs = _chunkZZOTHJ4Kcjs.walkDabs; exports.wbMatrix = wbMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.withNewIds = withNewIds; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.writeLfx2 = writeLfx2; exports.writePatternBlock = writePatternBlock; exports.writePsd = writePsd; exports.writeRegion = _chunkCRMAXIUVcjs.writeRegion; exports.xyToTempTint = xyToTempTint; exports.xyToUv = xyToUv;
|
|
16068
|
+
exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.ADJUSTMENT_LAYER_CONTROLS = ADJUSTMENT_LAYER_CONTROLS; exports.ADJUSTMENT_LAYER_OPACITY_CONTROL = ADJUSTMENT_LAYER_OPACITY_CONTROL; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.BLEND_MODES = _chunkCRMAXIUVcjs.BLEND_MODES; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.BRUSH_OPTION_CONTROLS = BRUSH_OPTION_CONTROLS; exports.CoverageMap = _chunkZZOTHJ4Kcjs.CoverageMap; exports.D50 = D50; exports.D65 = D65; exports.DEFAULT_ADJUSTMENTS = DEFAULT_ADJUSTMENTS; exports.DEFAULT_BRUSH = _chunkZZOTHJ4Kcjs.DEFAULT_BRUSH; exports.DEFAULT_DEPTH_MASK = DEFAULT_DEPTH_MASK; exports.DEFAULT_GLOBAL_LIGHT = _chunkWT6ZAWJPcjs.DEFAULT_GLOBAL_LIGHT; exports.DEFAULT_MIXER = _chunkZZOTHJ4Kcjs.DEFAULT_MIXER; exports.DEFAULT_REFINE_EDGE_PARAMS = DEFAULT_REFINE_EDGE_PARAMS; exports.DEFAULT_SELECTION_TOOL_OPTIONS = DEFAULT_SELECTION_TOOL_OPTIONS; exports.DEFAULT_TRANSFORM = DEFAULT_TRANSFORM; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.DIRECT_GAUSSIAN_MAX_SIGMA = _chunkWT6ZAWJPcjs.DIRECT_GAUSSIAN_MAX_SIGMA; exports.DabWalker = _chunkZZOTHJ4Kcjs.DabWalker; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.EMPTY_MIXER_LOAD = _chunkZZOTHJ4Kcjs.EMPTY_MIXER_LOAD; exports.FREE_TRANSFORM_CONTENTS = FREE_TRANSFORM_CONTENTS; exports.FREE_TRANSFORM_FIELDS = FREE_TRANSFORM_FIELDS; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.FREE_TRANSFORM_MODE_OPTIONS = FREE_TRANSFORM_MODE_OPTIONS; exports.FreeTransformSession = FreeTransformSession; exports.FreeTransformTool = FreeTransformTool; exports.GUIDED_FILTER_EPS = GUIDED_FILTER_EPS; exports.HISTOGRAM_BINS = HISTOGRAM_BINS; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.IMAGE_ADJUSTMENT_CONTROLS = IMAGE_ADJUSTMENT_CONTROLS; exports.IMAGE_EDITOR_SCHEMA_VERSION = IMAGE_EDITOR_SCHEMA_VERSION; exports.IMAGE_EDITOR_STATE_VERSION = IMAGE_EDITOR_STATE_VERSION; exports.INTERPOLATIONS = _chunkWT6ZAWJPcjs.INTERPOLATIONS; exports.ImageEditorController = ImageEditorController; exports.ImageEditorRenderer = ImageEditorRenderer; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.LAYER_EFFECT_KINDS = _chunkWT6ZAWJPcjs.LAYER_EFFECT_KINDS; exports.LAYER_EFFECT_MENU = LAYER_EFFECT_MENU; exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LUMA_709 = LUMA_709; exports.LayerCompositor = LayerCompositor; exports.LayerEffectError = _chunkWT6ZAWJPcjs.LayerEffectError; exports.LayerOperationError = LayerOperationError; exports.MAX_BRUSH_SIZE = _chunkZZOTHJ4Kcjs.MAX_BRUSH_SIZE; exports.MAX_EFFECT_REACH = _chunkWT6ZAWJPcjs.MAX_EFFECT_REACH; exports.MAX_KELVIN = MAX_KELVIN; exports.MAX_TRANSFORM_PIXELS = _chunkWT6ZAWJPcjs.MAX_TRANSFORM_PIXELS; exports.MIN_KELVIN = MIN_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.MIXER_DRAIN = _chunkZZOTHJ4Kcjs.MIXER_DRAIN; exports.MIXER_MIXING_OPTIONS = MIXER_MIXING_OPTIONS; exports.MIXER_OPTION_CONTROLS = MIXER_OPTION_CONTROLS; exports.MIXER_PICKUP_RATE = _chunkZZOTHJ4Kcjs.MIXER_PICKUP_RATE; exports.MIXING_MODELS = _chunkZZOTHJ4Kcjs.MIXING_MODELS; exports.MixerStroke = _chunkZZOTHJ4Kcjs.MixerStroke; exports.PAINT_TOOLS = PAINT_TOOLS; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.PIGMENT_BANDS = _chunkCRMAXIUVcjs.PIGMENT_BANDS; exports.PIGMENT_LAMBDA_MIN = _chunkCRMAXIUVcjs.PIGMENT_LAMBDA_MIN; exports.PIGMENT_LAMBDA_STEP = _chunkCRMAXIUVcjs.PIGMENT_LAMBDA_STEP; exports.PIGMENT_WAVELENGTHS = _chunkCRMAXIUVcjs.PIGMENT_WAVELENGTHS; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.PSD_FILE_ACCEPT = PSD_FILE_ACCEPT; exports.PaintGesture = PaintGesture; exports.PaintStrokeSession = PaintStrokeSession; exports.PatternPlacement = _chunkWT6ZAWJPcjs.PatternPlacement; exports.PatternTile = _chunkWT6ZAWJPcjs.PatternTile; exports.PsdError = PsdError; exports.REFINE_EDGE_CONTROLS = REFINE_EDGE_CONTROLS; exports.SELECTION_MODES = SELECTION_MODES; exports.SELECTION_MODE_LABELS = SELECTION_MODE_LABELS; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.SELECTION_TOOLS = SELECTION_TOOLS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.SelectionGesture = SelectionGesture; exports.StrokeCoverage = _chunkZZOTHJ4Kcjs.StrokeCoverage; exports.SurfaceDraft = _chunkCRMAXIUVcjs.SurfaceDraft; exports.TILE = _chunkCRMAXIUVcjs.TILE; exports.TILE_SHIFT = _chunkCRMAXIUVcjs.TILE_SHIFT; exports.TINT_SCALE = TINT_SCALE; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.TONE_RANGE_PRESETS = TONE_RANGE_PRESETS; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.TiledSurface = _chunkCRMAXIUVcjs.TiledSurface; exports.TransformTooLargeError = _chunkWT6ZAWJPcjs.TransformTooLargeError; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.WARP_STYLES = _chunkDWGZUSEScjs.WARP_STYLES; exports.WARP_STYLE_LABELS = _chunkDWGZUSEScjs.WARP_STYLE_LABELS; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.ZlibError = _chunkWT6ZAWJPcjs.ZlibError; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.addLayerEffect = addLayerEffect; exports.addLayerFilter = addLayerFilter; exports.addToHistogram = addToHistogram; exports.adjustmentKindLabel = adjustmentKindLabel; exports.adjustmentLayersKey = adjustmentLayersKey; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.adler32 = _chunkWT6ZAWJPcjs.adler32; exports.anchorPoint = anchorPoint; exports.annotationLayerFor = annotationLayerFor; exports.annotationLayerName = annotationLayerName; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustments = applyAdjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.applyHomography = _chunkMUUXNRU4cjs.applyHomography; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyMatrix3 = applyMatrix3; exports.applyOutputStage = applyOutputStage; exports.applyParams = applyParams; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyRegionBlur = applyRegionBlur; exports.applyRegionMosaic = applyRegionMosaic; exports.applyStrokeToTile = _chunkZZOTHJ4Kcjs.applyStrokeToTile; exports.backgroundLayer = backgroundLayer; exports.base64ToBytes = _chunkWT6ZAWJPcjs.base64ToBytes; exports.baseProjection = baseProjection; exports.blackWhiteGray = blackWhiteGray; exports.blendChannel = _chunkCRMAXIUVcjs.blendChannel; exports.blendImageData = _chunkCRMAXIUVcjs.blendImageData; exports.blendLum = _chunkCRMAXIUVcjs.blendLum; exports.blendPixel = _chunkCRMAXIUVcjs.blendPixel; exports.blendRgb = _chunkCRMAXIUVcjs.blendRgb; exports.blendTile = _chunkWT6ZAWJPcjs.blendTile; exports.blurFilter = blurFilter; exports.borderCoverage = borderCoverage; exports.boxMean = boxMean; exports.boxPointOf = boxPointOf; exports.boxQuad = _chunkMUUXNRU4cjs.boxQuad; exports.boxToCurvePoint = boxToCurvePoint; exports.bradfordAdaptation = bradfordAdaptation; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.buildToneLut = buildToneLut; exports.builtinPattern = _chunkWT6ZAWJPcjs.builtinPattern; exports.builtinPatternIds = _chunkWT6ZAWJPcjs.builtinPatternIds; exports.bytesToBase64 = _chunkWT6ZAWJPcjs.bytesToBase64; exports.calculateCropDrag = calculateCropDrag; exports.canvasCompositeOperation = _chunkCRMAXIUVcjs.canvasCompositeOperation; exports.canvasToImagePoint = canvasToImagePoint; exports.changedTiles = _chunkWT6ZAWJPcjs.changedTiles; exports.clampControlValue = clampControlValue; exports.clampCropToImage = clampCropToImage; exports.cleanMixer = _chunkZZOTHJ4Kcjs.cleanMixer; exports.collectTiles = _chunkCRMAXIUVcjs.collectTiles; exports.colorBalanceChannel = colorBalanceChannel; exports.colorRange = colorRange; exports.combineSelections = combineSelections; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.compositeSurfaceOver = _chunkWT6ZAWJPcjs.compositeSurfaceOver; exports.computeHistogram = computeHistogram; exports.computeSelectionBounds = computeSelectionBounds; exports.contentBounds = _chunkCRMAXIUVcjs.contentBounds; exports.contractCoverage = contractCoverage; exports.controlPosition = controlPosition; exports.controlTrackBackground = controlTrackBackground; exports.cornersFromMatrix = cornersFromMatrix; exports.coverageTileCoord = _chunkZZOTHJ4Kcjs.coverageTileCoord; exports.coverageToByte = coverageToByte; exports.coveringRect = coveringRect; exports.createAdjustmentLayer = createAdjustmentLayer; exports.createImageCaptureSurface = createImageCaptureSurface; exports.createImageEditTools = createImageEditTools; exports.createImageEditorToolProvider = createImageEditorToolProvider; exports.createImageEffectTools = createImageEffectTools; exports.createImageLayerTools = createImageLayerTools; exports.createImagePaintTools = createImagePaintTools; exports.createImagePsdTools = createImagePsdTools; exports.createImageSelectionTools = createImageSelectionTools; exports.createImageTransformTools = createImageTransformTools; exports.createPigment = _chunkCRMAXIUVcjs.createPigment; exports.createPigmentTools = _chunkZZOTHJ4Kcjs.createPigmentTools; exports.createSelectionMask = createSelectionMask; exports.curveLut = _chunkWT6ZAWJPcjs.curveLut; exports.curveLutFromLevels = curveLutFromLevels; exports.curvePointToBox = curvePointToBox; exports.curveSvgPath = curveSvgPath; exports.dabCoverage = _chunkZZOTHJ4Kcjs.dabCoverage; exports.dabRect = _chunkZZOTHJ4Kcjs.dabRect; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeLayerMask = decodeLayerMask; exports.decodeMergedImage = decodeMergedImage; exports.decodePlanes = decodePlanes; exports.decodePng = _chunkWT6ZAWJPcjs.decodePng; exports.decodePngDataUrl = decodePngDataUrl; exports.decodeSelectionRle = decodeSelectionRle; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.defaultEffectGradient = _chunkWT6ZAWJPcjs.defaultEffectGradient; exports.defaultLayerEffect = _chunkWT6ZAWJPcjs.defaultLayerEffect; exports.deflate = _chunkWT6ZAWJPcjs.deflate; exports.deflateRaw = _chunkWT6ZAWJPcjs.deflateRaw; exports.depthMaskAlpha = depthMaskAlpha; exports.depthRasterMask = depthRasterMask; exports.describeLayer = describeLayer; exports.describeLayerEffects = describeLayerEffects; exports.describeSelection = describeSelection; exports.describeTransform = describeTransform; exports.deserializeEffects = deserializeEffects; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.deserializePatterns = deserializePatterns; exports.deserializeSelection = deserializeSelection; exports.developFilter = developFilter; exports.developFromAdjustments = developFromAdjustments; exports.developTarget = developTarget; exports.distanceTransform = distanceTransform; exports.downloadPsd = downloadPsd; exports.dragWarpMeshPoint = _chunkDWGZUSEScjs.dragWarpMeshPoint; exports.dropPlacement = dropPlacement; exports.dropZone = dropZone; exports.duplicateLayer = duplicateLayer; exports.edgeWidth = edgeWidth; exports.effectColorHex = _chunkWT6ZAWJPcjs.effectColorHex; exports.effectControlChange = effectControlChange; exports.effectReach = _chunkWT6ZAWJPcjs.effectReach; exports.effectsFingerprint = _chunkWT6ZAWJPcjs.effectsFingerprint; exports.effectsMargin = _chunkWT6ZAWJPcjs.effectsMargin; exports.effectsScale = _chunkWT6ZAWJPcjs.effectsScale; exports.ellipsePoints = ellipsePoints; exports.ellipseSelection = ellipseSelection; exports.emptyHistogram = emptyHistogram; exports.emptySurface = _chunkCRMAXIUVcjs.emptySurface; exports.encodePng = _chunkWT6ZAWJPcjs.encodePng; exports.encodeRle = encodeRle; exports.encodeSelectionRle = encodeSelectionRle; exports.encodeSurface = encodeSurface; exports.evalWarpMesh = _chunkDWGZUSEScjs.evalWarpMesh; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.expandCoverage = expandCoverage; exports.exportPsd = exportPsd; exports.featherCoverage = featherCoverage; exports.fillRect = _chunkCRMAXIUVcjs.fillRect; exports.findAdjustmentControl = findAdjustmentControl; exports.findLayer = _chunkWT6ZAWJPcjs.findLayer; exports.findLayerControl = findLayerControl; exports.finishTile = _chunkCRMAXIUVcjs.finishTile; exports.flattenLayers = _chunkWT6ZAWJPcjs.flattenLayers; exports.flipCorners = flipCorners; exports.formatControlValue = formatControlValue; exports.fullSelection = fullSelection; exports.gaussianBlur = _chunkWT6ZAWJPcjs.gaussianBlur; exports.geometryHomography = geometryHomography; exports.getAnnotationBounds = getAnnotationBounds; exports.getControlPath = getControlPath; exports.getCropCursor = getCropCursor; exports.getRotatedSize = getRotatedSize; exports.getViewportMetrics = getViewportMetrics; exports.getViewportProjection = getViewportProjection; exports.globalImageCache = globalImageCache; exports.greyMorphology = greyMorphology; exports.groupLayers = groupLayers; exports.guidePlanes = guidePlanes; exports.guidedFilterColor = guidedFilterColor; exports.handlePaintShortcut = handlePaintShortcut; exports.hasActiveEffects = _chunkWT6ZAWJPcjs.hasActiveEffects; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.hasWarp = hasWarp; exports.hashMaskContent = hashMaskContent; exports.hashNoise = _chunkWT6ZAWJPcjs.hashNoise; exports.hexToRgb = hexToRgb; exports.histogramPath = histogramPath; exports.hitTestAnnotation = hitTestAnnotation; exports.hitTestCrop = hitTestCrop; exports.hitTestCurvePoint = hitTestCurvePoint; exports.homographyFromAffine = _chunkMUUXNRU4cjs.homographyFromAffine; exports.homographyFromPoints = _chunkMUUXNRU4cjs.homographyFromPoints; exports.hslToRgb = hslToRgb; exports.hueRange = hueRange; exports.hueRangeTables = hueRangeTables; exports.hueRangeWeight = hueRangeWeight; exports.hueSaturation = hueSaturation; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.identityTransform = identityTransform; exports.identityWarpMesh = _chunkDWGZUSEScjs.identityWarpMesh; exports.imageEditorStateMigrations = imageEditorStateMigrations; exports.imageToCanvasPoint = imageToCanvasPoint; exports.importPsd = importPsd; exports.inflate = _chunkWT6ZAWJPcjs.inflate; exports.inflateRaw = _chunkWT6ZAWJPcjs.inflateRaw; exports.insertCurvePoint = insertCurvePoint; exports.insertLayer = _chunkWT6ZAWJPcjs.insertLayer; exports.invertHomography = _chunkMUUXNRU4cjs.invertHomography; exports.invertMatrix3 = invertMatrix3; exports.invertSelection = invertSelection; exports.isActiveFilter = isActiveFilter; exports.isAdjustmentKind = isAdjustmentKind; exports.isBlendMode = _chunkCRMAXIUVcjs.isBlendMode; exports.isDefaultDepthMask = isDefaultDepthMask; exports.isIdentityTransform = isIdentityTransform; exports.isInterpolation = _chunkWT6ZAWJPcjs.isInterpolation; exports.isLayerEffectKind = _chunkWT6ZAWJPcjs.isLayerEffectKind; exports.isLayerLocked = _chunkWT6ZAWJPcjs.isLayerLocked; exports.isLegacyShape = isLegacyShape; exports.isPaintTool = isPaintTool; exports.isPng = _chunkWT6ZAWJPcjs.isPng; exports.isQuarterTurn = isQuarterTurn; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.isSelectionEmpty = isSelectionEmpty; exports.isSelectionMode = isSelectionMode; exports.isSeparableBlendMode = _chunkCRMAXIUVcjs.isSeparableBlendMode; exports.isSpatialFilter = isSpatialFilter; exports.isTransformAnchor = isTransformAnchor; exports.isValidWarp = isValidWarp; exports.kelvinToTemperature = kelvinToTemperature; exports.keysWeight = _chunkWT6ZAWJPcjs.keysWeight; exports.layerBadge = layerBadge; exports.layerEffectControls = layerEffectControls; exports.layerEffectFields = _chunkWT6ZAWJPcjs.layerEffectFields; exports.layerEffectLabel = _chunkWT6ZAWJPcjs.layerEffectLabel; exports.layerEffectsBadge = layerEffectsBadge; exports.layerEffectsOf = layerEffectsOf; exports.layerEffectsPanel = layerEffectsPanel; exports.layerLabel = layerLabel; exports.layerMaskCoverage = layerMaskCoverage; exports.layerMaskFromSelection = layerMaskFromSelection; exports.layerMaskKey = layerMaskKey; exports.layerMenu = layerMenu; exports.layerName = layerName; exports.layerPanelRows = layerPanelRows; exports.layerTree = layerTree; exports.layerTypeLabel = layerTypeLabel; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.legacyMaskOf = legacyMaskOf; exports.legacyView = legacyView; exports.lerpPigment = _chunkCRMAXIUVcjs.lerpPigment; exports.lerpPigmentInto = _chunkCRMAXIUVcjs.lerpPigmentInto; exports.levelsValue = levelsValue; exports.linearSrgbToXy = linearSrgbToXy; exports.linearToSrgb = linearToSrgb; exports.loadImageEditorDocument = loadImageEditorDocument; exports.loadMixer = _chunkZZOTHJ4Kcjs.loadMixer; exports.magicWand = magicWand; exports.mapCropHandle = mapCropHandle; exports.mapLayer = _chunkWT6ZAWJPcjs.mapLayer; exports.maskSummary = maskSummary; exports.matrixFromCorners = matrixFromCorners; exports.matrixFromParams = matrixFromParams; exports.mergeLayerEffect = _chunkWT6ZAWJPcjs.mergeLayerEffect; exports.migrateSerializedImageEditorState = migrateSerializedImageEditorState; exports.migrateToLayeredState = migrateToLayeredState; exports.mixPigment8 = _chunkCRMAXIUVcjs.mixPigment8; exports.mixPigmentRgb = _chunkCRMAXIUVcjs.mixPigmentRgb; exports.mixPigments = _chunkCRMAXIUVcjs.mixPigments; exports.mixerLoadResult = mixerLoadResult; exports.modifySelection = modifySelection; exports.moveCurvePoint = moveCurvePoint; exports.moveLayer = moveLayer; exports.mulMatrix3 = mulMatrix3; exports.needsLegacyBase = needsLegacyBase; exports.neutralHueRange = neutralHueRange; exports.newEffectId = _chunkWT6ZAWJPcjs.newEffectId; exports.newLayerId = newLayerId; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.normalizeAngle = normalizeAngle; exports.normalizeBlendMode = _chunkCRMAXIUVcjs.normalizeBlendMode; exports.normalizeBrush = _chunkZZOTHJ4Kcjs.normalizeBrush; exports.normalizeFilter = normalizeFilter; exports.normalizeLayerEffects = _chunkWT6ZAWJPcjs.normalizeLayerEffects; exports.normalizeLayerMask = normalizeLayerMask; exports.normalizeMixer = _chunkZZOTHJ4Kcjs.normalizeMixer; exports.normalizeProcessVersion = normalizeProcessVersion; exports.normalizeRect = normalizeRect; exports.normalizeRefineEdgeParams = normalizeRefineEdgeParams; exports.normalizeStoredAdjustments = normalizeStoredAdjustments; exports.offsetLayer = offsetLayer; exports.openPsdFile = openPsdFile; exports.packRgba = _chunkCRMAXIUVcjs.packRgba; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.parseBlend = parseBlend; exports.parseColor = parseColor; exports.parseDataUrl = _chunkWT6ZAWJPcjs.parseDataUrl; exports.parseEffectColor = _chunkWT6ZAWJPcjs.parseEffectColor; exports.parseLfx2 = parseLfx2; exports.parseLrfx = parseLrfx; exports.parsePatternBlock = parsePatternBlock; exports.parseSelectionMode = parseSelectionMode; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.photoFilterMatrix = photoFilterMatrix; exports.pixelLayerBounds = pixelLayerBounds; exports.pixelLayers = pixelLayers; exports.placeLayer = placeLayer; exports.pngDataUrl = _chunkWT6ZAWJPcjs.pngDataUrl; exports.pointerPressure = pointerPressure; exports.polygonCoverage = polygonCoverage; exports.polygonSelection = polygonSelection; exports.posterizeValue = posterizeValue; exports.presetWarp = presetWarp; exports.previewStep = previewStep; exports.projectImagePoint = projectImagePoint; exports.projectImageRect = projectImageRect; exports.projectMaskCoverage = projectMaskCoverage; exports.projectQuarterTurn = projectQuarterTurn; exports.psdBytesFromBase64 = psdBytesFromBase64; exports.psdFileName = psdFileName; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.psdToLayers = psdToLayers; exports.pullWarpMesh = _chunkDWGZUSEScjs.pullWarpMesh; exports.quickMaskPixels = quickMaskPixels; exports.rangeLightness = rangeLightness; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.rasterizeDab = _chunkZZOTHJ4Kcjs.rasterizeDab; exports.readAdjustmentControls = readAdjustmentControls; exports.readPixel = _chunkCRMAXIUVcjs.readPixel; exports.readPsd = readPsd; exports.readRegion = _chunkCRMAXIUVcjs.readRegion; exports.rectSelection = rectSelection; exports.rectToQuad = _chunkMUUXNRU4cjs.rectToQuad; exports.reduceSurface = _chunkWT6ZAWJPcjs.reduceSurface; exports.referencePoint = referencePoint; exports.refineCoverage = refineCoverage; exports.refineEdgeHalo = refineEdgeHalo; exports.refineSelection = refineSelection; exports.reflectanceToRgb = _chunkCRMAXIUVcjs.reflectanceToRgb; exports.removeAlpha = removeAlpha; exports.removeCurvePoint = removeCurvePoint; exports.removeLayer = removeLayer; exports.removeLayerEffect = removeLayerEffect; exports.removeLayerFilter = removeLayerFilter; exports.renderLayerEffects = _chunkWT6ZAWJPcjs.renderLayerEffects; exports.renderLayeredBase = renderLayeredBase; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.resizePixels = resizePixels; exports.resizeSelection = resizeSelection; exports.resizeWarpMesh = _chunkDWGZUSEScjs.resizeWarpMesh; exports.resolveExternalAssets = resolveExternalAssets; exports.resolveMosaicRegionBounds = resolveMosaicRegionBounds; exports.rgbToGray = rgbToGray; exports.rgbToHsl = rgbToHsl; exports.rgbToReflectance = _chunkCRMAXIUVcjs.rgbToReflectance; exports.rgbUnitToHex = rgbUnitToHex; exports.runLayerMenuAction = runLayerMenuAction; exports.sampleLut = sampleLut; exports.sampleToneLut = sampleToneLut; exports.scaleLayerEffect = _chunkWT6ZAWJPcjs.scaleLayerEffect; exports.selectionArea = selectionArea; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionFromPixels = selectionFromPixels; exports.selectionModeFromModifiers = selectionModeFromModifiers; exports.selectionOutline = selectionOutline; exports.selectionToCoverage = selectionToCoverage; exports.selectionToPixels = selectionToPixels; exports.selectionValueAt = selectionValueAt; exports.serializeEffects = serializeEffects; exports.serializeLayer = serializeLayer; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.serializePatterns = serializePatterns; exports.serializeSelection = serializeSelection; exports.setControlPath = setControlPath; exports.setLayerEffects = setLayerEffects; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.setLayerMask = setLayerMask; exports.setLayerProperties = setLayerProperties; exports.setLum = _chunkCRMAXIUVcjs.setLum; exports.setPigmentColor = _chunkCRMAXIUVcjs.setPigmentColor; exports.shiftCoverage = shiftCoverage; exports.smoothCoverage = smoothCoverage; exports.smoothPoints = _chunkZZOTHJ4Kcjs.smoothPoints; exports.solidSurface = _chunkCRMAXIUVcjs.solidSurface; exports.splitOverlayAnnotations = splitOverlayAnnotations; exports.srgb8ToLab = srgb8ToLab; exports.srgbToLinear = srgbToLinear; exports.sumHistograms = sumHistograms; exports.surfaceBytes = _chunkCRMAXIUVcjs.surfaceBytes; exports.surfaceFromPixels = _chunkCRMAXIUVcjs.surfaceFromPixels; exports.surfacesEqual = _chunkCRMAXIUVcjs.surfacesEqual; exports.tempTintToXy = tempTintToXy; exports.temperatureToKelvin = temperatureToKelvin; exports.tileCoord = _chunkCRMAXIUVcjs.tileCoord; exports.tileKey = _chunkCRMAXIUVcjs.tileKey; exports.tileRect = _chunkCRMAXIUVcjs.tileRect; exports.tilesInRect = _chunkCRMAXIUVcjs.tilesInRect; exports.tipFalloff = _chunkZZOTHJ4Kcjs.tipFalloff; exports.tipReach = _chunkZZOTHJ4Kcjs.tipReach; exports.tipShape = _chunkZZOTHJ4Kcjs.tipShape; exports.toHex = toHex2; exports.toneCurve = toneCurve; exports.toneLuts = toneLuts; exports.toneRange = toneRange; exports.transformHomography = transformHomography; exports.transformMap = transformMap; exports.transformSurface = _chunkWT6ZAWJPcjs.transformSurface; exports.transformedBounds = _chunkWT6ZAWJPcjs.transformedBounds; exports.transformedBox = transformedBox; exports.transformedPoint = transformedPoint; exports.translateSurface = _chunkCRMAXIUVcjs.translateSurface; exports.ungroupLayer = ungroupLayer; exports.uniformTile = _chunkCRMAXIUVcjs.uniformTile; exports.unionRect = unionRect; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.updateLayerEffect = updateLayerEffect; exports.updateLayerFilter = updateLayerFilter; exports.updateLayerMaskProps = updateLayerMaskProps; exports.uvToXy = uvToXy; exports.validateEffectGradient = _chunkWT6ZAWJPcjs.validateEffectGradient; exports.validateLayerEffect = _chunkWT6ZAWJPcjs.validateLayerEffect; exports.validateLayerEffects = _chunkWT6ZAWJPcjs.validateLayerEffects; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.walkDabs = _chunkZZOTHJ4Kcjs.walkDabs; exports.warpMeshEditPoints = _chunkDWGZUSEScjs.warpMeshEditPoints; exports.warpMeshGridCurves = _chunkDWGZUSEScjs.warpMeshGridCurves; exports.warpMeshParamAt = _chunkDWGZUSEScjs.warpMeshParamAt; exports.warpPresetMesh = _chunkDWGZUSEScjs.warpPresetMesh; exports.warpSurface = _chunkWT6ZAWJPcjs.warpSurface; exports.wbMatrix = wbMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.withNewIds = withNewIds; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.writeLfx2 = writeLfx2; exports.writePatternBlock = writePatternBlock; exports.writePsd = writePsd; exports.writeRegion = _chunkCRMAXIUVcjs.writeRegion; exports.xyToTempTint = xyToTempTint; exports.xyToUv = xyToUv;
|
|
14604
16069
|
//# sourceMappingURL=index.cjs.map
|