@pixerate/editor 0.259.0 → 0.260.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.js +1 -1
- package/dist/animation-editor/index.cjs +61 -59
- package/dist/animation-editor/index.js +5 -3
- package/dist/brushes/index.cjs +52 -52
- package/dist/brushes/index.js +6 -6
- package/dist/{brushstrokeRender-JI4W6F2G.js → brushstrokeRender-25Q5BEY6.js} +17 -7
- package/dist/{brushstrokeRender-MQ6PSDM5.cjs → brushstrokeRender-N6UPZSQS.cjs} +31 -21
- package/dist/canvas/brushTypes.d.cts +5 -0
- package/dist/canvas/brushTypes.d.ts +5 -0
- package/dist/canvas/drawController.d.cts +15 -1
- package/dist/canvas/drawController.d.ts +15 -1
- package/dist/canvas/index.cjs +136 -102
- package/dist/canvas/index.js +35 -1
- package/dist/{chunk-3PPJRMIG.js → chunk-3O47TPGX.js} +197 -18
- package/dist/{chunk-5Q5MLXAD.cjs → chunk-3TQW5MPW.cjs} +23 -23
- package/dist/{chunk-JBBJE76O.cjs → chunk-3ZRNK3RO.cjs} +1138 -85
- package/dist/{chunk-YSGW7VV4.cjs → chunk-43NT242D.cjs} +1401 -228
- package/dist/{chunk-SMTUQWGY.js → chunk-5IW65VQ6.js} +1 -1
- package/dist/{chunk-YQ4PQTBB.js → chunk-6NZL24W4.js} +9 -1
- package/dist/{chunk-O3ZVZSNJ.cjs → chunk-7AUQ2UJ3.cjs} +137 -129
- package/dist/{chunk-4M4E3N6X.js → chunk-CQVTGBQI.js} +1 -1
- package/dist/{chunk-SSFMWJDK.js → chunk-D4TE5JNW.js} +1192 -19
- package/dist/{chunk-AORZ5M5C.js → chunk-EHALWBBD.js} +1 -1
- package/dist/{chunk-6WCQ35GI.cjs → chunk-NHA26O5X.cjs} +2 -2
- package/dist/{chunk-DPYAO5U6.cjs → chunk-PVJMTLPJ.cjs} +197 -18
- package/dist/{chunk-MQGQTKVW.cjs → chunk-PYTJBVW5.cjs} +29 -29
- package/dist/{chunk-IXQZHCOF.js → chunk-QAR2N7HZ.js} +1 -1
- package/dist/{chunk-5P4JEOIV.js → chunk-TMDDMJCR.js} +2 -2
- package/dist/{chunk-RSIKDWOP.cjs → chunk-TZOX7KWV.cjs} +15 -15
- package/dist/{chunk-IPUTIUGQ.cjs → chunk-UVZ7RQOE.cjs} +1 -1
- package/dist/{chunk-A7GJ6BXI.js → chunk-WJ4WQJCC.js} +1062 -9
- package/dist/{chunk-ICTPLVSR.js → chunk-X2EXYY4J.js} +1 -1
- package/dist/{chunk-WQCNC4DK.js → chunk-XC6DPRYI.js} +695 -4
- package/dist/{chunk-KBYB7OWB.cjs → chunk-YHDHFJUC.cjs} +776 -85
- package/dist/{chunk-P3PZ63M3.cjs → chunk-YLUIFXSL.cjs} +35 -35
- package/dist/commands/index.cjs +2 -2
- package/dist/commands/index.js +1 -1
- package/dist/image-editor/index.cjs +1385 -2484
- package/dist/image-editor/index.js +139 -1238
- package/dist/image-editor/selection-worker.cjs +3 -4
- package/dist/image-editor/selection-worker.js +1 -2
- package/dist/paint/index.cjs +3 -5
- package/dist/paint/index.js +40 -42
- package/dist/paint-editor/contract.d.cts +29 -0
- package/dist/paint-editor/contract.d.ts +29 -0
- package/dist/paint-editor/dab-stroke.d.cts +5 -0
- package/dist/paint-editor/dab-stroke.d.ts +5 -0
- package/dist/paint-editor/index.cjs +402 -258
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +197 -53
- package/dist/paint-editor/stamp-tip.d.cts +17 -0
- package/dist/paint-editor/stamp-tip.d.ts +17 -0
- package/dist/paint-editor/ui.d.cts +21 -1
- package/dist/paint-editor/ui.d.ts +21 -1
- package/dist/raster/index.cjs +2 -4
- package/dist/raster/index.js +6 -8
- package/dist/vector/brushstroke.d.cts +6 -0
- package/dist/vector/brushstroke.d.ts +6 -0
- package/dist/vector/controller.d.cts +11 -2
- package/dist/vector/controller.d.ts +11 -2
- package/dist/vector/index.cjs +990 -973
- package/dist/vector/index.js +28 -11
- package/package.json +1 -1
- package/skills/pixerate-brushes/SKILL.md +1 -1
- package/skills/pixerate-canvas/SKILL.md +3 -1
- package/skills/pixerate-vector/SKILL.md +2 -2
- package/dist/chunk-2VJAVXLI.js +0 -192
- package/dist/chunk-62Z5WLRA.js +0 -700
- package/dist/chunk-BOHDJJ2O.cjs +0 -192
- package/dist/chunk-NKGB64CW.cjs +0 -700
- package/dist/chunk-SS53NNZO.cjs +0 -1066
- package/dist/chunk-ZNA3IQZF.js +0 -1066
|
@@ -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;
|
|
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;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var _chunkSS53NNZOcjs = require('./chunk-SS53NNZO.cjs');
|
|
11
10
|
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _chunk3ZRNK3ROcjs = require('./chunk-3ZRNK3RO.cjs');
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
|
|
@@ -48,7 +50,7 @@ var _chunkA2IS7EHEcjs = require('./chunk-A2IS7EHE.cjs');
|
|
|
48
50
|
|
|
49
51
|
|
|
50
52
|
|
|
51
|
-
var
|
|
53
|
+
var _chunkPVJMTLPJcjs = require('./chunk-PVJMTLPJ.cjs');
|
|
52
54
|
|
|
53
55
|
|
|
54
56
|
|
|
@@ -106,7 +108,7 @@ var _chunkBROJYMWUcjs = require('./chunk-BROJYMWU.cjs');
|
|
|
106
108
|
|
|
107
109
|
|
|
108
110
|
|
|
109
|
-
var
|
|
111
|
+
var _chunk7AUQ2UJ3cjs = require('./chunk-7AUQ2UJ3.cjs');
|
|
110
112
|
|
|
111
113
|
|
|
112
114
|
|
|
@@ -117,6 +119,12 @@ var _chunkO3ZVZSNJcjs = require('./chunk-O3ZVZSNJ.cjs');
|
|
|
117
119
|
var _chunkGF2RBSDMcjs = require('./chunk-GF2RBSDM.cjs');
|
|
118
120
|
|
|
119
121
|
|
|
122
|
+
var _chunkA2IS7EHEcjs = require('./chunk-A2IS7EHE.cjs');
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
var _chunkFQPUF2W2cjs = require('./chunk-FQPUF2W2.cjs');
|
|
126
|
+
|
|
127
|
+
|
|
120
128
|
|
|
121
129
|
|
|
122
130
|
|
|
@@ -741,7 +749,7 @@ function layerMaskSelection(layer, width, height) {
|
|
|
741
749
|
const ox = layer.type === "pixel" ? layer.offset.x : 0;
|
|
742
750
|
const oy = layer.type === "pixel" ? layer.offset.y : 0;
|
|
743
751
|
const data = _chunk474IQG74cjs.readRegion.call(void 0, layer.mask.surface, { x: -ox, y: -oy, width, height });
|
|
744
|
-
return
|
|
752
|
+
return _chunk3ZRNK3ROcjs.createSelectionMask.call(void 0, width, height, new Uint8Array(data.buffer, data.byteOffset, data.length));
|
|
745
753
|
}
|
|
746
754
|
var MAX_SIDE = 1 << 15;
|
|
747
755
|
function normalizeLayerMask(raw) {
|
|
@@ -764,7 +772,7 @@ function normalizeLayerMask(raw) {
|
|
|
764
772
|
return out;
|
|
765
773
|
}
|
|
766
774
|
function layerMaskFromSelection(selection, props = {}) {
|
|
767
|
-
return normalizeLayerMask({ width: selection.width, height: selection.height, rle:
|
|
775
|
+
return normalizeLayerMask({ width: selection.width, height: selection.height, rle: _chunk3ZRNK3ROcjs.encodeSelectionRle.call(void 0, selection.data), ...props });
|
|
768
776
|
}
|
|
769
777
|
function updateLayerMaskProps(mask, props) {
|
|
770
778
|
return normalizeLayerMask({
|
|
@@ -793,7 +801,7 @@ function decodeLayerMask(mask) {
|
|
|
793
801
|
const key = `${mask.width}x${mask.height}:${mask.rle}`;
|
|
794
802
|
return lru(decoded, key, () => {
|
|
795
803
|
try {
|
|
796
|
-
return
|
|
804
|
+
return _chunk3ZRNK3ROcjs.createSelectionMask.call(void 0, mask.width, mask.height, _chunk3ZRNK3ROcjs.decodeSelectionRle.call(void 0, mask.rle, mask.width * mask.height));
|
|
797
805
|
} catch (e2) {
|
|
798
806
|
return null;
|
|
799
807
|
}
|
|
@@ -801,7 +809,7 @@ function decodeLayerMask(mask) {
|
|
|
801
809
|
}
|
|
802
810
|
function layerMaskKey(mask) {
|
|
803
811
|
if (!mask) return "";
|
|
804
|
-
return `${mask.width}x${mask.height}:${
|
|
812
|
+
return `${mask.width}x${mask.height}:${_chunk3ZRNK3ROcjs.hashMaskContent.call(void 0, mask.rle)}:${_nullishCoalesce(mask.density, () => ( 1))}:${_nullishCoalesce(mask.feather, () => ( 0))}:${mask.enabled !== false}`;
|
|
805
813
|
}
|
|
806
814
|
function layerMaskCoverage(mask) {
|
|
807
815
|
if (mask.enabled === false) return null;
|
|
@@ -1054,7 +1062,7 @@ function normalizeAdjustmentLayers(raw) {
|
|
|
1054
1062
|
return out;
|
|
1055
1063
|
}
|
|
1056
1064
|
function curveLutFromLevels(points) {
|
|
1057
|
-
return
|
|
1065
|
+
return _chunkPVJMTLPJcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
|
|
1058
1066
|
}
|
|
1059
1067
|
var toUnitLevels = (c) => ({
|
|
1060
1068
|
inBlack: c.inBlack / 255,
|
|
@@ -2250,7 +2258,7 @@ function newLayerId(prefix = "layer") {
|
|
|
2250
2258
|
return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
|
|
2251
2259
|
}
|
|
2252
2260
|
function pixelLayers(layers) {
|
|
2253
|
-
return
|
|
2261
|
+
return _chunkPVJMTLPJcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
|
|
2254
2262
|
}
|
|
2255
2263
|
function developFilter(layer) {
|
|
2256
2264
|
return _optionalChain([layer, 'access', _10 => _10.filters, 'optionalAccess', _11 => _11.find, 'call', _12 => _12((f) => f.kind === "develop")]);
|
|
@@ -2281,14 +2289,14 @@ function isRenderedLayer(layer) {
|
|
|
2281
2289
|
return layer.type === "smart" || layer.type === "shape" || layer.type === "type";
|
|
2282
2290
|
}
|
|
2283
2291
|
function shapeLayers(layers) {
|
|
2284
|
-
return
|
|
2292
|
+
return _chunkPVJMTLPJcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
|
|
2285
2293
|
}
|
|
2286
2294
|
function smartObjectLayers(layers) {
|
|
2287
|
-
return
|
|
2295
|
+
return _chunkPVJMTLPJcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
|
|
2288
2296
|
}
|
|
2289
2297
|
|
|
2290
2298
|
// src/image-editor/layers/shape.ts
|
|
2291
|
-
var SHAPE_RENDER_MARGIN =
|
|
2299
|
+
var SHAPE_RENDER_MARGIN = _chunkPVJMTLPJcjs.MAX_EFFECT_REACH;
|
|
2292
2300
|
var DEFAULT_MITER_LIMIT = 100;
|
|
2293
2301
|
var fail = (message) => {
|
|
2294
2302
|
throw new LayerOperationError(message);
|
|
@@ -2328,7 +2336,7 @@ function mapAnchor(a, f) {
|
|
|
2328
2336
|
return out;
|
|
2329
2337
|
}
|
|
2330
2338
|
function mapSubpaths(subpaths, f) {
|
|
2331
|
-
return
|
|
2339
|
+
return _chunk7AUQ2UJ3cjs.expandVectorCorners.call(void 0, subpaths).map((sp) => ({ closed: sp.closed, anchors: sp.anchors.map((a) => mapAnchor(a, f)) }));
|
|
2332
2340
|
}
|
|
2333
2341
|
function liveShapeSubpaths(live) {
|
|
2334
2342
|
let out;
|
|
@@ -2336,19 +2344,19 @@ function liveShapeSubpaths(live) {
|
|
|
2336
2344
|
case "rect": {
|
|
2337
2345
|
const x = Math.min(live.x, live.x + live.width);
|
|
2338
2346
|
const y = Math.min(live.y, live.y + live.height);
|
|
2339
|
-
const sp =
|
|
2347
|
+
const sp = _chunk7AUQ2UJ3cjs.rectSubpath.call(void 0, { x, y, width: Math.abs(live.width), height: Math.abs(live.height) });
|
|
2340
2348
|
const r = _nullishCoalesce(live.radii, () => ( [0, 0, 0, 0]));
|
|
2341
|
-
out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ?
|
|
2349
|
+
out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ? _chunk7AUQ2UJ3cjs.setAnchorCorner.call(void 0, a, r[i]) : a) }];
|
|
2342
2350
|
break;
|
|
2343
2351
|
}
|
|
2344
2352
|
case "ellipse":
|
|
2345
|
-
out = [
|
|
2353
|
+
out = [_chunk7AUQ2UJ3cjs.ellipseSubpath.call(void 0, normBox(live))];
|
|
2346
2354
|
break;
|
|
2347
2355
|
case "polygon":
|
|
2348
|
-
out = [
|
|
2356
|
+
out = [_chunk7AUQ2UJ3cjs.polygonSubpath.call(void 0, normBox(live), live.sides)];
|
|
2349
2357
|
break;
|
|
2350
2358
|
case "star":
|
|
2351
|
-
out = [
|
|
2359
|
+
out = [_chunk7AUQ2UJ3cjs.starSubpath.call(void 0, normBox(live), live.points, Math.max(0, Math.min(1, live.innerRatio)))];
|
|
2352
2360
|
break;
|
|
2353
2361
|
case "line": {
|
|
2354
2362
|
const a = { x: live.x1, y: live.y1 };
|
|
@@ -2371,7 +2379,7 @@ function liveShapeSubpaths(live) {
|
|
|
2371
2379
|
}
|
|
2372
2380
|
}
|
|
2373
2381
|
const m = live.transform;
|
|
2374
|
-
return m && !
|
|
2382
|
+
return m && !_chunk7AUQ2UJ3cjs.isIdentityMatrix.call(void 0, m) ? mapSubpaths(out, (p) => _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, p)) : out;
|
|
2375
2383
|
}
|
|
2376
2384
|
function normBox(b) {
|
|
2377
2385
|
return { x: Math.min(b.x, b.x + b.width), y: Math.min(b.y, b.y + b.height), width: Math.abs(b.width), height: Math.abs(b.height) };
|
|
@@ -2383,7 +2391,7 @@ var pathCache = /* @__PURE__ */ new WeakMap();
|
|
|
2383
2391
|
function componentPath(c) {
|
|
2384
2392
|
let p = pathCache.get(c.subpaths);
|
|
2385
2393
|
if (!p) {
|
|
2386
|
-
p =
|
|
2394
|
+
p = _chunk7AUQ2UJ3cjs.subpathsToBezier.call(void 0, c.subpaths);
|
|
2387
2395
|
pathCache.set(c.subpaths, p);
|
|
2388
2396
|
}
|
|
2389
2397
|
return p;
|
|
@@ -2508,11 +2516,11 @@ function componentsCoverage(components, rect, rule = "nonzero", inverted = false
|
|
|
2508
2516
|
function paintContext(env) {
|
|
2509
2517
|
const tiles = /* @__PURE__ */ new Map();
|
|
2510
2518
|
return {
|
|
2511
|
-
light:
|
|
2519
|
+
light: _chunkPVJMTLPJcjs.DEFAULT_GLOBAL_LIGHT,
|
|
2512
2520
|
pattern: (id) => {
|
|
2513
2521
|
if (tiles.has(id)) return tiles.get(id);
|
|
2514
|
-
const p = _nullishCoalesce(_optionalChain([env, 'access', _18 => _18.pattern, 'optionalCall', _19 => _19(id)]), () => (
|
|
2515
|
-
const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0,
|
|
2522
|
+
const p = _nullishCoalesce(_optionalChain([env, 'access', _18 => _18.pattern, 'optionalCall', _19 => _19(id)]), () => ( _chunkPVJMTLPJcjs.builtinPattern.call(void 0, id)));
|
|
2523
|
+
const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0, _chunkPVJMTLPJcjs.PatternTile)(p) : null;
|
|
2516
2524
|
tiles.set(id, t);
|
|
2517
2525
|
return t;
|
|
2518
2526
|
}
|
|
@@ -2543,9 +2551,9 @@ function renderShapeRect(layer, rect, env, ctx = paintContext(env)) {
|
|
|
2543
2551
|
if (!fCov && !sCov) return null;
|
|
2544
2552
|
const canvas = { x: 0, y: 0, width: env.width, height: env.height };
|
|
2545
2553
|
const anchor = { x: geo.frame.x, y: geo.frame.y };
|
|
2546
|
-
const fc = fCov ?
|
|
2554
|
+
const fc = fCov ? _chunkPVJMTLPJcjs.effectFillColors.call(void 0, layer.fill, rect, geo.frame, canvas, anchor, ctx) : null;
|
|
2547
2555
|
const fo = _nullishCoalesce(_optionalChain([layer, 'access', _20 => _20.fill, 'optionalAccess', _21 => _21.opacity]), () => ( 1));
|
|
2548
|
-
const sc = sCov ?
|
|
2556
|
+
const sc = sCov ? _chunkPVJMTLPJcjs.effectFillColors.call(void 0, layer.stroke.paint, rect, geo.frame, canvas, anchor, ctx) : null;
|
|
2549
2557
|
const so = _nullishCoalesce(_optionalChain([layer, 'access', _22 => _22.stroke, 'optionalAccess', _23 => _23.paint, 'access', _24 => _24.opacity]), () => ( 1));
|
|
2550
2558
|
const out = new Uint8ClampedArray(n * 4);
|
|
2551
2559
|
let any = false;
|
|
@@ -2638,9 +2646,9 @@ function normalizeShapePaint(v, path = "paint") {
|
|
|
2638
2646
|
offset: _nullishCoalesce(g.offset, () => ( { x: 0, y: 0 }))
|
|
2639
2647
|
};
|
|
2640
2648
|
try {
|
|
2641
|
-
|
|
2649
|
+
_chunkPVJMTLPJcjs.validateEffectGradient.call(void 0, gradient, `${path}.gradient`);
|
|
2642
2650
|
} catch (e) {
|
|
2643
|
-
if (e instanceof
|
|
2651
|
+
if (e instanceof _chunkPVJMTLPJcjs.LayerEffectError) fail(e.message);
|
|
2644
2652
|
throw e;
|
|
2645
2653
|
}
|
|
2646
2654
|
if (gradient.stops.length < 1) fail(`${path}.gradient.stops needs at least one { position, color }.`);
|
|
@@ -2710,7 +2718,7 @@ function matrixArg(v, path) {
|
|
|
2710
2718
|
if (!Array.isArray(v) || v.length !== 6 || !v.every(isNum)) fail(`${path} must be six numbers [a, b, c, d, e, f].`);
|
|
2711
2719
|
const m = v;
|
|
2712
2720
|
if (Math.abs(m[0] * m[3] - m[1] * m[2]) < 1e-12) fail(`${path} is singular.`);
|
|
2713
|
-
return
|
|
2721
|
+
return _chunk7AUQ2UJ3cjs.isIdentityMatrix.call(void 0, m) ? void 0 : [...m];
|
|
2714
2722
|
}
|
|
2715
2723
|
function normalizeLiveShape(v, path = "shape") {
|
|
2716
2724
|
if (!v || typeof v !== "object") return fail(`${path} must be an object with kind ${LIVE_SHAPE_KINDS.join(", ")}.`);
|
|
@@ -2771,7 +2779,7 @@ function normalizeSubpaths(v, path = "subpaths") {
|
|
|
2771
2779
|
if (typeof v === "string") {
|
|
2772
2780
|
let subs;
|
|
2773
2781
|
try {
|
|
2774
|
-
subs =
|
|
2782
|
+
subs = _chunk7AUQ2UJ3cjs.bezierToSubpaths.call(void 0, v);
|
|
2775
2783
|
} catch (e5) {
|
|
2776
2784
|
return fail(`${path}: could not read the SVG path data.`);
|
|
2777
2785
|
}
|
|
@@ -2852,20 +2860,20 @@ function updateShapeLayer(layers, id, change, env, action = "edit it") {
|
|
|
2852
2860
|
if (!("annotation" in patch)) delete next.annotation;
|
|
2853
2861
|
if (!next.components.length) fail("A shape needs at least one component; delete the layer instead.");
|
|
2854
2862
|
const rendered = rerenderShape(next, env);
|
|
2855
|
-
return { layers:
|
|
2863
|
+
return { layers: _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
|
|
2856
2864
|
}
|
|
2857
2865
|
function transformShapeComponents(components, f, affine) {
|
|
2858
2866
|
return components.map((c) => {
|
|
2859
2867
|
if (affine && c.live) {
|
|
2860
|
-
const live = { ...c.live, transform:
|
|
2861
|
-
if (
|
|
2868
|
+
const live = { ...c.live, transform: _chunk7AUQ2UJ3cjs.multiplyMatrices.call(void 0, _nullishCoalesce(c.live.transform, () => ( _chunk7AUQ2UJ3cjs.IDENTITY_MATRIX)), affine) };
|
|
2869
|
+
if (_chunk7AUQ2UJ3cjs.isIdentityMatrix.call(void 0, live.transform)) delete live.transform;
|
|
2862
2870
|
return { op: c.op, subpaths: liveShapeSubpaths(live), live };
|
|
2863
2871
|
}
|
|
2864
2872
|
return { op: c.op, subpaths: mapSubpaths(c.subpaths, f) };
|
|
2865
2873
|
});
|
|
2866
2874
|
}
|
|
2867
2875
|
function offsetShape(layer, dx, dy, env) {
|
|
2868
|
-
const m =
|
|
2876
|
+
const m = _chunk7AUQ2UJ3cjs.translateMatrix.call(void 0, dx, dy);
|
|
2869
2877
|
const next = { ...layer, components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), m) };
|
|
2870
2878
|
delete next.annotation;
|
|
2871
2879
|
return rerenderShape(next, env);
|
|
@@ -2873,7 +2881,7 @@ function offsetShape(layer, dx, dy, env) {
|
|
|
2873
2881
|
function mergeShapeComponents(components, fillRule = "nonzero") {
|
|
2874
2882
|
if (components.length < 2) return [...components];
|
|
2875
2883
|
const path = shapeOutline(components, fillRule);
|
|
2876
|
-
const subpaths =
|
|
2884
|
+
const subpaths = _chunk7AUQ2UJ3cjs.bezierToSubpaths.call(void 0, path);
|
|
2877
2885
|
if (!subpaths.length) fail("The components combine to nothing (the operations remove every area), so there is nothing to merge into.");
|
|
2878
2886
|
return [{ op: "combine", subpaths }];
|
|
2879
2887
|
}
|
|
@@ -2883,14 +2891,14 @@ function shapeAsPixelLayer(layer) {
|
|
|
2883
2891
|
}
|
|
2884
2892
|
function annotationPaint(color, opacity) {
|
|
2885
2893
|
const c = _chunkA2IS7EHEcjs.parseCssColor.call(void 0, color);
|
|
2886
|
-
if (!c || !
|
|
2894
|
+
if (!c || !_chunkPVJMTLPJcjs.parseEffectColor.call(void 0, c.hex)) return void 0;
|
|
2887
2895
|
const a = c.alpha * opacity;
|
|
2888
2896
|
return a !== 1 ? { type: "color", color: c.hex, opacity: a } : { type: "color", color: c.hex };
|
|
2889
2897
|
}
|
|
2890
2898
|
function shapeFromAnnotation(a) {
|
|
2891
2899
|
const opacity = _nullishCoalesce(a.opacity, () => ( 1));
|
|
2892
2900
|
const lineWidth = "strokeWidth" in a && a.strokeWidth > 0 ? a.strokeWidth : 1;
|
|
2893
|
-
const rotation = a.rotation ?
|
|
2901
|
+
const rotation = a.rotation ? _chunk7AUQ2UJ3cjs.rotateMatrix.call(void 0, a.rotation, { x: a.x, y: a.y }) : void 0;
|
|
2894
2902
|
const t = rotation ? { transform: rotation } : {};
|
|
2895
2903
|
const live = (l) => liveComponent(l);
|
|
2896
2904
|
switch (a.type) {
|
|
@@ -2933,7 +2941,7 @@ function shapeFromAnnotation(a) {
|
|
|
2933
2941
|
case "pen": {
|
|
2934
2942
|
const paint = annotationPaint(a.strokeColor, opacity);
|
|
2935
2943
|
if (!paint) return null;
|
|
2936
|
-
const pts = rotation ? a.points.map((p) =>
|
|
2944
|
+
const pts = rotation ? a.points.map((p) => _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, rotation, p)) : a.points;
|
|
2937
2945
|
const subpaths = pts.length > 1 ? [{ closed: false, anchors: pts.map((p) => ({ x: p.x, y: p.y })) }] : [];
|
|
2938
2946
|
return {
|
|
2939
2947
|
components: [{ op: "combine", subpaths }],
|
|
@@ -2966,7 +2974,7 @@ var JOIN_SIGMA = 2;
|
|
|
2966
2974
|
function vectorMaskSegments(components) {
|
|
2967
2975
|
const out = [];
|
|
2968
2976
|
components.forEach((c, ci) => c.subpaths.forEach((sp, si) => {
|
|
2969
|
-
for (let k = 0; k <
|
|
2977
|
+
for (let k = 0; k < _chunk7AUQ2UJ3cjs.subpathSegmentCount.call(void 0, sp); k++) out.push({ component: ci, subpath: si, segment: k });
|
|
2970
2978
|
}));
|
|
2971
2979
|
return out;
|
|
2972
2980
|
}
|
|
@@ -2974,7 +2982,7 @@ function validVectorMaskEdges(edges, components) {
|
|
|
2974
2982
|
if (!_optionalChain([edges, 'optionalAccess', _34 => _34.length])) return [];
|
|
2975
2983
|
return edges.filter((e) => {
|
|
2976
2984
|
const sp = _optionalChain([components, 'access', _35 => _35[e.component], 'optionalAccess', _36 => _36.subpaths, 'access', _37 => _37[e.subpath]]);
|
|
2977
|
-
return Boolean(sp) && e.segment >= 0 && e.segment <
|
|
2985
|
+
return Boolean(sp) && e.segment >= 0 && e.segment < _chunk7AUQ2UJ3cjs.subpathSegmentCount.call(void 0, sp);
|
|
2978
2986
|
});
|
|
2979
2987
|
}
|
|
2980
2988
|
function reach(e) {
|
|
@@ -2997,8 +3005,8 @@ function hybridVectorMaskCoverage(vm, hard, width, height, guide) {
|
|
|
2997
3005
|
const seedClass = [];
|
|
2998
3006
|
vm.components.forEach(
|
|
2999
3007
|
(c, ci) => c.subpaths.forEach((sp, si) => {
|
|
3000
|
-
for (let k = 0; k <
|
|
3001
|
-
const seg =
|
|
3008
|
+
for (let k = 0; k < _chunk7AUQ2UJ3cjs.subpathSegmentCount.call(void 0, sp); k++) {
|
|
3009
|
+
const seg = _chunk7AUQ2UJ3cjs.subpathSegment.call(void 0, sp, k);
|
|
3002
3010
|
let len = 0;
|
|
3003
3011
|
for (let i = 1; i < seg.length; i++) len += Math.hypot(seg[i][0] - seg[i - 1][0], seg[i][1] - seg[i - 1][1]);
|
|
3004
3012
|
const steps = Math.max(2, Math.ceil(len * 2));
|
|
@@ -3148,7 +3156,7 @@ function hybridVectorMaskCoverage(vm, hard, width, height, guide) {
|
|
|
3148
3156
|
const inner = _nullishCoalesce(e.inner, () => ( VECTOR_MASK_EDGE_DEFAULTS.inner));
|
|
3149
3157
|
const outer = _nullishCoalesce(e.outer, () => ( VECTOR_MASK_EDGE_DEFAULTS.outer));
|
|
3150
3158
|
const r = Math.max(2, Math.round((inner + outer) / 2));
|
|
3151
|
-
const q2 =
|
|
3159
|
+
const q2 = _chunk3ZRNK3ROcjs.guidedFilterColor.call(void 0, planes(), Ht, bw, bh, r);
|
|
3152
3160
|
cov = new Float32Array(m);
|
|
3153
3161
|
for (let y = 0; y < bh; y++) {
|
|
3154
3162
|
for (let x = 0; x < bw; x++) {
|
|
@@ -3322,18 +3330,18 @@ function userErrorMessage(err) {
|
|
|
3322
3330
|
return err instanceof Error ? err.message : String(err);
|
|
3323
3331
|
}
|
|
3324
3332
|
function isPaintableLayer(layer) {
|
|
3325
|
-
return layer.type === "pixel" && layer.visible && !
|
|
3333
|
+
return layer.type === "pixel" && layer.visible && !_chunkPVJMTLPJcjs.isLayerLocked.call(void 0, layer, "pixels");
|
|
3326
3334
|
}
|
|
3327
3335
|
function defaultActiveLayerId(layers) {
|
|
3328
|
-
const pixels =
|
|
3336
|
+
const pixels = _chunkPVJMTLPJcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
|
|
3329
3337
|
for (let i = pixels.length - 1; i >= 0; i--) if (isPaintableLayer(pixels[i])) return pixels[i].id;
|
|
3330
3338
|
return _nullishCoalesce(_optionalChain([pixels, 'access', _47 => _47[pixels.length - 1], 'optionalAccess', _48 => _48.id]), () => ( null));
|
|
3331
3339
|
}
|
|
3332
3340
|
function activeLayerAfterRemoval(prev, next, removedId) {
|
|
3333
|
-
const before =
|
|
3341
|
+
const before = _chunkPVJMTLPJcjs.flattenLayers.call(void 0, prev);
|
|
3334
3342
|
const at = before.findIndex((l) => l.id === removedId);
|
|
3335
3343
|
for (let i = at - 1; i >= 0; i--) {
|
|
3336
|
-
const loc =
|
|
3344
|
+
const loc = _chunkPVJMTLPJcjs.findLayer.call(void 0, next, before[i].id);
|
|
3337
3345
|
if (loc && isPaintableLayer(loc.layer)) return loc.layer.id;
|
|
3338
3346
|
}
|
|
3339
3347
|
return defaultActiveLayerId(next);
|
|
@@ -3342,47 +3350,47 @@ var fail2 = (message) => {
|
|
|
3342
3350
|
throw new LayerOperationError(message);
|
|
3343
3351
|
};
|
|
3344
3352
|
function requireLayer(layers, id) {
|
|
3345
|
-
const loc =
|
|
3353
|
+
const loc = _chunkPVJMTLPJcjs.findLayer.call(void 0, layers, id);
|
|
3346
3354
|
if (!loc) {
|
|
3347
|
-
const ids =
|
|
3355
|
+
const ids = _chunkPVJMTLPJcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
|
|
3348
3356
|
fail2(`Unknown layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "The document has no layers."} Call list_layers for ids.`);
|
|
3349
3357
|
}
|
|
3350
3358
|
return loc;
|
|
3351
3359
|
}
|
|
3352
3360
|
function requireUnlocked(layer, what, action) {
|
|
3353
|
-
if (
|
|
3354
|
-
if (what !== "all" &&
|
|
3361
|
+
if (_chunkPVJMTLPJcjs.isLayerLocked.call(void 0, layer, "all")) fail2(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
|
|
3362
|
+
if (what !== "all" && _chunkPVJMTLPJcjs.isLayerLocked.call(void 0, layer, what)) fail2(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
|
|
3355
3363
|
}
|
|
3356
3364
|
function placeLayer(layers, layer, placement = {}, defaultIndex) {
|
|
3357
3365
|
const given = [placement.aboveId, placement.belowId, placement.parentId].filter((v) => v !== void 0).length;
|
|
3358
3366
|
if (given > 1) fail2("Give only one of aboveId, belowId and parentId.");
|
|
3359
3367
|
if (placement.aboveId || placement.belowId) {
|
|
3360
3368
|
const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
|
|
3361
|
-
return
|
|
3369
|
+
return _chunkPVJMTLPJcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _49 => _49.parent, 'optionalAccess', _50 => _50.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
|
|
3362
3370
|
}
|
|
3363
3371
|
if (placement.parentId) {
|
|
3364
3372
|
const ref = requireLayer(layers, placement.parentId);
|
|
3365
3373
|
if (ref.layer.type !== "group") fail2(`Layer "${placement.parentId}" is not a group; parentId must be a group id.`);
|
|
3366
|
-
return
|
|
3374
|
+
return _chunkPVJMTLPJcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
|
|
3367
3375
|
}
|
|
3368
|
-
return
|
|
3376
|
+
return _chunkPVJMTLPJcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
|
|
3369
3377
|
}
|
|
3370
3378
|
function removeLayer(layers, id) {
|
|
3371
3379
|
const loc = requireLayer(layers, id);
|
|
3372
3380
|
requireUnlocked(loc.layer, "all", "delete it");
|
|
3373
|
-
return
|
|
3381
|
+
return _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => null);
|
|
3374
3382
|
}
|
|
3375
3383
|
function moveLayer(layers, id, placement) {
|
|
3376
3384
|
const loc = requireLayer(layers, id);
|
|
3377
3385
|
requireUnlocked(loc.layer, "all", "move it");
|
|
3378
3386
|
const target = _nullishCoalesce(_nullishCoalesce(placement.aboveId, () => ( placement.belowId)), () => ( placement.parentId));
|
|
3379
3387
|
if (target === id) fail2("A layer cannot be placed relative to itself.");
|
|
3380
|
-
if (target && loc.layer.type === "group" &&
|
|
3388
|
+
if (target && loc.layer.type === "group" && _chunkPVJMTLPJcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
|
|
3381
3389
|
fail2(`Group "${id}" cannot be moved into its own child "${target}".`);
|
|
3382
3390
|
}
|
|
3383
3391
|
if (target) requireLayer(layers, target);
|
|
3384
3392
|
if (!target && placement.index === void 0) fail2("Give aboveId, belowId, parentId or index.");
|
|
3385
|
-
const without =
|
|
3393
|
+
const without = _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => null);
|
|
3386
3394
|
return placeLayer(without, loc.layer, placement);
|
|
3387
3395
|
}
|
|
3388
3396
|
function withNewIds(layer) {
|
|
@@ -3401,7 +3409,7 @@ function duplicateLayer(layers, id, name) {
|
|
|
3401
3409
|
const copy = withNewIds(loc.layer);
|
|
3402
3410
|
copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
|
|
3403
3411
|
delete copy.locks;
|
|
3404
|
-
return { layers:
|
|
3412
|
+
return { layers: _chunkPVJMTLPJcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _53 => _53.parent, 'optionalAccess', _54 => _54.id]), () => ( null)), loc.index + 1), id: copy.id };
|
|
3405
3413
|
}
|
|
3406
3414
|
function setLayerProperties(layers, id, props) {
|
|
3407
3415
|
const loc = requireLayer(layers, id);
|
|
@@ -3448,7 +3456,7 @@ function setLayerProperties(layers, id, props) {
|
|
|
3448
3456
|
if (props.collapsed) g.collapsed = true;
|
|
3449
3457
|
else delete g.collapsed;
|
|
3450
3458
|
}
|
|
3451
|
-
return
|
|
3459
|
+
return _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
3452
3460
|
}
|
|
3453
3461
|
function groupLayers(layers, ids, name = "Group") {
|
|
3454
3462
|
if (!ids.length) fail2("Give at least one layer id to group.");
|
|
@@ -3477,17 +3485,17 @@ function groupLayers(layers, ids, name = "Group") {
|
|
|
3477
3485
|
group.children[0] = c;
|
|
3478
3486
|
}
|
|
3479
3487
|
let out = layers;
|
|
3480
|
-
for (const l of ordered) out =
|
|
3481
|
-
return { layers:
|
|
3488
|
+
for (const l of ordered) out = _chunkPVJMTLPJcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
|
|
3489
|
+
return { layers: _chunkPVJMTLPJcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
|
|
3482
3490
|
}
|
|
3483
3491
|
function ungroupLayer(layers, id) {
|
|
3484
3492
|
const loc = requireLayer(layers, id);
|
|
3485
3493
|
if (loc.layer.type !== "group") fail2(`Layer "${id}" is not a group.`);
|
|
3486
3494
|
requireUnlocked(loc.layer, "all", "ungroup it");
|
|
3487
3495
|
const group = loc.layer;
|
|
3488
|
-
let out =
|
|
3496
|
+
let out = _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => null);
|
|
3489
3497
|
group.children.forEach((c, i) => {
|
|
3490
|
-
out =
|
|
3498
|
+
out = _chunkPVJMTLPJcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _63 => _63.parent, 'optionalAccess', _64 => _64.id]), () => ( null)), loc.index + i);
|
|
3491
3499
|
});
|
|
3492
3500
|
return { layers: out, ids: group.children.map((c) => c.id) };
|
|
3493
3501
|
}
|
|
@@ -3502,12 +3510,12 @@ function offsetLayer(layers, id, offset) {
|
|
|
3502
3510
|
if (mask && mask.linked === false && !mask.source) {
|
|
3503
3511
|
next.mask = { ...mask, surface: _chunk474IQG74cjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
|
|
3504
3512
|
}
|
|
3505
|
-
return
|
|
3513
|
+
return _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => followLayerMove(next, next.offset.x - layer.offset.x, next.offset.y - layer.offset.y));
|
|
3506
3514
|
}
|
|
3507
3515
|
function setLayerMask(layers, id, mask) {
|
|
3508
3516
|
const loc = requireLayer(layers, id);
|
|
3509
3517
|
requireUnlocked(loc.layer, "all", "change its mask");
|
|
3510
|
-
return
|
|
3518
|
+
return _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, (l) => {
|
|
3511
3519
|
const next = { ...l };
|
|
3512
3520
|
if (mask) next.mask = mask;
|
|
3513
3521
|
else delete next.mask;
|
|
@@ -3546,7 +3554,7 @@ function requirePixelLayer(layers, id) {
|
|
|
3546
3554
|
function addLayerFilter(layers, id, filter) {
|
|
3547
3555
|
const layer = requirePixelLayer(layers, id);
|
|
3548
3556
|
if (_optionalChain([layer, 'access', _65 => _65.filters, 'optionalAccess', _66 => _66.some, 'call', _67 => _67((f) => f.kind === filter.kind)])) fail2(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
|
|
3549
|
-
return
|
|
3557
|
+
return _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
|
|
3550
3558
|
}
|
|
3551
3559
|
function updateLayerFilter(layers, id, filterId, changes) {
|
|
3552
3560
|
const layer = requirePixelLayer(layers, id);
|
|
@@ -3557,7 +3565,7 @@ function updateLayerFilter(layers, id, filterId, changes) {
|
|
|
3557
3565
|
const merged2 = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
|
|
3558
3566
|
const filters = [...layer.filters];
|
|
3559
3567
|
filters[i] = merged2;
|
|
3560
|
-
return
|
|
3568
|
+
return _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
|
|
3561
3569
|
}
|
|
3562
3570
|
function removeLayerFilter(layers, id, filterId) {
|
|
3563
3571
|
const layer = requirePixelLayer(layers, id);
|
|
@@ -3566,7 +3574,7 @@ function removeLayerFilter(layers, id, filterId) {
|
|
|
3566
3574
|
const next = { ...layer };
|
|
3567
3575
|
if (filters.length) next.filters = filters;
|
|
3568
3576
|
else delete next.filters;
|
|
3569
|
-
return
|
|
3577
|
+
return _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
3570
3578
|
}
|
|
3571
3579
|
function requireEffectLayer(layers, id, action) {
|
|
3572
3580
|
const layer = requireLayer(layers, id).layer;
|
|
@@ -3581,7 +3589,7 @@ function guard(fn) {
|
|
|
3581
3589
|
try {
|
|
3582
3590
|
return fn();
|
|
3583
3591
|
} catch (e) {
|
|
3584
|
-
if (e instanceof
|
|
3592
|
+
if (e instanceof _chunkPVJMTLPJcjs.LayerEffectError) fail2(e.message);
|
|
3585
3593
|
throw e;
|
|
3586
3594
|
}
|
|
3587
3595
|
}
|
|
@@ -3589,20 +3597,20 @@ function setLayerEffects(layers, id, effects) {
|
|
|
3589
3597
|
const layer = requireEffectLayer(layers, id, "change its effects");
|
|
3590
3598
|
const next = { ...layer };
|
|
3591
3599
|
if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
|
|
3592
|
-
guard(() =>
|
|
3600
|
+
guard(() => _chunkPVJMTLPJcjs.validateLayerEffects.call(void 0, effects));
|
|
3593
3601
|
next.effects = effects;
|
|
3594
3602
|
} else delete next.effects;
|
|
3595
|
-
return
|
|
3603
|
+
return _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
3596
3604
|
}
|
|
3597
3605
|
function addLayerEffect(layers, id, kind, params = {}, index) {
|
|
3598
|
-
if (!
|
|
3606
|
+
if (!_chunkPVJMTLPJcjs.isLayerEffectKind.call(void 0, kind)) fail2(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkPVJMTLPJcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
|
|
3599
3607
|
const layer = requireEffectLayer(layers, id, "add effects");
|
|
3600
3608
|
const current = layerEffectsOf(layer);
|
|
3601
3609
|
const ids = new Set(current.items.map((e) => e.id));
|
|
3602
|
-
let effectId =
|
|
3603
|
-
while (ids.has(effectId)) effectId =
|
|
3610
|
+
let effectId = _chunkPVJMTLPJcjs.newEffectId.call(void 0, );
|
|
3611
|
+
while (ids.has(effectId)) effectId = _chunkPVJMTLPJcjs.newEffectId.call(void 0, );
|
|
3604
3612
|
const { id: _ignored, kind: _kind, ...rest } = params;
|
|
3605
|
-
const effect = guard(() =>
|
|
3613
|
+
const effect = guard(() => _chunkPVJMTLPJcjs.mergeLayerEffect.call(void 0, _chunkPVJMTLPJcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
|
|
3606
3614
|
const items = [...current.items];
|
|
3607
3615
|
const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
|
|
3608
3616
|
items.splice(at, 0, effect);
|
|
@@ -3619,7 +3627,7 @@ function updateLayerEffect(layers, id, effectId, changes) {
|
|
|
3619
3627
|
const i = requireEffect(layer, effectId);
|
|
3620
3628
|
const current = layer.effects;
|
|
3621
3629
|
const items = [...current.items];
|
|
3622
|
-
items[i] = guard(() =>
|
|
3630
|
+
items[i] = guard(() => _chunkPVJMTLPJcjs.mergeLayerEffect.call(void 0, items[i], changes));
|
|
3623
3631
|
return setLayerEffects(layers, id, { ...current, items });
|
|
3624
3632
|
}
|
|
3625
3633
|
function removeLayerEffect(layers, id, effectId) {
|
|
@@ -3677,11 +3685,11 @@ function despillEdge(rgba, coverage, w, h, amount, radius = EDGE_COLOR_RADIUS) {
|
|
|
3677
3685
|
const n = w * h;
|
|
3678
3686
|
const out = new Float32Array(n);
|
|
3679
3687
|
for (let i = 0; i < n; i++) out[i] = coverage[i] <= 5 ? 1 : 0;
|
|
3680
|
-
const weight =
|
|
3688
|
+
const weight = _chunk3ZRNK3ROcjs.boxMean.call(void 0, out, w, h, radius);
|
|
3681
3689
|
const mean = [0, 1, 2].map((c) => {
|
|
3682
3690
|
const v = new Float32Array(n);
|
|
3683
3691
|
for (let i = 0; i < n; i++) v[i] = rgba[i * 4 + c] * out[i];
|
|
3684
|
-
return
|
|
3692
|
+
return _chunk3ZRNK3ROcjs.boxMean.call(void 0, v, w, h, radius);
|
|
3685
3693
|
});
|
|
3686
3694
|
const luma = (r, g, b) => 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
3687
3695
|
for (let i = 0; i < n; i++) {
|
|
@@ -3711,7 +3719,7 @@ function despillEdge(rgba, coverage, w, h, amount, radius = EDGE_COLOR_RADIUS) {
|
|
|
3711
3719
|
}
|
|
3712
3720
|
function applyEdgeUnmix(rgba, coverage, w, h, edge) {
|
|
3713
3721
|
const d = _nullishCoalesce(edge.decontaminate, () => ( 0));
|
|
3714
|
-
if (d > 0) rgba.set(
|
|
3722
|
+
if (d > 0) rgba.set(_chunk3ZRNK3ROcjs.decontaminateColors.call(void 0, rgba, coverage, w, h, d, EDGE_COLOR_RADIUS));
|
|
3715
3723
|
despillEdge(rgba, coverage, w, h, _nullishCoalesce(edge.despill, () => ( 0)));
|
|
3716
3724
|
}
|
|
3717
3725
|
|
|
@@ -3864,7 +3872,7 @@ var PHOTO_PROFILE = {
|
|
|
3864
3872
|
return v;
|
|
3865
3873
|
}
|
|
3866
3874
|
};
|
|
3867
|
-
var LayerCompositor = class extends
|
|
3875
|
+
var LayerCompositor = class extends _chunkPVJMTLPJcjs.RasterCompositor {
|
|
3868
3876
|
constructor(options = {}) {
|
|
3869
3877
|
super(PHOTO_PROFILE, options);
|
|
3870
3878
|
}
|
|
@@ -3880,7 +3888,7 @@ var LayerCompositor = class extends _chunkDPYAO5U6cjs.RasterCompositor {
|
|
|
3880
3888
|
}
|
|
3881
3889
|
};
|
|
3882
3890
|
function compositeDeep(layers, rect, sources, depth) {
|
|
3883
|
-
const deep = new (0,
|
|
3891
|
+
const deep = new (0, _chunkPVJMTLPJcjs.DeepCompositor)(new LayerCompositor(), PHOTO_PROFILE, {
|
|
3884
3892
|
applyFilterRunDeep: (run, acc, _r, masks) => applyAdjustmentLayersFloat(acc, run.map(adjustmentNodeAsLayer), masks),
|
|
3885
3893
|
pixelFiltersDeep: (l) => {
|
|
3886
3894
|
if (l.type !== "pixel" || hasEdgeUnmix(l.edge)) return null;
|
|
@@ -3896,9 +3904,9 @@ function compositeDeep(layers, rect, sources, depth) {
|
|
|
3896
3904
|
var fail3 = (message) => {
|
|
3897
3905
|
throw new LayerOperationError(message);
|
|
3898
3906
|
};
|
|
3899
|
-
var TEXT_RENDER_MARGIN =
|
|
3907
|
+
var TEXT_RENDER_MARGIN = _chunkPVJMTLPJcjs.MAX_EFFECT_REACH;
|
|
3900
3908
|
function textMatrix(layer) {
|
|
3901
|
-
return _nullishCoalesce(layer.transform, () => (
|
|
3909
|
+
return _nullishCoalesce(layer.transform, () => ( _chunk7AUQ2UJ3cjs.IDENTITY_MATRIX));
|
|
3902
3910
|
}
|
|
3903
3911
|
function rectCorners(r) {
|
|
3904
3912
|
return [
|
|
@@ -3909,7 +3917,7 @@ function rectCorners(r) {
|
|
|
3909
3917
|
];
|
|
3910
3918
|
}
|
|
3911
3919
|
function docRect(r, m) {
|
|
3912
|
-
const pts = rectCorners(r).map((p) =>
|
|
3920
|
+
const pts = rectCorners(r).map((p) => _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, p));
|
|
3913
3921
|
const x0 = Math.floor(Math.min(...pts.map((p) => p.x)));
|
|
3914
3922
|
const y0 = Math.floor(Math.min(...pts.map((p) => p.y)));
|
|
3915
3923
|
const x1 = Math.ceil(Math.max(...pts.map((p) => p.x)));
|
|
@@ -3929,7 +3937,7 @@ function inkBounds(layout) {
|
|
|
3929
3937
|
for (const f of l.fragments) {
|
|
3930
3938
|
const pad = f.style.fontSize * (l.matrix ? 1 : 0.5);
|
|
3931
3939
|
const w = f.carets[f.carets.length - 1];
|
|
3932
|
-
const r =
|
|
3940
|
+
const r = _chunk7AUQ2UJ3cjs.transformTextRect.call(void 0, l.matrix, { x: f.x - pad, y: l.baseline - l.ascent - pad + Math.min(0, f.y - l.baseline), width: w + 2 * pad, height: l.ascent + l.descent + 2 * pad + Math.abs(f.y - l.baseline) });
|
|
3933
3941
|
if (!b) b = r;
|
|
3934
3942
|
else {
|
|
3935
3943
|
const x0 = Math.min(b.x, r.x);
|
|
@@ -3942,14 +3950,14 @@ function inkBounds(layout) {
|
|
|
3942
3950
|
}
|
|
3943
3951
|
function textOutlines(layer, shaper) {
|
|
3944
3952
|
if (!shaper.outline) fail3(`The text shaper "${shaper.id}" cannot give glyph outlines; plug in an outline shaper (createOutlineTextShaper) to convert text to shapes.`);
|
|
3945
|
-
const layout =
|
|
3953
|
+
const layout = _chunk7AUQ2UJ3cjs.layoutText.call(void 0, layer, shaper);
|
|
3946
3954
|
const m = textMatrix(layer);
|
|
3947
3955
|
const out = [];
|
|
3948
3956
|
for (const l of layout.lines) {
|
|
3949
3957
|
for (const f of l.fragments) {
|
|
3950
|
-
let path =
|
|
3951
|
-
for (const r of
|
|
3952
|
-
out.push({ fragment: f, path:
|
|
3958
|
+
let path = _chunk7AUQ2UJ3cjs.textFragmentOutline.call(void 0, shaper, layer.text, f);
|
|
3959
|
+
for (const r of _chunk7AUQ2UJ3cjs.textDecorations.call(void 0, f, l)) path = [...path, ..._chunk7AUQ2UJ3cjs.textRectPath.call(void 0, r)];
|
|
3960
|
+
out.push({ fragment: f, path: _chunk7AUQ2UJ3cjs.isIdentityMatrix.call(void 0, m) ? path : _chunkGF2RBSDMcjs.transformBezierPath.call(void 0, path, m) });
|
|
3953
3961
|
}
|
|
3954
3962
|
}
|
|
3955
3963
|
return out;
|
|
@@ -4005,7 +4013,7 @@ function renderOnCanvas(layer, shaper, region, env) {
|
|
|
4005
4013
|
const canvas = env.createCanvas(region.width, region.height);
|
|
4006
4014
|
const ctx = canvas.getContext("2d");
|
|
4007
4015
|
if (!ctx || typeof ctx.getImageData !== "function") return null;
|
|
4008
|
-
const layout =
|
|
4016
|
+
const layout = _chunk7AUQ2UJ3cjs.layoutText.call(void 0, layer, shaper);
|
|
4009
4017
|
const m = textMatrix(layer);
|
|
4010
4018
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
4011
4019
|
ctx.clearRect(0, 0, region.width, region.height);
|
|
@@ -4015,8 +4023,8 @@ function renderOnCanvas(layer, shaper, region, env) {
|
|
|
4015
4023
|
const [r, g, b] = rgbOf(f.style.color);
|
|
4016
4024
|
ctx.fillStyle = `rgb(${r}, ${g}, ${b})`;
|
|
4017
4025
|
ctx.globalAlpha = _nullishCoalesce(f.style.opacity, () => ( 1));
|
|
4018
|
-
|
|
4019
|
-
for (const d of
|
|
4026
|
+
_chunk7AUQ2UJ3cjs.drawTextFragment.call(void 0, ctx, shaper, layer.text, f);
|
|
4027
|
+
for (const d of _chunk7AUQ2UJ3cjs.textDecorations.call(void 0, f, l)) ctx.fillRect(d.x, d.y, d.width, d.height);
|
|
4020
4028
|
}
|
|
4021
4029
|
}
|
|
4022
4030
|
ctx.globalAlpha = 1;
|
|
@@ -4027,7 +4035,7 @@ function renderOnCanvas(layer, shaper, region, env) {
|
|
|
4027
4035
|
function renderText(layer, env) {
|
|
4028
4036
|
const shaper = env.shaper;
|
|
4029
4037
|
if (!shaper || !shaper.outline && !shaper.draw) return null;
|
|
4030
|
-
const layout =
|
|
4038
|
+
const layout = _chunk7AUQ2UJ3cjs.layoutText.call(void 0, layer, shaper);
|
|
4031
4039
|
const ink = inkBounds(layout);
|
|
4032
4040
|
const clip = { x: -TEXT_RENDER_MARGIN, y: -TEXT_RENDER_MARGIN, width: env.width + 2 * TEXT_RENDER_MARGIN, height: env.height + 2 * TEXT_RENDER_MARGIN };
|
|
4033
4041
|
const region = ink ? intersect2(docRect(ink, textMatrix(layer)), clip) : null;
|
|
@@ -4128,7 +4136,7 @@ function patchParagraphStyle(base, patch, path = "paragraph") {
|
|
|
4128
4136
|
continue;
|
|
4129
4137
|
}
|
|
4130
4138
|
const value = k === "autoLeading" ? num(v, `${path}.${k}`, 0.1, 10) : num(v, `${path}.${k}`, -1e4, 1e4);
|
|
4131
|
-
if (k === "autoLeading" && value ===
|
|
4139
|
+
if (k === "autoLeading" && value === _chunk7AUQ2UJ3cjs.DEFAULT_AUTO_LEADING || k !== "autoLeading" && value === 0) delete o[k];
|
|
4132
4140
|
else o[k] = value;
|
|
4133
4141
|
} else fail3(`${path}.${k} is not a paragraph style field; use ${PARAGRAPH_STYLE_FIELDS.join(", ")}.`);
|
|
4134
4142
|
}
|
|
@@ -4169,15 +4177,15 @@ function createTypeLayer(init, env, id = newLayerId(), lenient = false) {
|
|
|
4169
4177
|
opacity: 1,
|
|
4170
4178
|
blend: "normal",
|
|
4171
4179
|
text: text3,
|
|
4172
|
-
runs:
|
|
4173
|
-
paragraphs:
|
|
4180
|
+
runs: _chunk7AUQ2UJ3cjs.fitRuns.call(void 0, init.runs, text3.length, _chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE),
|
|
4181
|
+
paragraphs: _chunk7AUQ2UJ3cjs.fitParagraphRuns.call(void 0, _nullishCoalesce(init.paragraphs, () => ( [{ length: text3.length, style: {} }])), text3),
|
|
4174
4182
|
frame: init.frame,
|
|
4175
4183
|
...init.orientation === "vertical" ? { orientation: "vertical" } : {},
|
|
4176
4184
|
surface: _chunk474IQG74cjs.emptySurface.call(void 0, 4),
|
|
4177
4185
|
offset: { x: 0, y: 0 }
|
|
4178
4186
|
};
|
|
4179
|
-
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _79 => _79.runs, 'access', _80 => _80[0], 'optionalAccess', _81 => _81.style]), () => (
|
|
4180
|
-
if (init.transform && !
|
|
4187
|
+
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _79 => _79.runs, 'access', _80 => _80[0], 'optionalAccess', _81 => _81.style]), () => ( _chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE)) }];
|
|
4188
|
+
if (init.transform && !_chunk7AUQ2UJ3cjs.isIdentityMatrix.call(void 0, init.transform)) layer.transform = init.transform;
|
|
4181
4189
|
if (lenient && !renderText(layer, env)) return { ...layer, rendering: "stored" };
|
|
4182
4190
|
return rerenderText(layer, env);
|
|
4183
4191
|
}
|
|
@@ -4188,24 +4196,24 @@ function updateTypeLayer(layers, id, change, env, action = "edit it") {
|
|
|
4188
4196
|
const next = { ...current, ...patch };
|
|
4189
4197
|
if (!("annotation" in patch)) delete next.annotation;
|
|
4190
4198
|
if (next.orientation !== "vertical") delete next.orientation;
|
|
4191
|
-
if ("text" in patch || "runs" in patch) next.runs =
|
|
4192
|
-
if (!next.runs.length) next.runs = [{ length: 0, style:
|
|
4193
|
-
if ("text" in patch || "paragraphs" in patch) next.paragraphs =
|
|
4199
|
+
if ("text" in patch || "runs" in patch) next.runs = _chunk7AUQ2UJ3cjs.fitRuns.call(void 0, next.runs, next.text.length, _nullishCoalesce(_optionalChain([current, 'access', _82 => _82.runs, 'access', _83 => _83[0], 'optionalAccess', _84 => _84.style]), () => ( _chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE)));
|
|
4200
|
+
if (!next.runs.length) next.runs = [{ length: 0, style: _chunk7AUQ2UJ3cjs.styleAt.call(void 0, current.runs, 0, _chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE) }];
|
|
4201
|
+
if ("text" in patch || "paragraphs" in patch) next.paragraphs = _chunk7AUQ2UJ3cjs.fitParagraphRuns.call(void 0, next.paragraphs, next.text);
|
|
4194
4202
|
const rendered = rerenderText(next, env);
|
|
4195
|
-
return { layers:
|
|
4203
|
+
return { layers: _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
|
|
4196
4204
|
}
|
|
4197
4205
|
function replaceTextRange(layer, start, end, insert) {
|
|
4198
4206
|
const text3 = layer.text.slice(0, start) + insert + layer.text.slice(end);
|
|
4199
|
-
const style =
|
|
4200
|
-
const runs =
|
|
4201
|
-
const pstyle =
|
|
4202
|
-
const paragraphs =
|
|
4203
|
-
return { text: text3, runs, paragraphs:
|
|
4207
|
+
const style = _chunk7AUQ2UJ3cjs.styleAt.call(void 0, layer.runs, start > 0 && start === layer.text.length ? start - 1 : start, _chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE);
|
|
4208
|
+
const runs = _chunk7AUQ2UJ3cjs.spliceRuns.call(void 0, layer.runs, start, end, insert.length, style);
|
|
4209
|
+
const pstyle = _chunk7AUQ2UJ3cjs.styleAt.call(void 0, layer.paragraphs, start, {});
|
|
4210
|
+
const paragraphs = _chunk7AUQ2UJ3cjs.spliceRuns.call(void 0, layer.paragraphs, start, end, insert.length, pstyle);
|
|
4211
|
+
return { text: text3, runs, paragraphs: _chunk7AUQ2UJ3cjs.fitParagraphRuns.call(void 0, paragraphs, text3) };
|
|
4204
4212
|
}
|
|
4205
4213
|
function transformTypeLayer(layer, m) {
|
|
4206
|
-
const t =
|
|
4214
|
+
const t = _chunk7AUQ2UJ3cjs.multiplyMatrices.call(void 0, textMatrix(layer), m);
|
|
4207
4215
|
const next = { ...layer };
|
|
4208
|
-
if (
|
|
4216
|
+
if (_chunk7AUQ2UJ3cjs.isIdentityMatrix.call(void 0, t)) delete next.transform;
|
|
4209
4217
|
else next.transform = t;
|
|
4210
4218
|
delete next.annotation;
|
|
4211
4219
|
return next;
|
|
@@ -4213,7 +4221,7 @@ function transformTypeLayer(layer, m) {
|
|
|
4213
4221
|
function typeFrame(layer, shaper) {
|
|
4214
4222
|
if (layer.frame.kind === "box") return { x: 0, y: 0, width: layer.frame.width, height: layer.frame.height };
|
|
4215
4223
|
if (!shaper) return fail3("Type layers need a text shaper to be measured; none is set here.");
|
|
4216
|
-
const b =
|
|
4224
|
+
const b = _chunk7AUQ2UJ3cjs.layoutText.call(void 0, layer, shaper).bounds;
|
|
4217
4225
|
return { x: b.x, y: b.y, width: Math.max(b.width, 1), height: Math.max(b.height, 1) };
|
|
4218
4226
|
}
|
|
4219
4227
|
function typeAsPixelLayer(layer) {
|
|
@@ -4221,7 +4229,7 @@ function typeAsPixelLayer(layer) {
|
|
|
4221
4229
|
return { ...rest, type: "pixel", surface: layer.surface, offset: { x: 0, y: 0 } };
|
|
4222
4230
|
}
|
|
4223
4231
|
function toTextSpace(layer, p) {
|
|
4224
|
-
return
|
|
4232
|
+
return _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, _chunk7AUQ2UJ3cjs.invertMatrix.call(void 0, textMatrix(layer)), p);
|
|
4225
4233
|
}
|
|
4226
4234
|
function typeFromAnnotation(a) {
|
|
4227
4235
|
if (a.type !== "text") return null;
|
|
@@ -4235,7 +4243,7 @@ function typeFromAnnotation(a) {
|
|
|
4235
4243
|
if (op !== 1) style.opacity = op;
|
|
4236
4244
|
const text3 = t.text.replace(/\r?\n|\r/g, " ");
|
|
4237
4245
|
const translate = [1, 0, 0, 1, t.x, t.y];
|
|
4238
|
-
const transform = t.rotation ?
|
|
4246
|
+
const transform = t.rotation ? _chunk7AUQ2UJ3cjs.multiplyMatrices.call(void 0, translate, _chunk7AUQ2UJ3cjs.rotateMatrix.call(void 0, t.rotation, { x: t.x, y: t.y })) : translate;
|
|
4239
4247
|
return { text: text3, runs: [{ length: text3.length, style }], frame: { kind: "point", origin: "top" }, transform };
|
|
4240
4248
|
}
|
|
4241
4249
|
function annotationOfType(layer) {
|
|
@@ -4283,7 +4291,7 @@ var legacyMaskMemo = /* @__PURE__ */ new WeakMap();
|
|
|
4283
4291
|
function rasterMaskFromLegacy(mask, width, height) {
|
|
4284
4292
|
const sel = decodeLayerMask(mask);
|
|
4285
4293
|
if (!sel) return null;
|
|
4286
|
-
const sized = sel.width === width && sel.height === height ? sel :
|
|
4294
|
+
const sized = sel.width === width && sel.height === height ? sel : _chunk3ZRNK3ROcjs.resizeSelection.call(void 0, sel, width, height);
|
|
4287
4295
|
const surface = _chunk474IQG74cjs.surfaceFromPixels.call(void 0, { width, height, data: sized.data }, 1, 0, 0, 0);
|
|
4288
4296
|
legacyMaskMemo.set(surface, { width: mask.width, height: mask.height, rle: mask.rle });
|
|
4289
4297
|
const out = { surface, defaultValue: 0 };
|
|
@@ -4304,7 +4312,7 @@ function legacyMaskOf(mask, width, height) {
|
|
|
4304
4312
|
let memo = legacyMaskMemo.get(mask.surface);
|
|
4305
4313
|
if (!memo) {
|
|
4306
4314
|
const data = _chunk474IQG74cjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width, height });
|
|
4307
|
-
memo = { width, height, rle:
|
|
4315
|
+
memo = { width, height, rle: _chunk3ZRNK3ROcjs.encodeSelectionRle.call(void 0, new Uint8Array(data.buffer, data.byteOffset, data.length)) };
|
|
4308
4316
|
legacyMaskMemo.set(mask.surface, memo);
|
|
4309
4317
|
}
|
|
4310
4318
|
return normalizeLayerMask({ ...memo, density: mask.density, feather: mask.feather, enabled: mask.enabled });
|
|
@@ -4547,6 +4555,312 @@ function isLegacyShape(stack) {
|
|
|
4547
4555
|
return true;
|
|
4548
4556
|
}
|
|
4549
4557
|
|
|
4558
|
+
// src/image-editor/selection/magnetic.ts
|
|
4559
|
+
var BLOCK = 64;
|
|
4560
|
+
var W_ZERO = 0.3;
|
|
4561
|
+
var W_GRADIENT = 0.4;
|
|
4562
|
+
var W_DIRECTION = 0.3;
|
|
4563
|
+
var EdgeMap = (_class = class {
|
|
4564
|
+
|
|
4565
|
+
|
|
4566
|
+
|
|
4567
|
+
|
|
4568
|
+
__init() {this.blocks = /* @__PURE__ */ new Map()}
|
|
4569
|
+
constructor(pixels, options = {}) {;_class.prototype.__init.call(this);
|
|
4570
|
+
const { width, height, data } = pixels;
|
|
4571
|
+
if (!(width >= 1 && height >= 1) || data.length < width * height * 4) throw new Error("Invalid pixel buffer for edge detection.");
|
|
4572
|
+
this.width = width;
|
|
4573
|
+
this.height = height;
|
|
4574
|
+
this.contrast = Math.min(1, Math.max(0, _nullishCoalesce(options.contrast, () => ( 0.1))));
|
|
4575
|
+
const luma = new Uint8Array(width * height);
|
|
4576
|
+
for (let i = 0, p = 0; i < luma.length; i++, p += 4) {
|
|
4577
|
+
const a = data[p + 3] / 255;
|
|
4578
|
+
const y = 0.299 * data[p] + 0.587 * data[p + 1] + 0.114 * data[p + 2];
|
|
4579
|
+
luma[i] = Math.round(y * a + 255 * (1 - a));
|
|
4580
|
+
}
|
|
4581
|
+
this.luma = luma;
|
|
4582
|
+
}
|
|
4583
|
+
/** Edge strength at (x, y) in whole pixels, 0..1 (0 outside the image or below the contrast). */
|
|
4584
|
+
strength(x, y) {
|
|
4585
|
+
if (x < 0 || y < 0 || x >= this.width || y >= this.height) return 0;
|
|
4586
|
+
const b = this.block(x, y);
|
|
4587
|
+
return b.strength[y % BLOCK * BLOCK + x % BLOCK];
|
|
4588
|
+
}
|
|
4589
|
+
block(x, y) {
|
|
4590
|
+
const bx = Math.floor(x / BLOCK);
|
|
4591
|
+
const by = Math.floor(y / BLOCK);
|
|
4592
|
+
const key = by * 65536 + bx;
|
|
4593
|
+
let b = this.blocks.get(key);
|
|
4594
|
+
if (!b) {
|
|
4595
|
+
b = this.computeBlock(bx * BLOCK, by * BLOCK);
|
|
4596
|
+
this.blocks.set(key, b);
|
|
4597
|
+
}
|
|
4598
|
+
return b;
|
|
4599
|
+
}
|
|
4600
|
+
computeBlock(x0, y0) {
|
|
4601
|
+
const { width: W, height: H, luma } = this;
|
|
4602
|
+
const M = 2;
|
|
4603
|
+
const S = BLOCK + 2 * M;
|
|
4604
|
+
const smooth = new Float32Array(S * S);
|
|
4605
|
+
const at = (x, y) => luma[Math.min(H - 1, Math.max(0, y)) * W + Math.min(W - 1, Math.max(0, x))];
|
|
4606
|
+
for (let j = 0; j < S; j++) {
|
|
4607
|
+
const y = y0 - M + j;
|
|
4608
|
+
for (let i = 0; i < S; i++) {
|
|
4609
|
+
const x = x0 - M + i;
|
|
4610
|
+
const v = at(x - 1, y - 1) + 2 * at(x, y - 1) + at(x + 1, y - 1) + 2 * at(x - 1, y) + 4 * at(x, y) + 2 * at(x + 1, y) + at(x - 1, y + 1) + 2 * at(x, y + 1) + at(x + 1, y + 1);
|
|
4611
|
+
smooth[j * S + i] = v / (16 * 255);
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
4614
|
+
const lap = new Float32Array(S * S);
|
|
4615
|
+
for (let j = 1; j < S - 1; j++) {
|
|
4616
|
+
for (let i = 1; i < S - 1; i++) {
|
|
4617
|
+
const k = j * S + i;
|
|
4618
|
+
lap[k] = smooth[k - 1] + smooth[k + 1] + smooth[k - S] + smooth[k + S] - 4 * smooth[k];
|
|
4619
|
+
}
|
|
4620
|
+
}
|
|
4621
|
+
const n = BLOCK * BLOCK;
|
|
4622
|
+
const strength = new Float32Array(n);
|
|
4623
|
+
const dirX = new Float32Array(n);
|
|
4624
|
+
const dirY = new Float32Array(n);
|
|
4625
|
+
const zero = new Uint8Array(n);
|
|
4626
|
+
const c = this.contrast;
|
|
4627
|
+
for (let j = 0; j < BLOCK; j++) {
|
|
4628
|
+
if (y0 + j >= H) break;
|
|
4629
|
+
for (let i = 0; i < BLOCK; i++) {
|
|
4630
|
+
if (x0 + i >= W) break;
|
|
4631
|
+
const k = (j + M) * S + (i + M);
|
|
4632
|
+
const gx = (smooth[k + 1] - smooth[k - 1]) / 2;
|
|
4633
|
+
const gy = (smooth[k + S] - smooth[k - S]) / 2;
|
|
4634
|
+
const g = Math.hypot(gx, gy);
|
|
4635
|
+
const e = Math.min(1, 2 * g);
|
|
4636
|
+
if (e < c || g === 0) continue;
|
|
4637
|
+
const o = j * BLOCK + i;
|
|
4638
|
+
strength[o] = e;
|
|
4639
|
+
dirX[o] = gy / g;
|
|
4640
|
+
dirY[o] = -gx / g;
|
|
4641
|
+
const l = lap[k];
|
|
4642
|
+
for (const d of [1, -1, S, -S]) {
|
|
4643
|
+
const m = lap[k + d];
|
|
4644
|
+
if (l > 0 && m < 0 || l < 0 && m > 0 || l === 0) {
|
|
4645
|
+
if (Math.abs(l) <= Math.abs(m)) {
|
|
4646
|
+
zero[o] = 1;
|
|
4647
|
+
break;
|
|
4648
|
+
}
|
|
4649
|
+
}
|
|
4650
|
+
}
|
|
4651
|
+
}
|
|
4652
|
+
}
|
|
4653
|
+
return { strength, dirX, dirY, zero };
|
|
4654
|
+
}
|
|
4655
|
+
/** Features of the pixel at (x, y), which must be inside the image. */
|
|
4656
|
+
features(x, y) {
|
|
4657
|
+
const b = this.block(x, y);
|
|
4658
|
+
const o = y % BLOCK * BLOCK + x % BLOCK;
|
|
4659
|
+
return { strength: b.strength[o], dirX: b.dirX[o], dirY: b.dirY[o], zero: b.zero[o] };
|
|
4660
|
+
}
|
|
4661
|
+
}, _class);
|
|
4662
|
+
var clampPixel = (v, max) => Math.min(max - 1, Math.max(0, Math.floor(v)));
|
|
4663
|
+
function snapToEdge(map, point2, width = 10) {
|
|
4664
|
+
const cx = clampPixel(point2.x, map.width);
|
|
4665
|
+
const cy = clampPixel(point2.y, map.height);
|
|
4666
|
+
const r = Math.max(0, Math.round(width));
|
|
4667
|
+
let best = 0;
|
|
4668
|
+
let bestD = Infinity;
|
|
4669
|
+
let bx = cx;
|
|
4670
|
+
let by = cy;
|
|
4671
|
+
for (let y = Math.max(0, cy - r); y <= Math.min(map.height - 1, cy + r); y++) {
|
|
4672
|
+
for (let x = Math.max(0, cx - r); x <= Math.min(map.width - 1, cx + r); x++) {
|
|
4673
|
+
const d = (x - cx) ** 2 + (y - cy) ** 2;
|
|
4674
|
+
if (d > r * r) continue;
|
|
4675
|
+
const s = map.strength(x, y);
|
|
4676
|
+
if (s > best + 0.02 || s > 0 && Math.abs(s - best) <= 0.02 && d < bestD) {
|
|
4677
|
+
if (s > best) best = s;
|
|
4678
|
+
bestD = d;
|
|
4679
|
+
bx = x;
|
|
4680
|
+
by = y;
|
|
4681
|
+
}
|
|
4682
|
+
}
|
|
4683
|
+
}
|
|
4684
|
+
return best > 0 ? { x: bx + 0.5, y: by + 0.5 } : point2;
|
|
4685
|
+
}
|
|
4686
|
+
var Heap = (_class2 = class {constructor() { _class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this); }
|
|
4687
|
+
__init2() {this.ids = new Int32Array(256)}
|
|
4688
|
+
__init3() {this.keys = new Float64Array(256)}
|
|
4689
|
+
__init4() {this.size = 0}
|
|
4690
|
+
push(id, key) {
|
|
4691
|
+
if (this.size === this.ids.length) {
|
|
4692
|
+
const ids = new Int32Array(this.size * 2);
|
|
4693
|
+
ids.set(this.ids);
|
|
4694
|
+
const keys = new Float64Array(this.size * 2);
|
|
4695
|
+
keys.set(this.keys);
|
|
4696
|
+
this.ids = ids;
|
|
4697
|
+
this.keys = keys;
|
|
4698
|
+
}
|
|
4699
|
+
let i = this.size++;
|
|
4700
|
+
while (i > 0) {
|
|
4701
|
+
const p = i - 1 >> 1;
|
|
4702
|
+
if (this.keys[p] <= key) break;
|
|
4703
|
+
this.ids[i] = this.ids[p];
|
|
4704
|
+
this.keys[i] = this.keys[p];
|
|
4705
|
+
i = p;
|
|
4706
|
+
}
|
|
4707
|
+
this.ids[i] = id;
|
|
4708
|
+
this.keys[i] = key;
|
|
4709
|
+
}
|
|
4710
|
+
/** Removes the cheapest entry; read it from `topId` / `topKey` first. */
|
|
4711
|
+
pop() {
|
|
4712
|
+
const n = --this.size;
|
|
4713
|
+
const id = this.ids[n];
|
|
4714
|
+
const key = this.keys[n];
|
|
4715
|
+
let i = 0;
|
|
4716
|
+
for (; ; ) {
|
|
4717
|
+
let c = 2 * i + 1;
|
|
4718
|
+
if (c >= n) break;
|
|
4719
|
+
if (c + 1 < n && this.keys[c + 1] < this.keys[c]) c++;
|
|
4720
|
+
if (this.keys[c] >= key) break;
|
|
4721
|
+
this.ids[i] = this.ids[c];
|
|
4722
|
+
this.keys[i] = this.keys[c];
|
|
4723
|
+
i = c;
|
|
4724
|
+
}
|
|
4725
|
+
this.ids[i] = id;
|
|
4726
|
+
this.keys[i] = key;
|
|
4727
|
+
}
|
|
4728
|
+
get topId() {
|
|
4729
|
+
return this.ids[0];
|
|
4730
|
+
}
|
|
4731
|
+
get topKey() {
|
|
4732
|
+
return this.keys[0];
|
|
4733
|
+
}
|
|
4734
|
+
}, _class2);
|
|
4735
|
+
var NEIGHBOURS = [
|
|
4736
|
+
[1, 0],
|
|
4737
|
+
[-1, 0],
|
|
4738
|
+
[0, 1],
|
|
4739
|
+
[0, -1],
|
|
4740
|
+
[1, 1],
|
|
4741
|
+
[1, -1],
|
|
4742
|
+
[-1, 1],
|
|
4743
|
+
[-1, -1]
|
|
4744
|
+
];
|
|
4745
|
+
function liveWire(map, from, to, band) {
|
|
4746
|
+
const ax = clampPixel(from.x, map.width);
|
|
4747
|
+
const ay = clampPixel(from.y, map.height);
|
|
4748
|
+
const bx = clampPixel(to.x, map.width);
|
|
4749
|
+
const by = clampPixel(to.y, map.height);
|
|
4750
|
+
if (ax === bx && ay === by) return [{ x: ax + 0.5, y: ay + 0.5 }];
|
|
4751
|
+
const len = Math.hypot(bx - ax, by - ay);
|
|
4752
|
+
const half = Math.max(2, _nullishCoalesce(band, () => ( Math.max(16, len / 4))));
|
|
4753
|
+
const rx0 = Math.max(0, Math.floor(Math.min(ax, bx) - half));
|
|
4754
|
+
const ry0 = Math.max(0, Math.floor(Math.min(ay, by) - half));
|
|
4755
|
+
const rx1 = Math.min(map.width - 1, Math.ceil(Math.max(ax, bx) + half));
|
|
4756
|
+
const ry1 = Math.min(map.height - 1, Math.ceil(Math.max(ay, by) + half));
|
|
4757
|
+
const w = rx1 - rx0 + 1;
|
|
4758
|
+
const h = ry1 - ry0 + 1;
|
|
4759
|
+
const n = w * h;
|
|
4760
|
+
const strength = new Float32Array(n);
|
|
4761
|
+
const dirX = new Float32Array(n);
|
|
4762
|
+
const dirY = new Float32Array(n);
|
|
4763
|
+
const zero = new Uint8Array(n);
|
|
4764
|
+
const inside = new Uint8Array(n);
|
|
4765
|
+
let maxStrength = 0;
|
|
4766
|
+
const ux = (bx - ax) / len;
|
|
4767
|
+
const uy = (by - ay) / len;
|
|
4768
|
+
for (let y = 0; y < h; y++) {
|
|
4769
|
+
for (let x = 0; x < w; x++) {
|
|
4770
|
+
const px2 = rx0 + x - ax;
|
|
4771
|
+
const py = ry0 + y - ay;
|
|
4772
|
+
const t = Math.min(len, Math.max(0, px2 * ux + py * uy));
|
|
4773
|
+
if (Math.hypot(px2 - t * ux, py - t * uy) > half) continue;
|
|
4774
|
+
const i = y * w + x;
|
|
4775
|
+
inside[i] = 1;
|
|
4776
|
+
const f = map.features(rx0 + x, ry0 + y);
|
|
4777
|
+
strength[i] = f.strength;
|
|
4778
|
+
dirX[i] = f.dirX;
|
|
4779
|
+
dirY[i] = f.dirY;
|
|
4780
|
+
zero[i] = f.zero;
|
|
4781
|
+
if (f.strength > maxStrength) maxStrength = f.strength;
|
|
4782
|
+
}
|
|
4783
|
+
}
|
|
4784
|
+
const scale = maxStrength > 0 ? 1 / maxStrength : 0;
|
|
4785
|
+
const dist = new Float64Array(n).fill(Infinity);
|
|
4786
|
+
const prev = new Int32Array(n).fill(-1);
|
|
4787
|
+
const done = new Uint8Array(n);
|
|
4788
|
+
const start = (ay - ry0) * w + (ax - rx0);
|
|
4789
|
+
const goal = (by - ry0) * w + (bx - rx0);
|
|
4790
|
+
dist[start] = 0;
|
|
4791
|
+
const heap = new Heap();
|
|
4792
|
+
heap.push(start, 0);
|
|
4793
|
+
while (heap.size) {
|
|
4794
|
+
const p = heap.topId;
|
|
4795
|
+
const d = heap.topKey;
|
|
4796
|
+
heap.pop();
|
|
4797
|
+
if (done[p] || d > dist[p]) continue;
|
|
4798
|
+
done[p] = 1;
|
|
4799
|
+
if (p === goal) break;
|
|
4800
|
+
const x = p % w;
|
|
4801
|
+
const y = (p - x) / w;
|
|
4802
|
+
for (const [dx, dy] of NEIGHBOURS) {
|
|
4803
|
+
const qx = x + dx;
|
|
4804
|
+
const qy = y + dy;
|
|
4805
|
+
if (qx < 0 || qy < 0 || qx >= w || qy >= h) continue;
|
|
4806
|
+
const q2 = qy * w + qx;
|
|
4807
|
+
if (!inside[q2] || done[q2]) continue;
|
|
4808
|
+
const step = dx && dy ? Math.SQRT2 : 1;
|
|
4809
|
+
const lx = dx / step;
|
|
4810
|
+
const ly = dy / step;
|
|
4811
|
+
const dp = Math.min(1, Math.abs(dirX[p] * lx + dirY[p] * ly));
|
|
4812
|
+
const dq = Math.min(1, Math.abs(dirX[q2] * lx + dirY[q2] * ly));
|
|
4813
|
+
const fD = (Math.acos(dp) + Math.acos(dq)) / Math.PI;
|
|
4814
|
+
const fG = 1 - strength[q2] * scale;
|
|
4815
|
+
const fZ = 1 - zero[q2];
|
|
4816
|
+
const cost = (W_ZERO * fZ + W_GRADIENT * fG + W_DIRECTION * fD + 0.01) * step;
|
|
4817
|
+
const nd = d + cost;
|
|
4818
|
+
if (nd < dist[q2]) {
|
|
4819
|
+
dist[q2] = nd;
|
|
4820
|
+
prev[q2] = p;
|
|
4821
|
+
heap.push(q2, nd);
|
|
4822
|
+
}
|
|
4823
|
+
}
|
|
4824
|
+
}
|
|
4825
|
+
if (prev[goal] < 0) return [{ x: ax + 0.5, y: ay + 0.5 }, { x: bx + 0.5, y: by + 0.5 }];
|
|
4826
|
+
const path = [];
|
|
4827
|
+
for (let p = goal; p >= 0; p = prev[p]) {
|
|
4828
|
+
const x = p % w;
|
|
4829
|
+
path.push({ x: rx0 + x + 0.5, y: ry0 + (p - x) / w + 0.5 });
|
|
4830
|
+
}
|
|
4831
|
+
return path.reverse();
|
|
4832
|
+
}
|
|
4833
|
+
function simplifyPixelPath(points) {
|
|
4834
|
+
if (points.length < 3) return points.slice();
|
|
4835
|
+
const out = [points[0]];
|
|
4836
|
+
for (let i = 1; i < points.length - 1; i++) {
|
|
4837
|
+
const a = out[out.length - 1];
|
|
4838
|
+
const b = points[i];
|
|
4839
|
+
const c = points[i + 1];
|
|
4840
|
+
const cross = (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
|
4841
|
+
if (Math.abs(cross) > 1e-9) out.push(b);
|
|
4842
|
+
}
|
|
4843
|
+
out.push(points[points.length - 1]);
|
|
4844
|
+
return out;
|
|
4845
|
+
}
|
|
4846
|
+
function snapPolygonToEdges(pixels, points, options = {}) {
|
|
4847
|
+
const map = pixels instanceof EdgeMap ? pixels : new EdgeMap(pixels, options);
|
|
4848
|
+
const width = _nullishCoalesce(options.width, () => ( 10));
|
|
4849
|
+
const snapped = points.map((p) => snapToEdge(map, p, width));
|
|
4850
|
+
const out = [];
|
|
4851
|
+
for (let i = 0; i < snapped.length; i++) {
|
|
4852
|
+
const a = snapped[i];
|
|
4853
|
+
const b = snapped[(i + 1) % snapped.length];
|
|
4854
|
+
const seg = liveWire(map, a, b, Math.max(2 * width, 16, Math.hypot(b.x - a.x, b.y - a.y) / 4));
|
|
4855
|
+
out.push(...seg.slice(0, -1));
|
|
4856
|
+
}
|
|
4857
|
+
return simplifyPixelPath(out);
|
|
4858
|
+
}
|
|
4859
|
+
function magneticAnchorSpacing(frequency = 57) {
|
|
4860
|
+
const f = Math.min(100, Math.max(0, frequency));
|
|
4861
|
+
return 8 + (100 - f);
|
|
4862
|
+
}
|
|
4863
|
+
|
|
4550
4864
|
// src/image-editor/transform.ts
|
|
4551
4865
|
var FREE_TRANSFORM_MODES = ["scale", "rotate", "skew", "distort", "perspective", "warp"];
|
|
4552
4866
|
var TRANSFORM_ANCHORS = ["top-left", "top", "top-right", "left", "center", "right", "bottom-left", "bottom", "bottom-right"];
|
|
@@ -4569,7 +4883,7 @@ function identityTransform(box2) {
|
|
|
4569
4883
|
}
|
|
4570
4884
|
function cornersFromMatrix(box2, m) {
|
|
4571
4885
|
const q2 = _chunkQT26RHKKcjs.boxQuad.call(void 0, box2);
|
|
4572
|
-
return [
|
|
4886
|
+
return [_chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, q2[0]), _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, q2[1]), _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, q2[2]), _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, q2[3])];
|
|
4573
4887
|
}
|
|
4574
4888
|
function matrixFromCorners(box2, corners, eps = 1e-6) {
|
|
4575
4889
|
const [tl, tr, br, bl] = corners;
|
|
@@ -4586,7 +4900,7 @@ function transformHomography(geometry) {
|
|
|
4586
4900
|
function hasWarp(geometry) {
|
|
4587
4901
|
const w = geometry.warp;
|
|
4588
4902
|
if (!w) return false;
|
|
4589
|
-
const id =
|
|
4903
|
+
const id = _chunk7AUQ2UJ3cjs.identityWarpMesh.call(void 0, geometry.box, w.us.length - 1, w.vs.length - 1);
|
|
4590
4904
|
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;
|
|
4591
4905
|
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);
|
|
4592
4906
|
}
|
|
@@ -4601,7 +4915,7 @@ function transformMap(geometry) {
|
|
|
4601
4915
|
const { box: box2 } = geometry;
|
|
4602
4916
|
const warp = hasWarp(geometry) ? geometry.warp : null;
|
|
4603
4917
|
if (!warp) return (p) => _chunkQT26RHKKcjs.applyHomography.call(void 0, h, p);
|
|
4604
|
-
return (p) => _chunkQT26RHKKcjs.applyHomography.call(void 0, h,
|
|
4918
|
+
return (p) => _chunkQT26RHKKcjs.applyHomography.call(void 0, h, _chunk7AUQ2UJ3cjs.evalWarpMesh.call(void 0, warp, (p.x - box2.x) / box2.width, (p.y - box2.y) / box2.height));
|
|
4605
4919
|
}
|
|
4606
4920
|
function transformedPoint(geometry, fx, fy) {
|
|
4607
4921
|
const f = transformMap(geometry);
|
|
@@ -4645,8 +4959,8 @@ function matrixFromParams(box2, params) {
|
|
|
4645
4959
|
const tx = Math.tan((_nullishCoalesce(params.skewX, () => ( 0))) * Math.PI / 180);
|
|
4646
4960
|
const ty = Math.tan((_nullishCoalesce(params.skewY, () => ( 0))) * Math.PI / 180);
|
|
4647
4961
|
const ref = referencePoint(box2, params.reference);
|
|
4648
|
-
const linear =
|
|
4649
|
-
return
|
|
4962
|
+
const linear = _chunk7AUQ2UJ3cjs.multiplyMatrices.call(void 0, _chunk7AUQ2UJ3cjs.multiplyMatrices.call(void 0, [1, ty, tx, 1, 0, 0], [sx, 0, 0, sy, 0, 0]), _chunk7AUQ2UJ3cjs.rotateMatrix.call(void 0, _nullishCoalesce(params.rotate, () => ( 0))));
|
|
4963
|
+
return _chunk7AUQ2UJ3cjs.multiplyMatrices.call(void 0, _chunk7AUQ2UJ3cjs.matrixAbout.call(void 0, linear, ref), _chunk7AUQ2UJ3cjs.translateMatrix.call(void 0, _nullishCoalesce(params.dx, () => ( 0)), _nullishCoalesce(params.dy, () => ( 0))));
|
|
4650
4964
|
}
|
|
4651
4965
|
function describeTransform(geometry, reference = "center") {
|
|
4652
4966
|
const m = hasWarp(geometry) ? null : matrixFromCorners(geometry.box, geometry.corners);
|
|
@@ -4663,7 +4977,7 @@ function describeTransform(geometry, reference = "center") {
|
|
|
4663
4977
|
const shear = sxAbs ? (a * c + b * d) / sxAbs : 0;
|
|
4664
4978
|
const sy = sxAbs ? (a * d - b * c) / sxAbs : 0;
|
|
4665
4979
|
const skew = sxAbs ? Math.atan(shear / sxAbs) * 180 / Math.PI : 0;
|
|
4666
|
-
const at =
|
|
4980
|
+
const at = _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, ref);
|
|
4667
4981
|
const clean = (v) => Math.abs(v) < 1e-9 ? 0 : v;
|
|
4668
4982
|
return {
|
|
4669
4983
|
affine: true,
|
|
@@ -4681,24 +4995,24 @@ function applyParams(geometry, params) {
|
|
|
4681
4995
|
const ref = params.reference && typeof params.reference === "object" ? params.reference : anchorPoint(geometry, _nullishCoalesce(params.reference, () => ( "center")));
|
|
4682
4996
|
const m = matrixFromParams({ x: ref.x, y: ref.y, width: 0, height: 0 }, { ...params, reference: ref });
|
|
4683
4997
|
const c = geometry.corners;
|
|
4684
|
-
return [
|
|
4998
|
+
return [_chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, c[0]), _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, c[1]), _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, c[2]), _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, c[3])];
|
|
4685
4999
|
}
|
|
4686
5000
|
function flipCorners(geometry, axis) {
|
|
4687
5001
|
const c = anchorPoint(geometry, "center");
|
|
4688
5002
|
const m = axis === "horizontal" ? [-1, 0, 0, 1, 2 * c.x, 0] : [1, 0, 0, -1, 0, 2 * c.y];
|
|
4689
5003
|
const q2 = geometry.corners;
|
|
4690
|
-
return [
|
|
5004
|
+
return [_chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, q2[0]), _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, q2[1]), _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, q2[2]), _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, m, q2[3])];
|
|
4691
5005
|
}
|
|
4692
5006
|
function boxPointOf(geometry, p) {
|
|
4693
5007
|
const m = matrixFromCorners(geometry.box, geometry.corners);
|
|
4694
|
-
if (m) return
|
|
5008
|
+
if (m) return _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, _chunk7AUQ2UJ3cjs.invertMatrix.call(void 0, m), p);
|
|
4695
5009
|
return null;
|
|
4696
5010
|
}
|
|
4697
5011
|
function presetWarp(box2, preset) {
|
|
4698
|
-
return
|
|
5012
|
+
return _chunk7AUQ2UJ3cjs.warpPresetMesh.call(void 0, preset, box2);
|
|
4699
5013
|
}
|
|
4700
5014
|
function isValidWarp(mesh) {
|
|
4701
|
-
return
|
|
5015
|
+
return _chunk7AUQ2UJ3cjs.isValidWarpMesh.call(void 0, mesh);
|
|
4702
5016
|
}
|
|
4703
5017
|
function geometryHomography(geometry) {
|
|
4704
5018
|
const m = matrixFromCorners(geometry.box, geometry.corners);
|
|
@@ -4709,7 +5023,7 @@ function geometryHomography(geometry) {
|
|
|
4709
5023
|
var fail4 = (message) => {
|
|
4710
5024
|
throw new LayerOperationError(message);
|
|
4711
5025
|
};
|
|
4712
|
-
var SMART_RENDER_MARGIN =
|
|
5026
|
+
var SMART_RENDER_MARGIN = _chunkPVJMTLPJcjs.MAX_EFFECT_REACH;
|
|
4713
5027
|
var incompleteSurfaces = /* @__PURE__ */ new WeakSet();
|
|
4714
5028
|
var isSmartSurfaceIncomplete = (surface) => incompleteSurfaces.has(surface);
|
|
4715
5029
|
var surfaceIds = /* @__PURE__ */ new WeakMap();
|
|
@@ -4825,7 +5139,7 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
4825
5139
|
k = step;
|
|
4826
5140
|
let r = _optionalChain([options, 'access', _101 => _101.reduced, 'optionalAccess', _102 => _102.get, 'call', _103 => _103(k)]);
|
|
4827
5141
|
if (!r) {
|
|
4828
|
-
r =
|
|
5142
|
+
r = _chunkPVJMTLPJcjs.reduceSurface.call(void 0, src, k);
|
|
4829
5143
|
_optionalChain([options, 'access', _104 => _104.reduced, 'optionalAccess', _105 => _105.set, 'call', _106 => _106(k, r)]);
|
|
4830
5144
|
}
|
|
4831
5145
|
source = r;
|
|
@@ -4835,15 +5149,15 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
4835
5149
|
if (hasWarp(g)) {
|
|
4836
5150
|
const f = transformMap(g);
|
|
4837
5151
|
if (!f) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
|
|
4838
|
-
out =
|
|
5152
|
+
out = _chunkPVJMTLPJcjs.warpSurface.call(void 0, source, (p) => f({ x: p.x * k, y: p.y * k }), { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
|
|
4839
5153
|
} else {
|
|
4840
5154
|
const h = transformHomography(g);
|
|
4841
5155
|
if (!h) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
|
|
4842
5156
|
const hk = _chunkQT26RHKKcjs.multiplyHomographies.call(void 0, [k, 0, 0, 0, k, 0, 0, 0, 1], h);
|
|
4843
|
-
out =
|
|
5157
|
+
out = _chunkPVJMTLPJcjs.transformSurface.call(void 0, source, hk, { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
|
|
4844
5158
|
}
|
|
4845
5159
|
} catch (e) {
|
|
4846
|
-
if (e instanceof
|
|
5160
|
+
if (e instanceof _chunkPVJMTLPJcjs.TransformTooLargeError) fail4(e.message);
|
|
4847
5161
|
throw e;
|
|
4848
5162
|
}
|
|
4849
5163
|
}
|
|
@@ -4920,7 +5234,7 @@ function applySmartFilters(placed, stack, canvas) {
|
|
|
4920
5234
|
if (f.opacity >= 1) acc = out2;
|
|
4921
5235
|
else lerpInto(acc, out2, f.opacity, null);
|
|
4922
5236
|
} else {
|
|
4923
|
-
|
|
5237
|
+
_chunkPVJMTLPJcjs.blendTile.call(void 0, acc, out2, f.blend, f.opacity, null);
|
|
4924
5238
|
}
|
|
4925
5239
|
}
|
|
4926
5240
|
entry = { key, base, filtered: acc };
|
|
@@ -4977,11 +5291,11 @@ function normalizePlacement(raw, contents) {
|
|
|
4977
5291
|
}
|
|
4978
5292
|
const out = { corners: c.map((p) => ({ x: p.x, y: p.y })) };
|
|
4979
5293
|
if (raw.warp) {
|
|
4980
|
-
if (!
|
|
5294
|
+
if (!_chunk7AUQ2UJ3cjs.isValidWarpMesh.call(void 0, raw.warp)) fail4("warp must be a mesh with us and vs (knots from 0 to 1, increasing) and (3\xB7columns + 1) \xD7 (3\xB7rows + 1) finite points in contents pixels.");
|
|
4981
5295
|
out.warp = { us: [...raw.warp.us], vs: [...raw.warp.vs], points: raw.warp.points.map((p) => ({ x: p.x, y: p.y })) };
|
|
4982
5296
|
}
|
|
4983
5297
|
if (raw.interpolation !== void 0) {
|
|
4984
|
-
if (!
|
|
5298
|
+
if (!_chunkPVJMTLPJcjs.isInterpolation.call(void 0, raw.interpolation)) fail4(`Unknown interpolation "${String(raw.interpolation)}"; use nearest, bilinear or bicubic.`);
|
|
4985
5299
|
if (raw.interpolation !== "bicubic") out.interpolation = raw.interpolation;
|
|
4986
5300
|
}
|
|
4987
5301
|
const g = { box: { x: 0, y: 0, width: contents.width, height: contents.height }, corners: out.corners, warp: _nullishCoalesce(out.warp, () => ( null)) };
|
|
@@ -5001,7 +5315,7 @@ function followMask(mask, before, after) {
|
|
|
5001
5315
|
const inv = _chunkQT26RHKKcjs.invertHomography.call(void 0, h0);
|
|
5002
5316
|
if (!inv) return mask;
|
|
5003
5317
|
const delta = _chunkQT26RHKKcjs.multiplyHomographies.call(void 0, inv, h1);
|
|
5004
|
-
const surface =
|
|
5318
|
+
const surface = _chunkPVJMTLPJcjs.transformSurface.call(void 0, mask.surface, delta, { interpolation: "bilinear" });
|
|
5005
5319
|
return { ...mask, surface };
|
|
5006
5320
|
}
|
|
5007
5321
|
function setSmartPlacement(layers, id, placement, canvas) {
|
|
@@ -5022,7 +5336,7 @@ function setSmartPlacement(layers, id, placement, canvas) {
|
|
|
5022
5336
|
next.smartFilters = { ...next.smartFilters, mask: m };
|
|
5023
5337
|
}
|
|
5024
5338
|
next = rerender(next, canvas, "be transformed");
|
|
5025
|
-
return { layers:
|
|
5339
|
+
return { layers: _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, masksMoved };
|
|
5026
5340
|
}
|
|
5027
5341
|
function offsetSmartObject(layers, id, dx, dy, canvas) {
|
|
5028
5342
|
const layer = requireSmartObject(layers, id);
|
|
@@ -5045,7 +5359,7 @@ function offsetSmartObject(layers, id, dx, dy, canvas) {
|
|
|
5045
5359
|
} else {
|
|
5046
5360
|
next = rerender(next, canvas, "move");
|
|
5047
5361
|
}
|
|
5048
|
-
return
|
|
5362
|
+
return _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
5049
5363
|
}
|
|
5050
5364
|
function translateLayer(layer, dx, dy) {
|
|
5051
5365
|
if (!dx && !dy) return layer;
|
|
@@ -5081,7 +5395,7 @@ function translateLayer(layer, dx, dy) {
|
|
|
5081
5395
|
case "shape": {
|
|
5082
5396
|
const next = {
|
|
5083
5397
|
...layer,
|
|
5084
|
-
components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }),
|
|
5398
|
+
components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), _chunk7AUQ2UJ3cjs.translateMatrix.call(void 0, dx, dy)),
|
|
5085
5399
|
surface: _chunk474IQG74cjs.translateSurface.call(void 0, layer.surface, dx, dy),
|
|
5086
5400
|
mask: moveMask(layer.mask)
|
|
5087
5401
|
};
|
|
@@ -5090,7 +5404,7 @@ function translateLayer(layer, dx, dy) {
|
|
|
5090
5404
|
return next;
|
|
5091
5405
|
}
|
|
5092
5406
|
case "type": {
|
|
5093
|
-
const next = { ...transformTypeLayer(layer,
|
|
5407
|
+
const next = { ...transformTypeLayer(layer, _chunk7AUQ2UJ3cjs.translateMatrix.call(void 0, dx, dy)), surface: _chunk474IQG74cjs.translateSurface.call(void 0, layer.surface, dx, dy), mask: moveMask(layer.mask) };
|
|
5094
5408
|
if (!next.mask) delete next.mask;
|
|
5095
5409
|
return next;
|
|
5096
5410
|
}
|
|
@@ -5113,7 +5427,7 @@ function layerExtent(layer, surfaceOf, canvas) {
|
|
|
5113
5427
|
} else {
|
|
5114
5428
|
b = full;
|
|
5115
5429
|
}
|
|
5116
|
-
const m =
|
|
5430
|
+
const m = _chunkPVJMTLPJcjs.effectsMargin.call(void 0, layer.effects);
|
|
5117
5431
|
if (b && m > 0) b = { x: b.x - Math.ceil(m), y: b.y - Math.ceil(m), width: b.width + 2 * Math.ceil(m), height: b.height + 2 * Math.ceil(m) };
|
|
5118
5432
|
return b;
|
|
5119
5433
|
}
|
|
@@ -5182,7 +5496,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
5182
5496
|
delete resolved2.source;
|
|
5183
5497
|
layer = resolved2;
|
|
5184
5498
|
}
|
|
5185
|
-
if (
|
|
5499
|
+
if (_chunkPVJMTLPJcjs.flattenLayers.call(void 0, [layer]).some((x) => x.type === "pixel" && x.source === "document")) fail4(`Layer "${layer.name || layer.id}" holds the document image inside a group; convert the Background on its own.`);
|
|
5186
5500
|
return translateLayer(layer, -b.x, -b.y);
|
|
5187
5501
|
});
|
|
5188
5502
|
if (nested[0].clipped) {
|
|
@@ -5209,8 +5523,8 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
5209
5523
|
smart = { ...smart, surface: renderSmartObject(smart, canvas) };
|
|
5210
5524
|
const below = ordered.filter((l) => l.index < top.index).length;
|
|
5211
5525
|
let out = layers;
|
|
5212
|
-
for (const l of ordered) out =
|
|
5213
|
-
return { layers:
|
|
5526
|
+
for (const l of ordered) out = _chunkPVJMTLPJcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
|
|
5527
|
+
return { layers: _chunkPVJMTLPJcjs.insertLayer.call(void 0, out, smart, parent, top.index - below), layer: smart };
|
|
5214
5528
|
}
|
|
5215
5529
|
function rasterizeSmartObject(layers, id) {
|
|
5216
5530
|
const layer = requireSmartObject(layers, id);
|
|
@@ -5230,7 +5544,7 @@ function rasterizeSmartObject(layers, id) {
|
|
|
5230
5544
|
if (layer.locks) out.locks = layer.locks;
|
|
5231
5545
|
if (layer.effects) out.effects = layer.effects;
|
|
5232
5546
|
if (layer.fillOpacity !== void 0) out.fillOpacity = layer.fillOpacity;
|
|
5233
|
-
return { layers:
|
|
5547
|
+
return { layers: _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => out), layer: out };
|
|
5234
5548
|
}
|
|
5235
5549
|
function copySmartObject(layers, id, linked, name) {
|
|
5236
5550
|
const loc = requireLayer(layers, id);
|
|
@@ -5240,19 +5554,19 @@ function copySmartObject(layers, id, linked, name) {
|
|
|
5240
5554
|
delete copy.psd;
|
|
5241
5555
|
if (!linked) copy.contents = { ...layer.contents, id: newContentsId() };
|
|
5242
5556
|
if (copy.smartFilters) copy.smartFilters = { ...copy.smartFilters, filters: copy.smartFilters.filters.map((f) => ({ ...f, id: newLayerId("flt") })) };
|
|
5243
|
-
return { layers:
|
|
5557
|
+
return { layers: _chunkPVJMTLPJcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _140 => _140.parent, 'optionalAccess', _141 => _141.id]), () => ( null)), loc.index + 1), layer: copy };
|
|
5244
5558
|
}
|
|
5245
5559
|
function instancesOf(layers, contentsId) {
|
|
5246
|
-
return
|
|
5560
|
+
return _chunkPVJMTLPJcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
|
|
5247
5561
|
}
|
|
5248
5562
|
function replaceContents(layers, contentsId, contents, canvas) {
|
|
5249
5563
|
const ids = instancesOf(layers, contentsId);
|
|
5250
5564
|
if (!ids.length) fail4(`No smart object uses contents "${contentsId}".`);
|
|
5251
|
-
for (const id of ids) requireUnlocked(
|
|
5565
|
+
for (const id of ids) requireUnlocked(_chunkPVJMTLPJcjs.findLayer.call(void 0, layers, id).layer, "all", "replace its contents");
|
|
5252
5566
|
const next = { ...contents, id: contentsId };
|
|
5253
5567
|
let out = layers;
|
|
5254
5568
|
for (const id of ids) {
|
|
5255
|
-
out =
|
|
5569
|
+
out = _chunkPVJMTLPJcjs.mapLayer.call(void 0, out, id, (l) => {
|
|
5256
5570
|
const layer = l;
|
|
5257
5571
|
return rerender({ ...layer, contents: next, placement: refitPlacement(layer, next) }, canvas, "take the new contents");
|
|
5258
5572
|
});
|
|
@@ -5276,7 +5590,7 @@ function refitPlacement(layer, contents) {
|
|
|
5276
5590
|
});
|
|
5277
5591
|
const out = { corners: pts };
|
|
5278
5592
|
if (layer.placement.interpolation) out.interpolation = layer.placement.interpolation;
|
|
5279
|
-
if (layer.placement.warp) out.warp =
|
|
5593
|
+
if (layer.placement.warp) out.warp = _chunk7AUQ2UJ3cjs.mapWarpMeshPoints.call(void 0, layer.placement.warp, (p) => ({ x: p.x * W1 / W0, y: p.y * H1 / H0 }));
|
|
5280
5594
|
return out;
|
|
5281
5595
|
}
|
|
5282
5596
|
function normalizeSmartFilter(raw, id = newLayerId("flt")) {
|
|
@@ -5331,7 +5645,7 @@ function addSmartFilter(layers, id, filter, canvas, index) {
|
|
|
5331
5645
|
const at = index === void 0 ? filters.length : Math.max(0, Math.min(filters.length, Math.floor(index)));
|
|
5332
5646
|
filters.splice(at, 0, filter);
|
|
5333
5647
|
const next = withStack(layer, { ...stack, filters }, canvas);
|
|
5334
|
-
return { layers:
|
|
5648
|
+
return { layers: _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter };
|
|
5335
5649
|
}
|
|
5336
5650
|
function updateSmartFilter(layers, id, filterId, changes, canvas) {
|
|
5337
5651
|
const layer = editableSmart(layers, id);
|
|
@@ -5353,7 +5667,7 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
|
|
|
5353
5667
|
const filters = [...layer.smartFilters.filters];
|
|
5354
5668
|
filters[i] = merged2;
|
|
5355
5669
|
const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
|
|
5356
|
-
return { layers:
|
|
5670
|
+
return { layers: _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter: merged2 };
|
|
5357
5671
|
}
|
|
5358
5672
|
function removeSmartFilter(layers, id, filterId, canvas) {
|
|
5359
5673
|
const layer = editableSmart(layers, id);
|
|
@@ -5361,7 +5675,7 @@ function removeSmartFilter(layers, id, filterId, canvas) {
|
|
|
5361
5675
|
const stack = layer.smartFilters;
|
|
5362
5676
|
const filters = stack.filters.filter((f) => f.id !== filterId);
|
|
5363
5677
|
const next = withStack(layer, filters.length ? { ...stack, filters } : stack.enabled ? void 0 : { enabled: false, filters }, canvas);
|
|
5364
|
-
return { layers:
|
|
5678
|
+
return { layers: _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
5365
5679
|
}
|
|
5366
5680
|
function moveSmartFilter(layers, id, filterId, index, canvas) {
|
|
5367
5681
|
const layer = editableSmart(layers, id);
|
|
@@ -5372,12 +5686,12 @@ function moveSmartFilter(layers, id, filterId, index, canvas) {
|
|
|
5372
5686
|
const [f] = filters.splice(i, 1);
|
|
5373
5687
|
filters.splice(index, 0, f);
|
|
5374
5688
|
const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
|
|
5375
|
-
return { layers:
|
|
5689
|
+
return { layers: _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
5376
5690
|
}
|
|
5377
5691
|
function setSmartFiltersEnabled(layers, id, enabled, canvas) {
|
|
5378
5692
|
const layer = editableSmart(layers, id);
|
|
5379
5693
|
const next = withStack(layer, { ...stackOf(layer), enabled: Boolean(enabled) }, canvas);
|
|
5380
|
-
return { layers:
|
|
5694
|
+
return { layers: _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
5381
5695
|
}
|
|
5382
5696
|
function setSmartFilterMask(layers, id, mask, canvas) {
|
|
5383
5697
|
const layer = editableSmart(layers, id);
|
|
@@ -5386,7 +5700,7 @@ function setSmartFilterMask(layers, id, mask, canvas) {
|
|
|
5386
5700
|
if (mask) stack.mask = mask;
|
|
5387
5701
|
else delete stack.mask;
|
|
5388
5702
|
const next = withStack(layer, stack, canvas);
|
|
5389
|
-
return { layers:
|
|
5703
|
+
return { layers: _chunkPVJMTLPJcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
5390
5704
|
}
|
|
5391
5705
|
function withFilterMaskSurface(layer, surface, canvas) {
|
|
5392
5706
|
const stack = stackOf(layer);
|
|
@@ -5473,7 +5787,7 @@ function baseFields(layer, ctx) {
|
|
|
5473
5787
|
blend: layer.blend
|
|
5474
5788
|
};
|
|
5475
5789
|
if (layer.clipped) out.clipped = true;
|
|
5476
|
-
if (layer.mask) out.mask =
|
|
5790
|
+
if (layer.mask) out.mask = serializeMask2(layer.mask, `${layer.id}-mask`, ctx);
|
|
5477
5791
|
if (layer.vectorMask) out.vectorMask = serializeVectorMask(layer.vectorMask);
|
|
5478
5792
|
if (layer.locks && Object.values(layer.locks).some(Boolean)) out.locks = { ...layer.locks };
|
|
5479
5793
|
if (layer.effects) out.effects = serializeEffects(layer.effects);
|
|
@@ -5510,7 +5824,7 @@ function deserializeEffects(raw) {
|
|
|
5510
5824
|
psd = void 0;
|
|
5511
5825
|
}
|
|
5512
5826
|
}
|
|
5513
|
-
return
|
|
5827
|
+
return _chunkPVJMTLPJcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
|
|
5514
5828
|
}
|
|
5515
5829
|
function serializeVectorMask(vm) {
|
|
5516
5830
|
const out = { components: JSON.parse(JSON.stringify(vm.components)) };
|
|
@@ -5558,7 +5872,7 @@ function readVectorMask(r) {
|
|
|
5558
5872
|
}
|
|
5559
5873
|
return vm;
|
|
5560
5874
|
}
|
|
5561
|
-
function
|
|
5875
|
+
function serializeMask2(mask, hint, ctx) {
|
|
5562
5876
|
const out = { defaultValue: mask.defaultValue };
|
|
5563
5877
|
if (!mask.source) {
|
|
5564
5878
|
const enc = encodeSurface(mask.surface);
|
|
@@ -5653,7 +5967,7 @@ function readType(r, base, ctx) {
|
|
|
5653
5967
|
const text3 = normalizeText(_nullishCoalesce(r.text, () => ( "")));
|
|
5654
5968
|
const runs = (Array.isArray(r.runs) ? r.runs : []).map((run, i) => ({
|
|
5655
5969
|
length: Math.max(0, Math.floor(num2(_optionalChain([run, 'optionalAccess', _166 => _166.length]), 0, 1e9, 0))),
|
|
5656
|
-
style: patchTextStyle(
|
|
5970
|
+
style: patchTextStyle(_chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _167 => _167.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
|
|
5657
5971
|
}));
|
|
5658
5972
|
const paragraphs = (Array.isArray(r.paragraphs) ? r.paragraphs : []).map((p, i) => ({
|
|
5659
5973
|
length: Math.max(0, Math.floor(num2(_optionalChain([p, 'optionalAccess', _168 => _168.length]), 0, 1e9, 0))),
|
|
@@ -5666,13 +5980,13 @@ function readType(r, base, ctx) {
|
|
|
5666
5980
|
...base,
|
|
5667
5981
|
type: "type",
|
|
5668
5982
|
text: text3,
|
|
5669
|
-
runs:
|
|
5670
|
-
paragraphs:
|
|
5983
|
+
runs: _chunk7AUQ2UJ3cjs.fitRuns.call(void 0, runs, text3.length, _chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE),
|
|
5984
|
+
paragraphs: _chunk7AUQ2UJ3cjs.fitParagraphRuns.call(void 0, paragraphs.length ? paragraphs : [{ length: text3.length, style: {} }], text3),
|
|
5671
5985
|
frame,
|
|
5672
5986
|
surface: _chunk474IQG74cjs.emptySurface.call(void 0, 4),
|
|
5673
5987
|
offset: { x: 0, y: 0 }
|
|
5674
5988
|
};
|
|
5675
|
-
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _172 => _172[0], 'optionalAccess', _173 => _173.style]), () => (
|
|
5989
|
+
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _172 => _172[0], 'optionalAccess', _173 => _173.style]), () => ( _chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE)) }];
|
|
5676
5990
|
if (m) layer.transform = m;
|
|
5677
5991
|
if (r.orientation === "vertical") layer.orientation = "vertical";
|
|
5678
5992
|
if (r.antiAlias === false) layer.antiAlias = false;
|
|
@@ -5757,7 +6071,7 @@ function serializeSmartFilters(stack, layerId, ctx) {
|
|
|
5757
6071
|
enabled: stack.enabled,
|
|
5758
6072
|
filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data: _chunkW5M3J7PVcjs.bytesToBase64.call(void 0, f.data) } : JSON.parse(JSON.stringify(f)))
|
|
5759
6073
|
};
|
|
5760
|
-
if (stack.mask) out.mask =
|
|
6074
|
+
if (stack.mask) out.mask = serializeMask2(stack.mask, `${layerId}-filter-mask`, ctx);
|
|
5761
6075
|
return out;
|
|
5762
6076
|
}
|
|
5763
6077
|
function serializeSmartObject(layer, base, ctx) {
|
|
@@ -6105,7 +6419,7 @@ function readSmartFilters(raw, ctx, what) {
|
|
|
6105
6419
|
const r = raw;
|
|
6106
6420
|
const filters = [];
|
|
6107
6421
|
const list2 = Array.isArray(r.filters) ? r.filters : [];
|
|
6108
|
-
const
|
|
6422
|
+
const plain2 = _nullishCoalesce(readFilters(list2.filter((f) => f && f.kind !== "psd")), () => ( []));
|
|
6109
6423
|
let k = 0;
|
|
6110
6424
|
for (const f of list2) {
|
|
6111
6425
|
if (!f || typeof f !== "object") continue;
|
|
@@ -6118,7 +6432,7 @@ function readSmartFilters(raw, ctx, what) {
|
|
|
6118
6432
|
ctx.problems.push(`${what}: a Photoshop smart filter could not be read`);
|
|
6119
6433
|
}
|
|
6120
6434
|
} else if (f.kind === "develop" || f.kind === "blur") {
|
|
6121
|
-
const base =
|
|
6435
|
+
const base = plain2[k++];
|
|
6122
6436
|
if (base) filters.push({ ...base, blend, opacity });
|
|
6123
6437
|
} else if (f.kind === "effect") {
|
|
6124
6438
|
const ref = readEffectRef(f);
|
|
@@ -6142,8 +6456,8 @@ function readSmartObject(r, base, ctx) {
|
|
|
6142
6456
|
let placement;
|
|
6143
6457
|
try {
|
|
6144
6458
|
const raw = { corners: p.corners };
|
|
6145
|
-
if (p.warp &&
|
|
6146
|
-
if (
|
|
6459
|
+
if (p.warp && _chunk7AUQ2UJ3cjs.isValidWarpMesh.call(void 0, p.warp)) raw.warp = p.warp;
|
|
6460
|
+
if (_chunkPVJMTLPJcjs.isInterpolation.call(void 0, p.interpolation)) raw.interpolation = p.interpolation;
|
|
6147
6461
|
placement = normalizePlacement(raw, contents);
|
|
6148
6462
|
} catch (e) {
|
|
6149
6463
|
ctx.problems.push(`${what}: its placement is invalid (${e instanceof Error ? e.message : String(e)}); it was placed at the top left`);
|
|
@@ -6309,9 +6623,9 @@ var PsdReader = class _PsdReader {
|
|
|
6309
6623
|
return s.replace(/\u0000+$/, "");
|
|
6310
6624
|
}
|
|
6311
6625
|
};
|
|
6312
|
-
var PsdWriter = (
|
|
6313
|
-
|
|
6314
|
-
|
|
6626
|
+
var PsdWriter = (_class3 = class {constructor() { _class3.prototype.__init5.call(this);_class3.prototype.__init6.call(this); }
|
|
6627
|
+
__init5() {this.buf = new Uint8Array(1 << 16)}
|
|
6628
|
+
__init6() {this.length = 0}
|
|
6315
6629
|
ensure(n) {
|
|
6316
6630
|
if (this.length + n <= this.buf.length) return;
|
|
6317
6631
|
let size = this.buf.length * 2;
|
|
@@ -6396,7 +6710,7 @@ var PsdWriter = (_class = class {constructor() { _class.prototype.__init.call(th
|
|
|
6396
6710
|
result() {
|
|
6397
6711
|
return this.buf.slice(0, this.length);
|
|
6398
6712
|
}
|
|
6399
|
-
},
|
|
6713
|
+
}, _class3);
|
|
6400
6714
|
function decodeLegacyName(b) {
|
|
6401
6715
|
try {
|
|
6402
6716
|
return new TextDecoder("utf-8", { fatal: true }).decode(b);
|
|
@@ -7313,7 +7627,7 @@ function vectorBlockForComponents(components, inverted, width, height, flags = 0
|
|
|
7313
7627
|
const fr = (p) => ({ x: p.x / w, y: p.y / h });
|
|
7314
7628
|
const subpaths = [];
|
|
7315
7629
|
components.forEach((c, ci) => {
|
|
7316
|
-
|
|
7630
|
+
_chunk7AUQ2UJ3cjs.expandVectorCorners.call(void 0, c.subpaths).forEach((sp, si) => {
|
|
7317
7631
|
if (!sp.anchors.length) return;
|
|
7318
7632
|
subpaths.push({
|
|
7319
7633
|
closed: sp.closed,
|
|
@@ -8139,7 +8453,7 @@ function merged(levels) {
|
|
|
8139
8453
|
function charStyle(d, fonts, notes, vertical = false) {
|
|
8140
8454
|
const n = (k) => eNum(eGet(d, k));
|
|
8141
8455
|
const flag = (k) => eBool(eGet(d, k));
|
|
8142
|
-
const s = { ...
|
|
8456
|
+
const s = { ..._chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE };
|
|
8143
8457
|
const fi = n("Font");
|
|
8144
8458
|
const ps = fi !== void 0 ? fonts[fi] : void 0;
|
|
8145
8459
|
if (ps) {
|
|
@@ -8224,7 +8538,7 @@ function typeFromTySh(data, notes) {
|
|
|
8224
8538
|
}
|
|
8225
8539
|
const edText = _nullishCoalesce(eStr(ePath(_nullishCoalesce(engine, () => ( void 0)), ["EngineDict", "Editor", "Text"])), () => ( ""));
|
|
8226
8540
|
const text3 = (_nullishCoalesce(txt, () => ( edText.replace(/\r$/, "")))).replace(/\r\n?/g, "\n");
|
|
8227
|
-
let runs = [{ length: text3.length, style: { ...
|
|
8541
|
+
let runs = [{ length: text3.length, style: { ..._chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE } }];
|
|
8228
8542
|
let paragraphs = [{ length: text3.length, style: {} }];
|
|
8229
8543
|
let frame = { kind: "point" };
|
|
8230
8544
|
let transform = t.transform;
|
|
@@ -8280,14 +8594,14 @@ function typeFromTySh(data, notes) {
|
|
|
8280
8594
|
const b = eArray(ePath(shape, ["Cookie", "Photoshop", "BoxBounds"])).map((v) => _nullishCoalesce(eNum(v), () => ( 0)));
|
|
8281
8595
|
if (b.length === 4 && b[2] > b[0] && b[3] > b[1]) {
|
|
8282
8596
|
frame = { kind: "box", width: b[2] - b[0], height: b[3] - b[1] };
|
|
8283
|
-
transform =
|
|
8597
|
+
transform = _chunk7AUQ2UJ3cjs.multiplyMatrices.call(void 0, [1, 0, 0, 1, b[0], b[1]], t.transform);
|
|
8284
8598
|
}
|
|
8285
8599
|
}
|
|
8286
8600
|
}
|
|
8287
8601
|
return {
|
|
8288
8602
|
text: text3,
|
|
8289
|
-
runs:
|
|
8290
|
-
paragraphs:
|
|
8603
|
+
runs: _chunk7AUQ2UJ3cjs.fitRuns.call(void 0, runs, text3.length, _chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE),
|
|
8604
|
+
paragraphs: _chunk7AUQ2UJ3cjs.fitParagraphRuns.call(void 0, paragraphs, text3),
|
|
8291
8605
|
frame,
|
|
8292
8606
|
orientation: vertical ? "vertical" : "horizontal",
|
|
8293
8607
|
transform,
|
|
@@ -8363,7 +8677,7 @@ function buildEngineData(layer, template) {
|
|
|
8363
8677
|
fonts.push(ps);
|
|
8364
8678
|
return fonts.length - 1;
|
|
8365
8679
|
};
|
|
8366
|
-
const runs =
|
|
8680
|
+
const runs = _chunk7AUQ2UJ3cjs.fitRuns.call(void 0, layer.runs, layer.text.length, _chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE);
|
|
8367
8681
|
const vertical = layer.orientation === "vertical";
|
|
8368
8682
|
const sruns = [];
|
|
8369
8683
|
const slens = [];
|
|
@@ -8372,10 +8686,10 @@ function buildEngineData(layer, template) {
|
|
|
8372
8686
|
slens.push(E.int(r.length + (i === runs.length - 1 ? 1 : 0)));
|
|
8373
8687
|
});
|
|
8374
8688
|
if (!runs.length) {
|
|
8375
|
-
sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(
|
|
8689
|
+
sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(_chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE, fontIndex(postScriptFor(_chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE)))]])]]));
|
|
8376
8690
|
slens.push(E.int(1));
|
|
8377
8691
|
}
|
|
8378
|
-
const paras =
|
|
8692
|
+
const paras = _chunk7AUQ2UJ3cjs.fitParagraphRuns.call(void 0, layer.paragraphs, layer.text);
|
|
8379
8693
|
const pruns = [];
|
|
8380
8694
|
const plens = [];
|
|
8381
8695
|
paras.forEach((p, i) => {
|
|
@@ -8431,7 +8745,7 @@ function buildEngineData(layer, template) {
|
|
|
8431
8745
|
eSet(e, key, rd);
|
|
8432
8746
|
}
|
|
8433
8747
|
eSet(rd, "FontSet", fontSet);
|
|
8434
|
-
if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _248 => _248[0], 'optionalAccess', _249 => _249.style]), () => (
|
|
8748
|
+
if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _248 => _248[0], 'optionalAccess', _249 => _249.style]), () => ( _chunk7AUQ2UJ3cjs.DEFAULT_TEXT_STYLE)), 0)]])]));
|
|
8435
8749
|
if (!eGet(rd, "ParagraphSheetSet")) eSet(rd, "ParagraphSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["DefaultStyleSheet", E.int(0)], ["Properties", paragraphProperties({})]])]));
|
|
8436
8750
|
if (!eGet(rd, "TheNormalStyleSheet")) eSet(rd, "TheNormalStyleSheet", E.int(0));
|
|
8437
8751
|
if (!eGet(rd, "TheNormalParagraphSheet")) eSet(rd, "TheNormalParagraphSheet", E.int(0));
|
|
@@ -8442,13 +8756,13 @@ function inkBounds2(layer) {
|
|
|
8442
8756
|
if (layer.frame.kind === "box") return [0, 0, layer.frame.width, layer.frame.height];
|
|
8443
8757
|
const b = _chunk474IQG74cjs.contentBounds.call(void 0, layer.surface);
|
|
8444
8758
|
if (!b) return [0, 0, 0, 0];
|
|
8445
|
-
const inv =
|
|
8759
|
+
const inv = _chunk7AUQ2UJ3cjs.invertMatrix.call(void 0, textMatrix(layer));
|
|
8446
8760
|
const pts = [
|
|
8447
8761
|
{ x: b.x, y: b.y },
|
|
8448
8762
|
{ x: b.x + b.width, y: b.y },
|
|
8449
8763
|
{ x: b.x + b.width, y: b.y + b.height },
|
|
8450
8764
|
{ x: b.x, y: b.y + b.height }
|
|
8451
|
-
].map((p) =>
|
|
8765
|
+
].map((p) => _chunk7AUQ2UJ3cjs.applyMatrix.call(void 0, inv, p));
|
|
8452
8766
|
return [Math.min(...pts.map((p) => p.x)), Math.min(...pts.map((p) => p.y)), Math.max(...pts.map((p) => p.x)), Math.max(...pts.map((p) => p.y))];
|
|
8453
8767
|
}
|
|
8454
8768
|
function tyShForLayer(layer) {
|
|
@@ -8729,7 +9043,7 @@ function filterMaskItem(placed, mask, area) {
|
|
|
8729
9043
|
var warpStyleOf = (name) => {
|
|
8730
9044
|
if (!name.startsWith("warp")) return null;
|
|
8731
9045
|
const s = _optionalChain([name, 'access', _263 => _263[4], 'optionalAccess', _264 => _264.toLowerCase, 'call', _265 => _265()]) + name.slice(5);
|
|
8732
|
-
return
|
|
9046
|
+
return _chunk7AUQ2UJ3cjs.WARP_STYLES.includes(s) ? s : null;
|
|
8733
9047
|
};
|
|
8734
9048
|
function warpFromDescriptor(w, contents) {
|
|
8735
9049
|
const full = { x: 0, y: 0, width: contents.width, height: contents.height };
|
|
@@ -8759,7 +9073,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
8759
9073
|
} else {
|
|
8760
9074
|
const style = warpStyleOf(styleName);
|
|
8761
9075
|
if (!style) return void 0;
|
|
8762
|
-
mesh =
|
|
9076
|
+
mesh = _chunk7AUQ2UJ3cjs.warpPresetMesh.call(void 0,
|
|
8763
9077
|
{
|
|
8764
9078
|
style,
|
|
8765
9079
|
bend: _nullishCoalesce(descNumber(w, "warpValue"), () => ( 0)),
|
|
@@ -8774,7 +9088,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
8774
9088
|
const same = Math.abs(bounds.x) < 1e-6 && Math.abs(bounds.y) < 1e-6 && Math.abs(bounds.width - contents.width) < 1e-6 && Math.abs(bounds.height - contents.height) < 1e-6;
|
|
8775
9089
|
if (!same) {
|
|
8776
9090
|
const m = mesh;
|
|
8777
|
-
mesh =
|
|
9091
|
+
mesh = _chunk7AUQ2UJ3cjs.fitWarpMesh.call(void 0, (s, t) => _chunk7AUQ2UJ3cjs.evalWarpMesh.call(void 0, m, (s * contents.width - bounds.x) / bounds.width, (t * contents.height - bounds.y) / bounds.height), [0, 1], [0, 1]);
|
|
8778
9092
|
}
|
|
8779
9093
|
return { mesh, frame };
|
|
8780
9094
|
}
|
|
@@ -9948,9 +10262,9 @@ var SMART_KEYS = ["SoLd", "SoLE", "PlLd"];
|
|
|
9948
10262
|
var VECTOR_KEYS = ["vmsk", "vsms"];
|
|
9949
10263
|
var MAX_CONTENTS_DEPTH = 6;
|
|
9950
10264
|
var percent = (v) => Math.round(v / 255 * 100) / 100;
|
|
9951
|
-
var Warnings = (
|
|
9952
|
-
|
|
9953
|
-
|
|
10265
|
+
var Warnings = (_class4 = class {constructor() { _class4.prototype.__init7.call(this);_class4.prototype.__init8.call(this); }
|
|
10266
|
+
__init7() {this.groups = /* @__PURE__ */ new Map()}
|
|
10267
|
+
__init8() {this.extra = []}
|
|
9954
10268
|
add(message, layer) {
|
|
9955
10269
|
const list2 = _nullishCoalesce(this.groups.get(message), () => ( []));
|
|
9956
10270
|
if (!list2.includes(layer)) list2.push(layer);
|
|
@@ -9965,7 +10279,7 @@ var Warnings = (_class2 = class {constructor() { _class2.prototype.__init3.call(
|
|
|
9965
10279
|
}
|
|
9966
10280
|
return out;
|
|
9967
10281
|
}
|
|
9968
|
-
},
|
|
10282
|
+
}, _class4);
|
|
9969
10283
|
function psdKind(rec) {
|
|
9970
10284
|
if (rec.blocks.some((b) => TYPE_KEYS.includes(b.key))) return "type";
|
|
9971
10285
|
if (rec.blocks.some((b) => SMART_KEYS.includes(b.key))) return "smart-object";
|
|
@@ -10113,7 +10427,7 @@ function recordEffects(ctx, rec, name, notes, group) {
|
|
|
10113
10427
|
}
|
|
10114
10428
|
for (const e of parsed.effects.items) {
|
|
10115
10429
|
for (const id of patternIds(e)) {
|
|
10116
|
-
if (ctx.patterns.has(id) ||
|
|
10430
|
+
if (ctx.patterns.has(id) || _chunkPVJMTLPJcjs.builtinPattern.call(void 0, id)) continue;
|
|
10117
10431
|
ctx.warn.add("A pattern effect uses a pattern the file does not contain, and paints nothing", name);
|
|
10118
10432
|
notes.push(`pattern "${id}" is not in the file`);
|
|
10119
10433
|
}
|
|
@@ -10366,7 +10680,7 @@ function importSmart(ctx, rec, name, notes, props) {
|
|
|
10366
10680
|
if (placement && (size.width !== contents.width || size.height !== contents.height)) {
|
|
10367
10681
|
const kx = contents.width / size.width;
|
|
10368
10682
|
const ky = contents.height / size.height;
|
|
10369
|
-
if (placement.warp) placement = { ...placement, warp:
|
|
10683
|
+
if (placement.warp) placement = { ...placement, warp: _chunk7AUQ2UJ3cjs.mapWarpMeshPoints.call(void 0, placement.warp, (p) => ({ x: p.x * kx, y: p.y * ky })) };
|
|
10370
10684
|
}
|
|
10371
10685
|
}
|
|
10372
10686
|
if (!contents || !placement) {
|
|
@@ -10691,34 +11005,34 @@ function blendOf(d, key, fallback, notes) {
|
|
|
10691
11005
|
function colorOf(d, fallback = "#000000") {
|
|
10692
11006
|
if (!d) return fallback;
|
|
10693
11007
|
const g = (k) => descNumber(d, k);
|
|
10694
|
-
if (g("redFloat") !== void 0) return
|
|
11008
|
+
if (g("redFloat") !== void 0) return _chunkPVJMTLPJcjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
|
|
10695
11009
|
switch (d.classId) {
|
|
10696
11010
|
case "HSBC": {
|
|
10697
11011
|
const rgb = decodePsdColor(1, [(_nullishCoalesce(g("H "), () => ( 0))) / 360 * 65535, (_nullishCoalesce(g("Strt"), () => ( 0))) / 100 * 65535, (_nullishCoalesce(g("Brgh"), () => ( 0))) / 100 * 65535]);
|
|
10698
|
-
return rgb ?
|
|
11012
|
+
return rgb ? _chunkPVJMTLPJcjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
10699
11013
|
}
|
|
10700
11014
|
case "CMYC": {
|
|
10701
11015
|
const inv = (k) => (1 - (_nullishCoalesce(g(k), () => ( 0))) / 100) * 65535;
|
|
10702
11016
|
const rgb = decodePsdColor(2, [inv("Cyn "), inv("Mgnt"), inv("Ylw "), inv("Blck")]);
|
|
10703
|
-
return rgb ?
|
|
11017
|
+
return rgb ? _chunkPVJMTLPJcjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
10704
11018
|
}
|
|
10705
11019
|
case "LbCl": {
|
|
10706
11020
|
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]);
|
|
10707
|
-
return rgb ?
|
|
11021
|
+
return rgb ? _chunkPVJMTLPJcjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
10708
11022
|
}
|
|
10709
11023
|
case "Grsc": {
|
|
10710
11024
|
const v = 1 - (_nullishCoalesce(g("Gry "), () => ( 0))) / 100;
|
|
10711
|
-
return
|
|
11025
|
+
return _chunkPVJMTLPJcjs.effectColorHex.call(void 0, [v, v, v]);
|
|
10712
11026
|
}
|
|
10713
11027
|
}
|
|
10714
11028
|
const r = g("Rd ");
|
|
10715
11029
|
const gr = g("Grn ");
|
|
10716
11030
|
const b = g("Bl ");
|
|
10717
11031
|
if (r === void 0 || gr === void 0 || b === void 0) return fallback;
|
|
10718
|
-
return
|
|
11032
|
+
return _chunkPVJMTLPJcjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
|
|
10719
11033
|
}
|
|
10720
11034
|
function colorDesc(hex) {
|
|
10721
|
-
const [r, g, b] = _nullishCoalesce(
|
|
11035
|
+
const [r, g, b] = _nullishCoalesce(_chunkPVJMTLPJcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
|
|
10722
11036
|
return descriptor("RGBC", [
|
|
10723
11037
|
["Rd ", dbl3(r * 255)],
|
|
10724
11038
|
["Grn ", dbl3(g * 255)],
|
|
@@ -10801,9 +11115,9 @@ function gradientOf(d, notes) {
|
|
|
10801
11115
|
raw.forEach((s, i) => {
|
|
10802
11116
|
if (i > 0 && Math.abs(s.mid - 0.5) > 1e-3) {
|
|
10803
11117
|
const a = raw[i - 1];
|
|
10804
|
-
const ca =
|
|
10805
|
-
const cb =
|
|
10806
|
-
stops.push({ position: a.position + (s.position - a.position) * s.mid, color:
|
|
11118
|
+
const ca = _chunkPVJMTLPJcjs.parseEffectColor.call(void 0, a.color);
|
|
11119
|
+
const cb = _chunkPVJMTLPJcjs.parseEffectColor.call(void 0, s.color);
|
|
11120
|
+
stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkPVJMTLPJcjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
|
|
10807
11121
|
notes.add("gradient midpoints are drawn as straight segments");
|
|
10808
11122
|
}
|
|
10809
11123
|
stops.push({ position: s.position, color: s.color });
|
|
@@ -10915,8 +11229,8 @@ var KINDS = [
|
|
|
10915
11229
|
["FrFX", "frameFXMulti", "stroke"]
|
|
10916
11230
|
];
|
|
10917
11231
|
function common(d, kind, notes) {
|
|
10918
|
-
const def =
|
|
10919
|
-
return { id:
|
|
11232
|
+
const def = _chunkPVJMTLPJcjs.defaultLayerEffect.call(void 0, kind, "x");
|
|
11233
|
+
return { id: _chunkPVJMTLPJcjs.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) };
|
|
10920
11234
|
}
|
|
10921
11235
|
function readOne(kind, d, notes) {
|
|
10922
11236
|
const size = (key, fallback) => clamp3(num3(d, key, fallback), 0, 250);
|
|
@@ -10959,7 +11273,7 @@ function readOne(kind, d, notes) {
|
|
|
10959
11273
|
case "bevel-emboss": {
|
|
10960
11274
|
const styles = { OtrB: "outer-bevel", InrB: "inner-bevel", Embs: "emboss", PlEb: "pillow-emboss", strokeEmboss: "stroke-emboss" };
|
|
10961
11275
|
const out = {
|
|
10962
|
-
id:
|
|
11276
|
+
id: _chunkPVJMTLPJcjs.newEffectId.call(void 0, ),
|
|
10963
11277
|
enabled: descBool(d, "enab") !== false,
|
|
10964
11278
|
kind,
|
|
10965
11279
|
style: _nullishCoalesce(styles[_nullishCoalesce(enumOf3(d, "bvlS"), () => ( ""))], () => ( "inner-bevel")),
|
|
@@ -11170,10 +11484,10 @@ function writeLfx2(effects) {
|
|
|
11170
11484
|
["Scl ", unit3("#Prc", 100)],
|
|
11171
11485
|
["masterFXSwitch", boolV3(effects.enabled)]
|
|
11172
11486
|
];
|
|
11173
|
-
const scale =
|
|
11487
|
+
const scale = _chunkPVJMTLPJcjs.effectsScale.call(void 0, effects);
|
|
11174
11488
|
let dropped = 0;
|
|
11175
11489
|
for (const [single, multi, kind] of KINDS) {
|
|
11176
|
-
const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(
|
|
11490
|
+
const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkPVJMTLPJcjs.scaleLayerEffect.call(void 0, e, scale)));
|
|
11177
11491
|
if (!of.length) continue;
|
|
11178
11492
|
if (of.length === 1) items.push([single, obj3(of[0])]);
|
|
11179
11493
|
else if (multi) items.push([multi, { type: "VlLs", items: of.map(obj3) }]);
|
|
@@ -11205,7 +11519,7 @@ function parseLrfx(data) {
|
|
|
11205
11519
|
const colorAt = (rd) => {
|
|
11206
11520
|
rd.u16();
|
|
11207
11521
|
const c = [rd.u16(), rd.u16(), rd.u16(), rd.u16()];
|
|
11208
|
-
return
|
|
11522
|
+
return _chunkPVJMTLPJcjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
|
|
11209
11523
|
};
|
|
11210
11524
|
const blendAt = (rd) => {
|
|
11211
11525
|
rd.skip(4);
|
|
@@ -11224,7 +11538,7 @@ function parseLrfx(data) {
|
|
|
11224
11538
|
const enabled = b.u8() !== 0;
|
|
11225
11539
|
const useGlobalLight = b.u8() !== 0;
|
|
11226
11540
|
const opacity = b.u8() / 255;
|
|
11227
|
-
const base = { id:
|
|
11541
|
+
const base = { id: _chunkPVJMTLPJcjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
|
|
11228
11542
|
items.push(key === "dsdw" ? { ...base, kind: "drop-shadow", spread: 0, knocksOut: true } : { ...base, kind: "inner-shadow", choke: 0 });
|
|
11229
11543
|
} else if (key === "oglw" || key === "iglw") {
|
|
11230
11544
|
b.u32();
|
|
@@ -11234,7 +11548,7 @@ function parseLrfx(data) {
|
|
|
11234
11548
|
const blend = blendAt(b);
|
|
11235
11549
|
const enabled = b.u8() !== 0;
|
|
11236
11550
|
const opacity = b.u8() / 255;
|
|
11237
|
-
const base = { id:
|
|
11551
|
+
const base = { id: _chunkPVJMTLPJcjs.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 };
|
|
11238
11552
|
items.push(key === "oglw" ? { ...base, kind: "outer-glow", spread: 0 } : { ...base, kind: "inner-glow", choke: 0, source: "edge" });
|
|
11239
11553
|
} else if (key === "sofi") {
|
|
11240
11554
|
b.u32();
|
|
@@ -11242,7 +11556,7 @@ function parseLrfx(data) {
|
|
|
11242
11556
|
const color = colorAt(b);
|
|
11243
11557
|
const opacity = b.u8() / 255;
|
|
11244
11558
|
const enabled = b.u8() !== 0;
|
|
11245
|
-
items.push({ id:
|
|
11559
|
+
items.push({ id: _chunkPVJMTLPJcjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
|
|
11246
11560
|
} else if (key === "bevl") notes.add("legacy bevels are not read");
|
|
11247
11561
|
}
|
|
11248
11562
|
return { effects: { enabled: true, items }, notes: [...notes] };
|
|
@@ -11332,12 +11646,12 @@ function prepareNestedLayers(layers) {
|
|
|
11332
11646
|
const b = l.surface.bounds;
|
|
11333
11647
|
if (b) {
|
|
11334
11648
|
const r = { x: b.x + l.offset.x - 64, y: b.y + l.offset.y - 64, width: b.width + 128, height: b.height + 128 };
|
|
11335
|
-
const
|
|
11336
|
-
delete
|
|
11337
|
-
delete
|
|
11338
|
-
delete
|
|
11339
|
-
delete
|
|
11340
|
-
const data = new LayerCompositor().composite([
|
|
11649
|
+
const plain2 = { ...l, visible: true, opacity: 1, blend: "normal" };
|
|
11650
|
+
delete plain2.mask;
|
|
11651
|
+
delete plain2.clipped;
|
|
11652
|
+
delete plain2.effects;
|
|
11653
|
+
delete plain2.fillOpacity;
|
|
11654
|
+
const data = new LayerCompositor().composite([plain2], r, { width: r.x + r.width, height: r.y + r.height });
|
|
11341
11655
|
p.surface = _chunk474IQG74cjs.surfaceFromPixels.call(void 0, { width: r.width, height: r.height, data }, 4, r.x - l.offset.x, r.y - l.offset.y);
|
|
11342
11656
|
}
|
|
11343
11657
|
}
|
|
@@ -11435,7 +11749,7 @@ function exportPsd(input) {
|
|
|
11435
11749
|
const key = layer.type === "group" ? "lfxs" : "lfx2";
|
|
11436
11750
|
if (fx.psd) {
|
|
11437
11751
|
const original = parseLfx2(fx.psd.data);
|
|
11438
|
-
if (original ?
|
|
11752
|
+
if (original ? _chunkPVJMTLPJcjs.effectsFingerprint.call(void 0, original.effects) === _chunkPVJMTLPJcjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
|
|
11439
11753
|
}
|
|
11440
11754
|
if (!fx.items.length && fx.enabled && (_nullishCoalesce(fx.scale, () => ( 1))) === 1) return null;
|
|
11441
11755
|
const { data, dropped } = writeLfx2(fx);
|
|
@@ -11687,7 +12001,7 @@ function exportPsd(input) {
|
|
|
11687
12001
|
const byId = new Map((_nullishCoalesce(input.patterns, () => ( []))).map((p) => [p.id, p]));
|
|
11688
12002
|
const embed = [];
|
|
11689
12003
|
for (const id of patternIds2) {
|
|
11690
|
-
const p = _nullishCoalesce(byId.get(id), () => (
|
|
12004
|
+
const p = _nullishCoalesce(byId.get(id), () => ( _chunkPVJMTLPJcjs.builtinPattern.call(void 0, id)));
|
|
11691
12005
|
if (p) embed.push(p);
|
|
11692
12006
|
else note(`Pattern "${id}" is not in the document and was not embedded`, id);
|
|
11693
12007
|
}
|
|
@@ -11728,6 +12042,95 @@ function exportPsd(input) {
|
|
|
11728
12042
|
return { bytes, psb, records: records.length, warnings };
|
|
11729
12043
|
}
|
|
11730
12044
|
|
|
12045
|
+
// src/image-editor/selection/tool-options.ts
|
|
12046
|
+
var SELECTION_TOOLS = [
|
|
12047
|
+
{ id: "wand", label: "Magic Wand" },
|
|
12048
|
+
{ id: "rect", label: "Rectangle" },
|
|
12049
|
+
{ id: "ellipse", label: "Ellipse" },
|
|
12050
|
+
{ id: "row", label: "Single Row" },
|
|
12051
|
+
{ id: "column", label: "Single Column" },
|
|
12052
|
+
{ id: "lasso", label: "Lasso" },
|
|
12053
|
+
{ id: "polygon", label: "Polygonal Lasso" },
|
|
12054
|
+
{ id: "magnetic", label: "Magnetic Lasso" },
|
|
12055
|
+
{ id: "quick", label: "Quick Selection" },
|
|
12056
|
+
{ id: "object", label: "Object Selection" },
|
|
12057
|
+
{ id: "range", label: "Color Range" },
|
|
12058
|
+
{ id: "type", label: "Type Mask" },
|
|
12059
|
+
{ id: "type-vertical", label: "Vertical Type Mask" }
|
|
12060
|
+
];
|
|
12061
|
+
var COLOR_RANGE_PRESET_LABELS = {
|
|
12062
|
+
reds: "Reds",
|
|
12063
|
+
yellows: "Yellows",
|
|
12064
|
+
greens: "Greens",
|
|
12065
|
+
cyans: "Cyans",
|
|
12066
|
+
blues: "Blues",
|
|
12067
|
+
magentas: "Magentas",
|
|
12068
|
+
highlights: "Highlights",
|
|
12069
|
+
midtones: "Midtones",
|
|
12070
|
+
shadows: "Shadows",
|
|
12071
|
+
skinTones: "Skin Tones"
|
|
12072
|
+
};
|
|
12073
|
+
var SELECTION_MODE_LABELS = {
|
|
12074
|
+
replace: "New",
|
|
12075
|
+
add: "Add",
|
|
12076
|
+
subtract: "Subtract",
|
|
12077
|
+
intersect: "Intersect"
|
|
12078
|
+
};
|
|
12079
|
+
var DEFAULT_SELECTION_TOOL_OPTIONS = {
|
|
12080
|
+
tool: "wand",
|
|
12081
|
+
mode: "replace",
|
|
12082
|
+
tolerance: 32,
|
|
12083
|
+
contiguous: true,
|
|
12084
|
+
antiAlias: true,
|
|
12085
|
+
sampleMerged: false,
|
|
12086
|
+
distance: "rgb",
|
|
12087
|
+
feather: 0,
|
|
12088
|
+
fuzziness: 40,
|
|
12089
|
+
localized: 0,
|
|
12090
|
+
rangeInvert: false,
|
|
12091
|
+
magneticWidth: 10,
|
|
12092
|
+
magneticContrast: 10,
|
|
12093
|
+
magneticFrequency: 57,
|
|
12094
|
+
quickSize: 30,
|
|
12095
|
+
quickSampleAll: true,
|
|
12096
|
+
quickEnhance: false,
|
|
12097
|
+
objectSampleAll: true,
|
|
12098
|
+
objectEnhance: false,
|
|
12099
|
+
focusRange: 50,
|
|
12100
|
+
focusNoise: 0,
|
|
12101
|
+
focusSoftness: 4,
|
|
12102
|
+
typeText: "Type",
|
|
12103
|
+
typeSize: 72,
|
|
12104
|
+
typeFamily: "sans-serif"
|
|
12105
|
+
};
|
|
12106
|
+
function selectionModeFromModifiers(modifiers, fallback) {
|
|
12107
|
+
if (modifiers.shiftKey && modifiers.altKey) return "intersect";
|
|
12108
|
+
if (modifiers.shiftKey) return "add";
|
|
12109
|
+
if (modifiers.altKey) return "subtract";
|
|
12110
|
+
return fallback;
|
|
12111
|
+
}
|
|
12112
|
+
var REFINE_EDGE_CONTROLS = [
|
|
12113
|
+
{ id: "radius", label: "Radius", min: 0, max: 64, step: 1, unit: "px" },
|
|
12114
|
+
{ id: "smooth", label: "Smooth", min: 0, max: 100, step: 1, unit: "" },
|
|
12115
|
+
{ id: "feather", label: "Feather", min: 0, max: 50, step: 0.5, unit: "px" },
|
|
12116
|
+
{ id: "contrast", label: "Contrast", min: 0, max: 100, step: 1, unit: "%" },
|
|
12117
|
+
{ id: "shiftEdge", label: "Shift Edge", min: -100, max: 100, step: 1, unit: "%" }
|
|
12118
|
+
];
|
|
12119
|
+
var REFINE_OUTPUTS = [
|
|
12120
|
+
{ id: "selection", label: "Selection" },
|
|
12121
|
+
{ id: "layer-mask", label: "Layer Mask" },
|
|
12122
|
+
{ id: "new-layer", label: "New Layer" },
|
|
12123
|
+
{ id: "new-layer-with-mask", label: "New Layer with Layer Mask" },
|
|
12124
|
+
{ id: "new-document", label: "New Document", needsDocuments: true },
|
|
12125
|
+
{ id: "new-document-with-mask", label: "New Document with Layer Mask", needsDocuments: true }
|
|
12126
|
+
];
|
|
12127
|
+
function describeSelection(mask) {
|
|
12128
|
+
if (!mask || !mask.bounds) return "No selection";
|
|
12129
|
+
const pct2 = _chunk3ZRNK3ROcjs.selectionArea.call(void 0, mask) / (mask.width * mask.height) * 100;
|
|
12130
|
+
const shown = pct2 >= 10 ? Math.round(pct2) : Math.round(pct2 * 10) / 10;
|
|
12131
|
+
return `${mask.bounds.width} \xD7 ${mask.bounds.height} px selected (${shown}% of the image)`;
|
|
12132
|
+
}
|
|
12133
|
+
|
|
11731
12134
|
// src/image-editor/effect-tools.ts
|
|
11732
12135
|
var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
11733
12136
|
var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
|
|
@@ -11927,8 +12330,8 @@ function settingsSchema(forUpdate) {
|
|
|
11927
12330
|
}
|
|
11928
12331
|
function patternList(documentPatterns) {
|
|
11929
12332
|
const doc = documentPatterns.map((p) => ({ id: p.id, name: p.name, width: p.width, height: p.height, builtin: false }));
|
|
11930
|
-
const builtins =
|
|
11931
|
-
const p =
|
|
12333
|
+
const builtins = _chunkPVJMTLPJcjs.builtinPatternIds.call(void 0, ).map((id) => {
|
|
12334
|
+
const p = _chunkPVJMTLPJcjs.builtinPattern.call(void 0, id);
|
|
11932
12335
|
return { id, name: p.name, width: p.width, height: p.height, builtin: true };
|
|
11933
12336
|
});
|
|
11934
12337
|
return [...doc, ...builtins];
|
|
@@ -11937,9 +12340,9 @@ function describeLayerEffects(effects) {
|
|
|
11937
12340
|
return {
|
|
11938
12341
|
enabled: effects.enabled,
|
|
11939
12342
|
scale: _nullishCoalesce(effects.scale, () => ( 1)),
|
|
11940
|
-
margin:
|
|
12343
|
+
margin: _chunkPVJMTLPJcjs.effectsMargin.call(void 0, effects),
|
|
11941
12344
|
fromPsd: Boolean(effects.psd),
|
|
11942
|
-
effects: effects.items.map((e) => ({ ...JSON.parse(JSON.stringify(e)), label:
|
|
12345
|
+
effects: effects.items.map((e) => ({ ...JSON.parse(JSON.stringify(e)), label: _chunkPVJMTLPJcjs.layerEffectLabel.call(void 0, e.kind) }))
|
|
11943
12346
|
};
|
|
11944
12347
|
}
|
|
11945
12348
|
function createImageEffectTools(controller) {
|
|
@@ -11967,14 +12370,14 @@ function createLayerEffectTools(host, options) {
|
|
|
11967
12370
|
return id;
|
|
11968
12371
|
};
|
|
11969
12372
|
const result = (layerId, extra = {}) => ({ layerId, ...extra, ...describeLayerEffects(host.getLayerEffects(layerId)) });
|
|
11970
|
-
const globalLight = () => _nullishCoalesce(_optionalChain([host, 'access', _325 => _325.getGlobalLight, 'optionalCall', _326 => _326()]), () => ( { ...
|
|
12373
|
+
const globalLight = () => _nullishCoalesce(_optionalChain([host, 'access', _325 => _325.getGlobalLight, 'optionalCall', _326 => _326()]), () => ( { ..._chunkPVJMTLPJcjs.DEFAULT_GLOBAL_LIGHT }));
|
|
11971
12374
|
const list2 = {
|
|
11972
12375
|
name: "list_layer_effects",
|
|
11973
12376
|
title: "List layer effects",
|
|
11974
12377
|
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.",
|
|
11975
12378
|
inputSchema: { type: "object", properties: { layerId: LAYER_ID }, required: ["layerId"], additionalProperties: false },
|
|
11976
12379
|
annotations: { title: "List layer effects", ...READ },
|
|
11977
|
-
handler: ({ layerId }) => result(layerArg(layerId), { globalLight: globalLight(), patterns: patternList(_nullishCoalesce(_optionalChain([host, 'access', _327 => _327.getDocumentPatterns, 'optionalCall', _328 => _328()]), () => ( []))), kinds: [...
|
|
12380
|
+
handler: ({ layerId }) => result(layerArg(layerId), { globalLight: globalLight(), patterns: patternList(_nullishCoalesce(_optionalChain([host, 'access', _327 => _327.getDocumentPatterns, 'optionalCall', _328 => _328()]), () => ( []))), kinds: [..._chunkPVJMTLPJcjs.LAYER_EFFECT_KINDS] })
|
|
11978
12381
|
};
|
|
11979
12382
|
const add = {
|
|
11980
12383
|
name: "add_layer_effect",
|
|
@@ -11985,7 +12388,7 @@ function createLayerEffectTools(host, options) {
|
|
|
11985
12388
|
$defs: DEFS,
|
|
11986
12389
|
properties: {
|
|
11987
12390
|
layerId: LAYER_ID,
|
|
11988
|
-
kind: { type: "string", enum: [...
|
|
12391
|
+
kind: { type: "string", enum: [..._chunkPVJMTLPJcjs.LAYER_EFFECT_KINDS], description: "Effect kind." },
|
|
11989
12392
|
settings: settingsSchema(false),
|
|
11990
12393
|
index: { type: "integer", minimum: 0, description: "Position in the layer's effect list (default the end)." }
|
|
11991
12394
|
},
|
|
@@ -11995,7 +12398,7 @@ function createLayerEffectTools(host, options) {
|
|
|
11995
12398
|
annotations: { title: "Add a layer effect", ...WRITE },
|
|
11996
12399
|
handler: ({ layerId, kind, settings, index }) => {
|
|
11997
12400
|
const id = layerArg(layerId);
|
|
11998
|
-
if (!
|
|
12401
|
+
if (!_chunkPVJMTLPJcjs.isLayerEffectKind.call(void 0, kind)) throw error(`kind must be one of ${_chunkPVJMTLPJcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
|
|
11999
12402
|
const { effect } = host.addLayerEffect(id, kind, _nullishCoalesce(settings, () => ( {})), index);
|
|
12000
12403
|
return result(id, { effectId: effect.id });
|
|
12001
12404
|
}
|
|
@@ -12077,6 +12480,776 @@ function createLayerEffectTools(host, options) {
|
|
|
12077
12480
|
return host.setGlobalLight ? [list2, add, update, remove, setEnabled, light] : [list2, add, update, remove, setEnabled];
|
|
12078
12481
|
}
|
|
12079
12482
|
|
|
12483
|
+
// src/image-editor/selection/gesture.ts
|
|
12484
|
+
function snapTo45(from, point2) {
|
|
12485
|
+
const dx = point2.x - from.x;
|
|
12486
|
+
const dy = point2.y - from.y;
|
|
12487
|
+
const len = Math.hypot(dx, dy);
|
|
12488
|
+
if (len === 0) return point2;
|
|
12489
|
+
const a = Math.round(Math.atan2(dy, dx) / (Math.PI / 4)) * (Math.PI / 4);
|
|
12490
|
+
return { x: from.x + Math.cos(a) * len, y: from.y + Math.sin(a) * len };
|
|
12491
|
+
}
|
|
12492
|
+
var SelectionGesture = (_class5 = class {
|
|
12493
|
+
constructor(controller, getOptions) {;_class5.prototype.__init9.call(this);_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);_class5.prototype.__init17.call(this);_class5.prototype.__init18.call(this);_class5.prototype.__init19.call(this);_class5.prototype.__init20.call(this);_class5.prototype.__init21.call(this);
|
|
12494
|
+
this.controller = controller;
|
|
12495
|
+
this.getOptions = getOptions;
|
|
12496
|
+
}
|
|
12497
|
+
|
|
12498
|
+
|
|
12499
|
+
__init9() {this.start = null}
|
|
12500
|
+
__init10() {this.points = []}
|
|
12501
|
+
__init11() {this.current = null}
|
|
12502
|
+
__init12() {this.modifiers = {}}
|
|
12503
|
+
/** Polygonal lasso corners while one is being drawn. */
|
|
12504
|
+
__init13() {this.polygon = null}
|
|
12505
|
+
__init14() {this.pressedAt = null}
|
|
12506
|
+
__init15() {this.freehand = false}
|
|
12507
|
+
__init16() {this.magnetic = null}
|
|
12508
|
+
/** A click this close to the first corner (natural pixels) closes a polygonal lasso. */
|
|
12509
|
+
__init17() {this.closeRadius = 8}
|
|
12510
|
+
/** The last error (e.g. pixels unavailable for the wand), for the UI to show. */
|
|
12511
|
+
__init18() {this.error = null}
|
|
12512
|
+
__init19() {this.pending = Promise.resolve()}
|
|
12513
|
+
/** Quick Selection while dragging: the selection before the stroke, how the stroke combines, the pixels. */
|
|
12514
|
+
__init20() {this.quick = null}
|
|
12515
|
+
__init21() {this.livePreviews = Promise.resolve()}
|
|
12516
|
+
get active() {
|
|
12517
|
+
return this.start !== null || this.polygon !== null || this.magnetic !== null;
|
|
12518
|
+
}
|
|
12519
|
+
/** Resolves once a Quick Selection stroke or an Object Selection has been applied. */
|
|
12520
|
+
get settled() {
|
|
12521
|
+
return this.pending;
|
|
12522
|
+
}
|
|
12523
|
+
/** Resolves once no live Quick Selection preview is being computed. */
|
|
12524
|
+
get previewed() {
|
|
12525
|
+
return this.livePreviews;
|
|
12526
|
+
}
|
|
12527
|
+
/** Grows the Quick Selection preview to the stroke so far: one at a time, the newest points following. */
|
|
12528
|
+
growPreview() {
|
|
12529
|
+
const q2 = this.quick;
|
|
12530
|
+
if (!q2) return;
|
|
12531
|
+
if (q2.running) {
|
|
12532
|
+
q2.dirty = true;
|
|
12533
|
+
return;
|
|
12534
|
+
}
|
|
12535
|
+
q2.running = true;
|
|
12536
|
+
this.livePreviews = (async () => {
|
|
12537
|
+
do {
|
|
12538
|
+
q2.dirty = false;
|
|
12539
|
+
const stroke = this.points.slice();
|
|
12540
|
+
const options = this.getOptions();
|
|
12541
|
+
try {
|
|
12542
|
+
const pixels = await q2.pixels;
|
|
12543
|
+
if (!pixels || this.quick !== q2) break;
|
|
12544
|
+
const { mask } = await this.controller.runSelectionJob(
|
|
12545
|
+
{
|
|
12546
|
+
op: "quick",
|
|
12547
|
+
stroke,
|
|
12548
|
+
size: _nullishCoalesce(options.quickSize, () => ( 30)),
|
|
12549
|
+
grow: q2.mode === "add",
|
|
12550
|
+
enhanceEdge: _nullishCoalesce(options.quickEnhance, () => ( false)),
|
|
12551
|
+
selection: q2.mode === "add" && _optionalChain([q2, 'access', _329 => _329.base, 'optionalAccess', _330 => _330.bounds]) ? _chunk3ZRNK3ROcjs.serializeMask.call(void 0, q2.base) : null
|
|
12552
|
+
},
|
|
12553
|
+
pixels
|
|
12554
|
+
);
|
|
12555
|
+
if (this.quick === q2) this.controller.setSelectionPreview(_chunk3ZRNK3ROcjs.combineSelections.call(void 0, q2.base, mask, q2.mode));
|
|
12556
|
+
} catch (e28) {
|
|
12557
|
+
break;
|
|
12558
|
+
}
|
|
12559
|
+
} while (q2.dirty && this.quick === q2);
|
|
12560
|
+
q2.running = false;
|
|
12561
|
+
})();
|
|
12562
|
+
}
|
|
12563
|
+
/** The anchors of a Magnetic Lasso being drawn (empty otherwise). */
|
|
12564
|
+
get magneticAnchors() {
|
|
12565
|
+
const m = this.magnetic;
|
|
12566
|
+
return m ? m.anchors.map((i) => m.fixed[i]) : [];
|
|
12567
|
+
}
|
|
12568
|
+
/** The outline of the shape being drawn, or `null`. */
|
|
12569
|
+
get draftPath() {
|
|
12570
|
+
if (this.magnetic) return [...this.magnetic.fixed, ...this.magnetic.live.slice(1)];
|
|
12571
|
+
if (this.polygon) return this.current ? [...this.polygon, this.current] : this.polygon.slice();
|
|
12572
|
+
if (!this.start || !this.current) return null;
|
|
12573
|
+
const { tool } = this.getOptions();
|
|
12574
|
+
if (tool === "quick") return null;
|
|
12575
|
+
if (tool === "lasso") return this.points.length > 1 ? this.points.slice() : null;
|
|
12576
|
+
const rect = _chunk3ZRNK3ROcjs.normalizeRect.call(void 0, {
|
|
12577
|
+
x: this.start.x,
|
|
12578
|
+
y: this.start.y,
|
|
12579
|
+
width: this.current.x - this.start.x,
|
|
12580
|
+
height: this.current.y - this.start.y
|
|
12581
|
+
});
|
|
12582
|
+
if (rect.width < 1 && rect.height < 1) return null;
|
|
12583
|
+
if (tool === "ellipse") return _chunk3ZRNK3ROcjs.ellipsePoints.call(void 0, rect);
|
|
12584
|
+
return [
|
|
12585
|
+
{ x: rect.x, y: rect.y },
|
|
12586
|
+
{ x: rect.x + rect.width, y: rect.y },
|
|
12587
|
+
{ x: rect.x + rect.width, y: rect.y + rect.height },
|
|
12588
|
+
{ x: rect.x, y: rect.y + rect.height }
|
|
12589
|
+
];
|
|
12590
|
+
}
|
|
12591
|
+
/** Pointer down. Resolves once a wand click has been applied. */
|
|
12592
|
+
async begin(point2, modifiers = {}) {
|
|
12593
|
+
const options = this.getOptions();
|
|
12594
|
+
this.error = null;
|
|
12595
|
+
if (this.polygon && options.tool !== "polygon" || this.magnetic && options.tool !== "magnetic") this.cancel();
|
|
12596
|
+
if (options.tool === "magnetic") return this.magneticClick(point2, modifiers, options);
|
|
12597
|
+
if (options.tool === "polygon") {
|
|
12598
|
+
this.pressedAt = point2;
|
|
12599
|
+
this.freehand = false;
|
|
12600
|
+
if (!this.polygon) {
|
|
12601
|
+
this.modifiers = modifiers;
|
|
12602
|
+
this.polygon = [point2];
|
|
12603
|
+
this.current = point2;
|
|
12604
|
+
return;
|
|
12605
|
+
}
|
|
12606
|
+
const last = this.polygon[this.polygon.length - 1];
|
|
12607
|
+
const p = modifiers.shiftKey ? snapTo45(last, point2) : point2;
|
|
12608
|
+
const first = this.polygon[0];
|
|
12609
|
+
if (this.polygon.length >= 3 && Math.hypot(p.x - first.x, p.y - first.y) <= this.closeRadius) {
|
|
12610
|
+
this.close();
|
|
12611
|
+
return;
|
|
12612
|
+
}
|
|
12613
|
+
if (Math.hypot(p.x - last.x, p.y - last.y) >= 0.5) this.polygon.push(p);
|
|
12614
|
+
this.current = p;
|
|
12615
|
+
if ((_nullishCoalesce(modifiers.detail, () => ( 1))) >= 2) this.close();
|
|
12616
|
+
return;
|
|
12617
|
+
}
|
|
12618
|
+
this.modifiers = modifiers;
|
|
12619
|
+
if (options.tool === "row" || options.tool === "column") {
|
|
12620
|
+
this.start = null;
|
|
12621
|
+
try {
|
|
12622
|
+
this.controller.selectLine(options.tool, options.tool === "row" ? point2.y : point2.x, {
|
|
12623
|
+
mode: selectionModeFromModifiers(modifiers, options.mode),
|
|
12624
|
+
feather: _nullishCoalesce(options.feather, () => ( 0))
|
|
12625
|
+
});
|
|
12626
|
+
} catch (err) {
|
|
12627
|
+
this.error = err instanceof Error ? err.message : String(err);
|
|
12628
|
+
}
|
|
12629
|
+
return;
|
|
12630
|
+
}
|
|
12631
|
+
if (options.tool === "type" || options.tool === "type-vertical") {
|
|
12632
|
+
this.start = null;
|
|
12633
|
+
try {
|
|
12634
|
+
this.controller.selectTextShape({
|
|
12635
|
+
text: options.typeText || "Type",
|
|
12636
|
+
x: point2.x,
|
|
12637
|
+
y: point2.y,
|
|
12638
|
+
orientation: options.tool === "type-vertical" ? "vertical" : "horizontal",
|
|
12639
|
+
style: { fontSize: _nullishCoalesce(options.typeSize, () => ( 72)), fontFamily: options.typeFamily || "sans-serif" },
|
|
12640
|
+
mode: selectionModeFromModifiers(modifiers, options.mode),
|
|
12641
|
+
feather: _nullishCoalesce(options.feather, () => ( 0)),
|
|
12642
|
+
antiAlias: options.antiAlias
|
|
12643
|
+
});
|
|
12644
|
+
} catch (err) {
|
|
12645
|
+
this.error = err instanceof Error ? err.message : String(err);
|
|
12646
|
+
}
|
|
12647
|
+
return;
|
|
12648
|
+
}
|
|
12649
|
+
if (options.tool === "wand" || options.tool === "range") {
|
|
12650
|
+
this.start = null;
|
|
12651
|
+
const common2 = {
|
|
12652
|
+
sampleMerged: options.sampleMerged,
|
|
12653
|
+
sample: options.sample,
|
|
12654
|
+
feather: _nullishCoalesce(options.feather, () => ( 0)),
|
|
12655
|
+
mode: selectionModeFromModifiers(modifiers, options.mode)
|
|
12656
|
+
};
|
|
12657
|
+
try {
|
|
12658
|
+
if (options.tool === "range") {
|
|
12659
|
+
const pixels = await this.controller.getSamplePixels(common2);
|
|
12660
|
+
if (!pixels) throw new Error("The image pixels are not available to sample.");
|
|
12661
|
+
const x = Math.min(pixels.width - 1, Math.max(0, Math.floor(point2.x)));
|
|
12662
|
+
const y = Math.min(pixels.height - 1, Math.max(0, Math.floor(point2.y)));
|
|
12663
|
+
const p = (y * pixels.width + x) * 4;
|
|
12664
|
+
const color = [pixels.data[p], pixels.data[p + 1], pixels.data[p + 2]];
|
|
12665
|
+
await this.controller.selectColorRange([{ color, at: point2 }], {
|
|
12666
|
+
...common2,
|
|
12667
|
+
fuzziness: _nullishCoalesce(options.fuzziness, () => ( 40)),
|
|
12668
|
+
localized: options.localized ? options.localized : void 0,
|
|
12669
|
+
invert: _nullishCoalesce(options.rangeInvert, () => ( false))
|
|
12670
|
+
});
|
|
12671
|
+
return;
|
|
12672
|
+
}
|
|
12673
|
+
await this.controller.magicWand(point2, {
|
|
12674
|
+
...common2,
|
|
12675
|
+
tolerance: options.tolerance,
|
|
12676
|
+
contiguous: options.contiguous,
|
|
12677
|
+
antiAlias: options.antiAlias,
|
|
12678
|
+
distance: options.distance
|
|
12679
|
+
});
|
|
12680
|
+
} catch (err) {
|
|
12681
|
+
this.error = err instanceof Error ? err.message : String(err);
|
|
12682
|
+
}
|
|
12683
|
+
return;
|
|
12684
|
+
}
|
|
12685
|
+
this.start = point2;
|
|
12686
|
+
this.current = point2;
|
|
12687
|
+
this.points = [point2];
|
|
12688
|
+
if (options.tool === "quick") {
|
|
12689
|
+
const picked = selectionModeFromModifiers(modifiers, options.mode);
|
|
12690
|
+
const base = this.controller.getSelection();
|
|
12691
|
+
this.quick = {
|
|
12692
|
+
base,
|
|
12693
|
+
mode: picked === "replace" && base ? "add" : picked,
|
|
12694
|
+
pixels: this.controller.getSamplePixels({ sample: options.quickSampleAll === false ? "active-layer" : "composite" }).catch(() => null),
|
|
12695
|
+
running: false,
|
|
12696
|
+
dirty: false
|
|
12697
|
+
};
|
|
12698
|
+
this.growPreview();
|
|
12699
|
+
}
|
|
12700
|
+
}
|
|
12701
|
+
/** Pointer move; returns true when the draft changed (re-render). */
|
|
12702
|
+
move(point2, modifiers = {}) {
|
|
12703
|
+
if (this.magnetic) {
|
|
12704
|
+
this.current = point2;
|
|
12705
|
+
this.followEdges(point2);
|
|
12706
|
+
return true;
|
|
12707
|
+
}
|
|
12708
|
+
if (this.polygon) {
|
|
12709
|
+
const last = this.polygon[this.polygon.length - 1];
|
|
12710
|
+
if (this.pressedAt && (this.freehand || Math.hypot(point2.x - this.pressedAt.x, point2.y - this.pressedAt.y) >= 3)) {
|
|
12711
|
+
this.freehand = true;
|
|
12712
|
+
if (Math.hypot(point2.x - last.x, point2.y - last.y) >= 0.5) this.polygon.push(point2);
|
|
12713
|
+
this.current = null;
|
|
12714
|
+
return true;
|
|
12715
|
+
}
|
|
12716
|
+
this.current = modifiers.shiftKey ? snapTo45(last, point2) : point2;
|
|
12717
|
+
return true;
|
|
12718
|
+
}
|
|
12719
|
+
if (!this.start) return false;
|
|
12720
|
+
this.current = point2;
|
|
12721
|
+
const drawn = this.getOptions().tool;
|
|
12722
|
+
if (drawn === "lasso" || drawn === "quick") {
|
|
12723
|
+
const last = this.points[this.points.length - 1];
|
|
12724
|
+
if (Math.hypot(point2.x - last.x, point2.y - last.y) < 0.5) return false;
|
|
12725
|
+
this.points.push(point2);
|
|
12726
|
+
if (drawn === "quick") this.growPreview();
|
|
12727
|
+
}
|
|
12728
|
+
return true;
|
|
12729
|
+
}
|
|
12730
|
+
/** Pointer up: commits the shape. Returns true when the selection changed. */
|
|
12731
|
+
end(point2, modifiers) {
|
|
12732
|
+
if (this.magnetic) return false;
|
|
12733
|
+
if (this.polygon) {
|
|
12734
|
+
if (point2 && this.freehand) this.move(point2);
|
|
12735
|
+
this.pressedAt = null;
|
|
12736
|
+
this.freehand = false;
|
|
12737
|
+
return false;
|
|
12738
|
+
}
|
|
12739
|
+
if (!this.start) return false;
|
|
12740
|
+
if (point2) this.move(point2);
|
|
12741
|
+
const options = this.getOptions();
|
|
12742
|
+
const mode = selectionModeFromModifiers(_nullishCoalesce(modifiers, () => ( this.modifiers)), options.mode);
|
|
12743
|
+
if (options.tool === "object") {
|
|
12744
|
+
const rect2 = _chunk3ZRNK3ROcjs.normalizeRect.call(void 0, { x: this.start.x, y: this.start.y, width: this.current.x - this.start.x, height: this.current.y - this.start.y });
|
|
12745
|
+
this.start = null;
|
|
12746
|
+
this.current = null;
|
|
12747
|
+
this.points = [];
|
|
12748
|
+
const target = rect2.width >= 4 && rect2.height >= 4 ? { rect: rect2 } : { point: { x: rect2.x + rect2.width / 2, y: rect2.y + rect2.height / 2 } };
|
|
12749
|
+
this.pending = this.controller.selectObject(target, { mode, sampleAllLayers: _nullishCoalesce(options.objectSampleAll, () => ( true)), enhanceEdge: _nullishCoalesce(options.objectEnhance, () => ( false)) }).then(
|
|
12750
|
+
() => void 0,
|
|
12751
|
+
(err) => {
|
|
12752
|
+
this.error = err instanceof Error ? err.message : String(err);
|
|
12753
|
+
}
|
|
12754
|
+
);
|
|
12755
|
+
return false;
|
|
12756
|
+
}
|
|
12757
|
+
if (options.tool === "quick") {
|
|
12758
|
+
const stroke = this.points;
|
|
12759
|
+
this.start = null;
|
|
12760
|
+
this.current = null;
|
|
12761
|
+
this.points = [];
|
|
12762
|
+
const strokeMode = _nullishCoalesce(_optionalChain([this, 'access', _331 => _331.quick, 'optionalAccess', _332 => _332.mode]), () => ( (mode === "replace" && this.controller.getSelection() ? "add" : mode)));
|
|
12763
|
+
this.quick = null;
|
|
12764
|
+
this.pending = this.controller.quickSelect([stroke], {
|
|
12765
|
+
size: _nullishCoalesce(options.quickSize, () => ( 30)),
|
|
12766
|
+
mode: strokeMode,
|
|
12767
|
+
sampleAllLayers: _nullishCoalesce(options.quickSampleAll, () => ( true)),
|
|
12768
|
+
enhanceEdge: _nullishCoalesce(options.quickEnhance, () => ( false))
|
|
12769
|
+
}).then(
|
|
12770
|
+
() => void 0,
|
|
12771
|
+
(err) => {
|
|
12772
|
+
this.error = err instanceof Error ? err.message : String(err);
|
|
12773
|
+
}
|
|
12774
|
+
).finally(() => this.controller.setSelectionPreview(void 0));
|
|
12775
|
+
return false;
|
|
12776
|
+
}
|
|
12777
|
+
const path = this.draftPath;
|
|
12778
|
+
const rect = _chunk3ZRNK3ROcjs.normalizeRect.call(void 0, {
|
|
12779
|
+
x: this.start.x,
|
|
12780
|
+
y: this.start.y,
|
|
12781
|
+
width: this.current.x - this.start.x,
|
|
12782
|
+
height: this.current.y - this.start.y
|
|
12783
|
+
});
|
|
12784
|
+
this.start = null;
|
|
12785
|
+
this.current = null;
|
|
12786
|
+
this.points = [];
|
|
12787
|
+
if (!path) return mode === "replace" ? this.controller.deselect() : false;
|
|
12788
|
+
const opts = { mode, antiAlias: options.antiAlias, feather: _nullishCoalesce(options.feather, () => ( 0)) };
|
|
12789
|
+
if (options.tool === "lasso") return path.length >= 3 ? this.controller.selectPolygon(path, opts) : false;
|
|
12790
|
+
return options.tool === "ellipse" ? this.controller.selectEllipse(rect, opts) : this.controller.selectRect(rect, opts);
|
|
12791
|
+
}
|
|
12792
|
+
/** Closes a polygonal lasso and selects it. Returns true when the selection changed. */
|
|
12793
|
+
close() {
|
|
12794
|
+
let polygon2 = this.polygon;
|
|
12795
|
+
const m = this.magnetic;
|
|
12796
|
+
if (m) {
|
|
12797
|
+
const tail = m.edges && m.fixed.length > 1 ? liveWire(m.edges, m.fixed[m.fixed.length - 1], m.fixed[0], this.corridor(m.fixed[m.fixed.length - 1], m.fixed[0])) : [];
|
|
12798
|
+
polygon2 = simplifyPixelPath([...m.fixed, ...tail.slice(1, -1)]);
|
|
12799
|
+
}
|
|
12800
|
+
if (!polygon2) return false;
|
|
12801
|
+
const options = this.getOptions();
|
|
12802
|
+
this.cancel();
|
|
12803
|
+
if (polygon2.length < 3) return false;
|
|
12804
|
+
return this.controller.selectPolygon(polygon2, {
|
|
12805
|
+
mode: selectionModeFromModifiers(this.modifiers, options.mode),
|
|
12806
|
+
antiAlias: options.antiAlias,
|
|
12807
|
+
feather: _nullishCoalesce(options.feather, () => ( 0))
|
|
12808
|
+
});
|
|
12809
|
+
}
|
|
12810
|
+
/**
|
|
12811
|
+
* Keys for a polygonal lasso being drawn: Enter closes it, Escape cancels, Backspace / Delete
|
|
12812
|
+
* removes the last corner. Returns true when the key was used (the host prevents its default).
|
|
12813
|
+
*/
|
|
12814
|
+
key(key) {
|
|
12815
|
+
if (!this.polygon && !this.magnetic) return false;
|
|
12816
|
+
if (key === "Enter") this.close();
|
|
12817
|
+
else if (key === "Escape") this.cancel();
|
|
12818
|
+
else if (key === "Backspace" || key === "Delete") {
|
|
12819
|
+
const m = this.magnetic;
|
|
12820
|
+
if (m) {
|
|
12821
|
+
m.anchors.pop();
|
|
12822
|
+
if (!m.anchors.length) this.cancel();
|
|
12823
|
+
else {
|
|
12824
|
+
m.fixed.length = m.anchors[m.anchors.length - 1] + 1;
|
|
12825
|
+
m.live = [];
|
|
12826
|
+
if (this.current) this.followEdges(this.current, false);
|
|
12827
|
+
}
|
|
12828
|
+
} else {
|
|
12829
|
+
this.polygon.pop();
|
|
12830
|
+
if (!this.polygon.length) this.cancel();
|
|
12831
|
+
}
|
|
12832
|
+
} else return false;
|
|
12833
|
+
return true;
|
|
12834
|
+
}
|
|
12835
|
+
/** Corridor half-width for a live-wire between two points. */
|
|
12836
|
+
corridor(a, b) {
|
|
12837
|
+
return Math.max(2 * (_nullishCoalesce(this.getOptions().magneticWidth, () => ( 10))), 16, Math.hypot(b.x - a.x, b.y - a.y) / 4);
|
|
12838
|
+
}
|
|
12839
|
+
async magneticClick(point2, modifiers, options) {
|
|
12840
|
+
const m = this.magnetic;
|
|
12841
|
+
if (!m) {
|
|
12842
|
+
this.modifiers = modifiers;
|
|
12843
|
+
const draft = { fixed: [point2], anchors: [0], live: [], edges: null };
|
|
12844
|
+
this.magnetic = draft;
|
|
12845
|
+
this.current = point2;
|
|
12846
|
+
try {
|
|
12847
|
+
const pixels = await this.controller.getSamplePixels({ sampleMerged: options.sampleMerged, sample: options.sample });
|
|
12848
|
+
if (!pixels) throw new Error("The image pixels are not available to find edges in.");
|
|
12849
|
+
if (this.magnetic !== draft) return;
|
|
12850
|
+
draft.edges = new EdgeMap(pixels, { contrast: (_nullishCoalesce(options.magneticContrast, () => ( 10))) / 100 });
|
|
12851
|
+
draft.fixed = [snapToEdge(draft.edges, point2, _nullishCoalesce(options.magneticWidth, () => ( 10)))];
|
|
12852
|
+
if (this.current) this.followEdges(this.current);
|
|
12853
|
+
} catch (err) {
|
|
12854
|
+
this.error = err instanceof Error ? err.message : String(err);
|
|
12855
|
+
if (this.magnetic === draft) this.cancel();
|
|
12856
|
+
}
|
|
12857
|
+
return;
|
|
12858
|
+
}
|
|
12859
|
+
const first = m.fixed[0];
|
|
12860
|
+
if (m.anchors.length >= 2 && Math.hypot(point2.x - first.x, point2.y - first.y) <= this.closeRadius) {
|
|
12861
|
+
this.close();
|
|
12862
|
+
return;
|
|
12863
|
+
}
|
|
12864
|
+
this.current = point2;
|
|
12865
|
+
this.followEdges(point2);
|
|
12866
|
+
if (m.live.length > 1) {
|
|
12867
|
+
m.fixed.push(...m.live.slice(1));
|
|
12868
|
+
m.anchors.push(m.fixed.length - 1);
|
|
12869
|
+
m.live = [];
|
|
12870
|
+
}
|
|
12871
|
+
if ((_nullishCoalesce(modifiers.detail, () => ( 1))) >= 2) this.close();
|
|
12872
|
+
}
|
|
12873
|
+
/** Updates the live path to `point`, fixing anchors along it every `frequency` px (with `place`). */
|
|
12874
|
+
followEdges(point2, place = true) {
|
|
12875
|
+
const m = this.magnetic;
|
|
12876
|
+
const last = () => m.fixed[m.fixed.length - 1];
|
|
12877
|
+
if (!m.edges) {
|
|
12878
|
+
m.live = [last(), point2];
|
|
12879
|
+
return;
|
|
12880
|
+
}
|
|
12881
|
+
const options = this.getOptions();
|
|
12882
|
+
const target = snapToEdge(m.edges, point2, _nullishCoalesce(options.magneticWidth, () => ( 10)));
|
|
12883
|
+
const spacing = magneticAnchorSpacing(_nullishCoalesce(options.magneticFrequency, () => ( 57)));
|
|
12884
|
+
for (let guard2 = 0; guard2 < 64; guard2++) {
|
|
12885
|
+
const path = liveWire(m.edges, last(), target, this.corridor(last(), target));
|
|
12886
|
+
let length = 0;
|
|
12887
|
+
let k = 0;
|
|
12888
|
+
for (k = 1; k < path.length; k++) {
|
|
12889
|
+
length += Math.hypot(path[k].x - path[k - 1].x, path[k].y - path[k - 1].y);
|
|
12890
|
+
if (length >= spacing) break;
|
|
12891
|
+
}
|
|
12892
|
+
if (!place || k >= path.length - 1) {
|
|
12893
|
+
m.live = path;
|
|
12894
|
+
return;
|
|
12895
|
+
}
|
|
12896
|
+
m.fixed.push(...path.slice(1, k + 1));
|
|
12897
|
+
m.anchors.push(m.fixed.length - 1);
|
|
12898
|
+
}
|
|
12899
|
+
m.live = [last(), target];
|
|
12900
|
+
}
|
|
12901
|
+
/** Abandons a drag (or a polygonal lasso) without changing the selection. */
|
|
12902
|
+
cancel() {
|
|
12903
|
+
if (this.quick) {
|
|
12904
|
+
this.quick = null;
|
|
12905
|
+
this.controller.setSelectionPreview(void 0);
|
|
12906
|
+
}
|
|
12907
|
+
this.start = null;
|
|
12908
|
+
this.current = null;
|
|
12909
|
+
this.points = [];
|
|
12910
|
+
this.polygon = null;
|
|
12911
|
+
this.magnetic = null;
|
|
12912
|
+
this.pressedAt = null;
|
|
12913
|
+
this.freehand = false;
|
|
12914
|
+
}
|
|
12915
|
+
}, _class5);
|
|
12916
|
+
function handleSelectionShortcut(controller, e, onError) {
|
|
12917
|
+
if (!(e.ctrlKey || e.metaKey)) return false;
|
|
12918
|
+
const key = e.key.toLowerCase();
|
|
12919
|
+
const run = (fn) => {
|
|
12920
|
+
try {
|
|
12921
|
+
fn();
|
|
12922
|
+
} catch (err) {
|
|
12923
|
+
_optionalChain([onError, 'optionalCall', _333 => _333(err instanceof Error ? err.message : String(err))]);
|
|
12924
|
+
}
|
|
12925
|
+
return true;
|
|
12926
|
+
};
|
|
12927
|
+
if (key === "c") return run(() => controller.copyPixels({ merged: Boolean(e.shiftKey) }));
|
|
12928
|
+
if (key === "x" && !e.shiftKey) return run(() => controller.cutPixels());
|
|
12929
|
+
if (key === "v") return run(() => controller.pastePixels(e.shiftKey && e.altKey ? "into" : e.shiftKey ? "in-place" : "new-layer"));
|
|
12930
|
+
if (key === "d") return run(() => e.shiftKey ? controller.reselect() : controller.deselect());
|
|
12931
|
+
if (key === "i" && e.shiftKey) return run(() => controller.invertSelection());
|
|
12932
|
+
return false;
|
|
12933
|
+
}
|
|
12934
|
+
function handleMaskViewKey(controller, e) {
|
|
12935
|
+
if (e.ctrlKey || e.metaKey || e.altKey || e.key !== "\\") return false;
|
|
12936
|
+
const id = controller.getState().activeLayerId;
|
|
12937
|
+
const layer = id ? controller.getLayer(id) : null;
|
|
12938
|
+
if (!_optionalChain([layer, 'optionalAccess', _334 => _334.mask]) || layer.mask.source) return false;
|
|
12939
|
+
const view = controller.getMaskView();
|
|
12940
|
+
controller.setMaskView(_optionalChain([view, 'optionalAccess', _335 => _335.layerId]) === layer.id && view.mode === "overlay" ? "off" : "overlay", layer.id);
|
|
12941
|
+
return true;
|
|
12942
|
+
}
|
|
12943
|
+
function handleQuickMaskKey(controller, e) {
|
|
12944
|
+
if (e.ctrlKey || e.metaKey || e.altKey || e.key.toLowerCase() !== "q") return false;
|
|
12945
|
+
controller.setQuickMaskMode(!controller.quickMaskEditing);
|
|
12946
|
+
return true;
|
|
12947
|
+
}
|
|
12948
|
+
|
|
12949
|
+
// src/image-editor/layers/paint-ui.ts
|
|
12950
|
+
var plain = { kind: "plain" };
|
|
12951
|
+
var BRUSH_OPTION_CONTROLS = [
|
|
12952
|
+
{ id: "size", label: "Size", section: "layer", min: 1, max: 500, step: 1, default: 20, decimals: 0, track: plain, unit: "px" },
|
|
12953
|
+
{ id: "hardness", label: "Hardness", section: "layer", min: 0, max: 1, step: 0.01, default: 1, decimals: 0, track: plain, displayScale: 100, unit: "%" },
|
|
12954
|
+
{ id: "opacity", label: "Opacity", section: "layer", min: 0, max: 1, step: 0.01, default: 1, decimals: 0, track: plain, displayScale: 100, unit: "%" },
|
|
12955
|
+
{ id: "flow", label: "Flow", section: "layer", min: 0, max: 1, step: 0.01, default: 1, decimals: 0, track: plain, displayScale: 100, unit: "%" },
|
|
12956
|
+
{ id: "smoothing", label: "Smoothing", section: "layer", min: 0, max: 0.95, step: 0.01, default: 0, decimals: 0, track: plain, displayScale: 100, unit: "%" }
|
|
12957
|
+
];
|
|
12958
|
+
var MIXER_OPTION_CONTROLS = [
|
|
12959
|
+
{ id: "wet", label: "Wet", section: "layer", min: 0, max: 1, step: 0.01, default: 0.5, decimals: 0, track: plain, displayScale: 100, unit: "%" },
|
|
12960
|
+
{ id: "load", label: "Load", section: "layer", min: 0, max: 1, step: 0.01, default: 0.5, decimals: 0, track: plain, displayScale: 100, unit: "%" },
|
|
12961
|
+
{ id: "mix", label: "Mix", section: "layer", min: 0, max: 1, step: 0.01, default: 0.5, decimals: 0, track: plain, displayScale: 100, unit: "%" }
|
|
12962
|
+
];
|
|
12963
|
+
var MIXER_MIXING_OPTIONS = [
|
|
12964
|
+
{ id: "rgb", label: "RGB", title: "Mix colours as RGB averages" },
|
|
12965
|
+
{ id: "pigment", label: "Pigment", title: "Mix colours like paint: blue and yellow make green" }
|
|
12966
|
+
];
|
|
12967
|
+
var PAINT_TOOLS = [
|
|
12968
|
+
{ id: "move", label: "Move", shortcut: "V" },
|
|
12969
|
+
{ id: "brush", label: "Brush", shortcut: "B" },
|
|
12970
|
+
{ id: "mixer", label: "Mixer", shortcut: "Shift+B" },
|
|
12971
|
+
{ id: "eraser", label: "Eraser", shortcut: "E" },
|
|
12972
|
+
{ id: "clone", label: "Clone", shortcut: "S" },
|
|
12973
|
+
{ id: "heal", label: "Heal", shortcut: "Shift+J" },
|
|
12974
|
+
{ id: "spot-heal", label: "Spot Heal", shortcut: "J" },
|
|
12975
|
+
{ id: "smudge", label: "Smudge", shortcut: "" },
|
|
12976
|
+
{ id: "dodge", label: "Dodge", shortcut: "O" },
|
|
12977
|
+
{ id: "burn", label: "Burn", shortcut: "Shift+O" },
|
|
12978
|
+
{ id: "sponge", label: "Sponge", shortcut: "Shift+O" },
|
|
12979
|
+
{ id: "blur", label: "Blur", shortcut: "" },
|
|
12980
|
+
{ id: "sharpen", label: "Sharpen", shortcut: "" },
|
|
12981
|
+
{ id: "history", label: "History", shortcut: "Y" }
|
|
12982
|
+
];
|
|
12983
|
+
var isPaintTool = (tool) => PAINT_TOOLS.some((t) => t.id === tool);
|
|
12984
|
+
var isRetouchPaintTool = (tool) => tool === "clone" || tool === "heal" || tool === "spot-heal" || tool === "smudge" || tool === "dodge" || tool === "burn" || tool === "sponge" || tool === "blur" || tool === "sharpen" || tool === "history";
|
|
12985
|
+
var RETOUCH_OPTION_CONTROLS = [
|
|
12986
|
+
{ id: "exposure", label: "Exposure", section: "layer", min: 0, max: 1, step: 0.01, default: 0.5, decimals: 0, track: plain, displayScale: 100, unit: "%", tools: ["dodge", "burn"] },
|
|
12987
|
+
{ id: "strength", label: "Strength", section: "layer", min: 0, max: 1, step: 0.01, default: 0.5, decimals: 0, track: plain, displayScale: 100, unit: "%", tools: ["smudge", "blur", "sharpen"] },
|
|
12988
|
+
{ id: "historySteps", label: "Steps back", section: "layer", min: 0, max: 50, step: 1, default: 0, decimals: 0, track: plain, unit: "", tools: ["history"] }
|
|
12989
|
+
];
|
|
12990
|
+
var CLONE_TRANSFORM_CONTROLS = [
|
|
12991
|
+
{ id: "width", label: "Source W", section: "layer", min: 1, max: 400, step: 1, default: 100, decimals: 0, track: plain, unit: "%" },
|
|
12992
|
+
{ id: "height", label: "Source H", section: "layer", min: 1, max: 400, step: 1, default: 100, decimals: 0, track: plain, unit: "%" },
|
|
12993
|
+
{ id: "angle", label: "Source angle", section: "layer", min: -180, max: 180, step: 1, default: 0, decimals: 0, track: plain, unit: "\xB0" }
|
|
12994
|
+
];
|
|
12995
|
+
function cloneTransformView(controller) {
|
|
12996
|
+
const t = controller.getState().paint.cloneTransform;
|
|
12997
|
+
return {
|
|
12998
|
+
width: Math.round(Math.abs(t.scaleX) * 100),
|
|
12999
|
+
height: Math.round(Math.abs(t.scaleY) * 100),
|
|
13000
|
+
angle: t.rotate,
|
|
13001
|
+
flipH: t.scaleX < 0,
|
|
13002
|
+
flipV: t.scaleY < 0,
|
|
13003
|
+
identity: t.scaleX === 1 && t.scaleY === 1 && t.rotate === 0
|
|
13004
|
+
};
|
|
13005
|
+
}
|
|
13006
|
+
function setCloneTransformValue(controller, id, value) {
|
|
13007
|
+
const t = controller.getState().paint.cloneTransform;
|
|
13008
|
+
if (id === "width") controller.setCloneTransform({ scaleX: Math.sign(t.scaleX) * (_nullishCoalesce(value, () => ( 100))) / 100 });
|
|
13009
|
+
else if (id === "height") controller.setCloneTransform({ scaleY: Math.sign(t.scaleY) * (_nullishCoalesce(value, () => ( 100))) / 100 });
|
|
13010
|
+
else if (id === "angle") controller.setCloneTransform({ rotate: _nullishCoalesce(value, () => ( 0)) });
|
|
13011
|
+
else if (id === "flipH") controller.setCloneTransform({ scaleX: -t.scaleX });
|
|
13012
|
+
else controller.setCloneTransform({ scaleY: -t.scaleY });
|
|
13013
|
+
}
|
|
13014
|
+
var RETOUCH_CHOICES = [
|
|
13015
|
+
{
|
|
13016
|
+
id: "sample",
|
|
13017
|
+
label: "Sample",
|
|
13018
|
+
tools: ["clone", "heal", "spot-heal"],
|
|
13019
|
+
options: [
|
|
13020
|
+
{ id: "current", label: "Current", title: "Sample the layer being retouched" },
|
|
13021
|
+
{ id: "current-below", label: "Current & Below", title: "Sample this layer and the layers under it" },
|
|
13022
|
+
{ id: "all", label: "All", title: "Sample every layer (retouch onto an empty layer)" }
|
|
13023
|
+
]
|
|
13024
|
+
},
|
|
13025
|
+
{
|
|
13026
|
+
id: "spotType",
|
|
13027
|
+
label: "Type",
|
|
13028
|
+
tools: ["spot-heal"],
|
|
13029
|
+
options: [
|
|
13030
|
+
{ id: "proximity-match", label: "Proximity Match", title: "Copy the best matching patch nearby" },
|
|
13031
|
+
{ id: "content-aware", label: "Content-Aware", title: "Synthesise texture and edges from patches around the spot" },
|
|
13032
|
+
{ id: "smooth", label: "Smooth", title: "Fill smoothly from the edges" }
|
|
13033
|
+
]
|
|
13034
|
+
},
|
|
13035
|
+
{
|
|
13036
|
+
id: "range",
|
|
13037
|
+
label: "Range",
|
|
13038
|
+
tools: ["dodge", "burn"],
|
|
13039
|
+
options: [
|
|
13040
|
+
{ id: "shadows", label: "Shadows", title: "Change the dark tones most" },
|
|
13041
|
+
{ id: "midtones", label: "Midtones", title: "Change the middle tones most" },
|
|
13042
|
+
{ id: "highlights", label: "Highlights", title: "Change the light tones most" }
|
|
13043
|
+
]
|
|
13044
|
+
},
|
|
13045
|
+
{
|
|
13046
|
+
id: "spongeMode",
|
|
13047
|
+
label: "Mode",
|
|
13048
|
+
tools: ["sponge"],
|
|
13049
|
+
options: [
|
|
13050
|
+
{ id: "desaturate", label: "Desaturate", title: "Take colour out" },
|
|
13051
|
+
{ id: "saturate", label: "Saturate", title: "Add colour" }
|
|
13052
|
+
]
|
|
13053
|
+
}
|
|
13054
|
+
];
|
|
13055
|
+
var RETOUCH_TOGGLES = [
|
|
13056
|
+
{ id: "aligned", label: "Aligned", tools: ["clone", "heal"] },
|
|
13057
|
+
{ id: "protectTones", label: "Protect tones", tools: ["dodge", "burn"] },
|
|
13058
|
+
{ id: "vibrance", label: "Vibrance", tools: ["sponge"] }
|
|
13059
|
+
];
|
|
13060
|
+
function setRetouchChoice(controller, id, value) {
|
|
13061
|
+
controller.setPaintOptions({ retouch: { [id]: value } });
|
|
13062
|
+
}
|
|
13063
|
+
function cloneSourceLabel(controller) {
|
|
13064
|
+
const cs = controller.getState().paint.cloneSource;
|
|
13065
|
+
return cs ? `Source ${cs.x}, ${cs.y}${cs.offset ? ` (offset ${cs.offset.x}, ${cs.offset.y})` : ""}` : "Alt-click to set the source";
|
|
13066
|
+
}
|
|
13067
|
+
function rgbUnitToHex(c) {
|
|
13068
|
+
return `#${c.map((v) => Math.round(Math.min(1, Math.max(0, v)) * 255).toString(16).padStart(2, "0")).join("")}`;
|
|
13069
|
+
}
|
|
13070
|
+
function sizeStep(size) {
|
|
13071
|
+
return size < 10 ? 1 : size < 50 ? 5 : size < 100 ? 10 : size < 200 ? 25 : size < 500 ? 50 : 100;
|
|
13072
|
+
}
|
|
13073
|
+
var isTyping = (t) => {
|
|
13074
|
+
const el = t;
|
|
13075
|
+
return Boolean(el && (el.isContentEditable || el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT"));
|
|
13076
|
+
};
|
|
13077
|
+
function handlePaintShortcut(controller, e) {
|
|
13078
|
+
if (e.ctrlKey || e.metaKey || e.altKey || isTyping(e.target)) return false;
|
|
13079
|
+
const brush = controller.getState().paint.brush;
|
|
13080
|
+
const set = (b) => controller.setPaintOptions({ brush: b });
|
|
13081
|
+
const key = e.key;
|
|
13082
|
+
if (handleMaskViewKey(controller, e)) return true;
|
|
13083
|
+
switch (key.toLowerCase()) {
|
|
13084
|
+
case "q":
|
|
13085
|
+
controller.setQuickMaskMode(!controller.quickMaskEditing);
|
|
13086
|
+
return true;
|
|
13087
|
+
case "b":
|
|
13088
|
+
controller.setTool(e.shiftKey || key === "B" ? "mixer" : "brush");
|
|
13089
|
+
return true;
|
|
13090
|
+
case "e":
|
|
13091
|
+
controller.setTool("eraser");
|
|
13092
|
+
return true;
|
|
13093
|
+
case "v":
|
|
13094
|
+
controller.setTool("move");
|
|
13095
|
+
return true;
|
|
13096
|
+
case "s":
|
|
13097
|
+
controller.setTool("clone");
|
|
13098
|
+
return true;
|
|
13099
|
+
case "j":
|
|
13100
|
+
controller.setTool(e.shiftKey || key === "J" ? controller.getState().activeTool === "heal" ? "spot-heal" : "heal" : "spot-heal");
|
|
13101
|
+
return true;
|
|
13102
|
+
case "o": {
|
|
13103
|
+
const cur = controller.getState().activeTool;
|
|
13104
|
+
const next = e.shiftKey || key === "O" ? cur === "dodge" ? "burn" : cur === "burn" ? "sponge" : "dodge" : "dodge";
|
|
13105
|
+
controller.setTool(next);
|
|
13106
|
+
return true;
|
|
13107
|
+
}
|
|
13108
|
+
case "y":
|
|
13109
|
+
controller.setTool("history");
|
|
13110
|
+
return true;
|
|
13111
|
+
case "d":
|
|
13112
|
+
controller.resetPaintColors();
|
|
13113
|
+
return true;
|
|
13114
|
+
case "x":
|
|
13115
|
+
controller.swapPaintColors();
|
|
13116
|
+
return true;
|
|
13117
|
+
}
|
|
13118
|
+
if (key === "[" || key === "{") {
|
|
13119
|
+
if (e.shiftKey || key === "{") set({ hardness: Math.max(0, Math.round((brush.hardness - 0.25) * 4) / 4) });
|
|
13120
|
+
else set({ size: Math.max(1, brush.size - sizeStep(brush.size - 1)) });
|
|
13121
|
+
return true;
|
|
13122
|
+
}
|
|
13123
|
+
if (key === "]" || key === "}") {
|
|
13124
|
+
if (e.shiftKey || key === "}") set({ hardness: Math.min(1, Math.round((brush.hardness + 0.25) * 4) / 4) });
|
|
13125
|
+
else set({ size: Math.min(_chunkFQPUF2W2cjs.MAX_BRUSH_SIZE, brush.size + sizeStep(brush.size)) });
|
|
13126
|
+
return true;
|
|
13127
|
+
}
|
|
13128
|
+
if (/^[0-9]$/.test(key) && isPaintTool(controller.getState().activeTool)) {
|
|
13129
|
+
set({ opacity: key === "0" ? 1 : Number(key) / 10 });
|
|
13130
|
+
return true;
|
|
13131
|
+
}
|
|
13132
|
+
return false;
|
|
13133
|
+
}
|
|
13134
|
+
var PaintGesture = (_class6 = class {
|
|
13135
|
+
constructor(controller) {;_class6.prototype.__init22.call(this);_class6.prototype.__init23.call(this);_class6.prototype.__init24.call(this);
|
|
13136
|
+
this.controller = controller;
|
|
13137
|
+
}
|
|
13138
|
+
|
|
13139
|
+
__init22() {this.stroke = null}
|
|
13140
|
+
__init23() {this.move = null}
|
|
13141
|
+
/** The last refusal (e.g. "layer is locked"), for the editor to show. */
|
|
13142
|
+
__init24() {this.error = null}
|
|
13143
|
+
get active() {
|
|
13144
|
+
return Boolean(this.stroke || this.move);
|
|
13145
|
+
}
|
|
13146
|
+
down(sample) {
|
|
13147
|
+
this.error = null;
|
|
13148
|
+
const tool = this.controller.getState().activeTool;
|
|
13149
|
+
try {
|
|
13150
|
+
if (tool === "move") {
|
|
13151
|
+
const layer = this.controller.getActiveLayer();
|
|
13152
|
+
if (!layer) throw new Error("Select a layer to move in the Layers panel.");
|
|
13153
|
+
if (layer.type !== "pixel" && layer.type !== "shape" && layer.type !== "smart") throw new Error(`Only pixel, shape and smart object layers move; "${layer.name}" is a ${layer.type} layer.`);
|
|
13154
|
+
if (_optionalChain([layer, 'access', _336 => _336.locks, 'optionalAccess', _337 => _337.all]) || _optionalChain([layer, 'access', _338 => _338.locks, 'optionalAccess', _339 => _339.position])) throw new Error(`Layer "${layer.name}" has its position locked.`);
|
|
13155
|
+
const origin = layer.type === "pixel" ? { ...layer.offset } : layer.type === "smart" ? { ...layer.placement.corners[0] } : (() => {
|
|
13156
|
+
const b = shapeGeometryBounds(layer);
|
|
13157
|
+
return b ? { x: b.x, y: b.y } : { x: 0, y: 0 };
|
|
13158
|
+
})();
|
|
13159
|
+
this.move = { id: layer.id, start: { x: sample.x, y: sample.y }, origin, moved: false };
|
|
13160
|
+
return null;
|
|
13161
|
+
}
|
|
13162
|
+
if ((tool === "clone" || tool === "heal") && sample.altKey) {
|
|
13163
|
+
this.controller.setCloneSource({ x: sample.x, y: sample.y });
|
|
13164
|
+
return null;
|
|
13165
|
+
}
|
|
13166
|
+
if (isPaintTool(tool)) {
|
|
13167
|
+
this.stroke = this.controller.beginStroke({ tool });
|
|
13168
|
+
this.stroke.push([{ x: sample.x, y: sample.y, pressure: sample.pressure }]);
|
|
13169
|
+
return null;
|
|
13170
|
+
}
|
|
13171
|
+
} catch (err) {
|
|
13172
|
+
this.error = userErrorMessage(err);
|
|
13173
|
+
this.stroke = null;
|
|
13174
|
+
this.move = null;
|
|
13175
|
+
}
|
|
13176
|
+
return this.error;
|
|
13177
|
+
}
|
|
13178
|
+
/** Feeds pointer samples (all coalesced events of one move, in order). */
|
|
13179
|
+
moveTo(samples) {
|
|
13180
|
+
if (!samples.length) return;
|
|
13181
|
+
if (this.stroke) {
|
|
13182
|
+
this.stroke.push(samples);
|
|
13183
|
+
return;
|
|
13184
|
+
}
|
|
13185
|
+
const m = this.move;
|
|
13186
|
+
if (m) {
|
|
13187
|
+
const last = samples[samples.length - 1];
|
|
13188
|
+
const x = m.origin.x + Math.round(last.x - m.start.x);
|
|
13189
|
+
const y = m.origin.y + Math.round(last.y - m.start.y);
|
|
13190
|
+
try {
|
|
13191
|
+
this.controller.offsetLayer(m.id, { x, y }, !m.moved);
|
|
13192
|
+
m.moved = true;
|
|
13193
|
+
} catch (err) {
|
|
13194
|
+
this.error = userErrorMessage(err);
|
|
13195
|
+
this.move = null;
|
|
13196
|
+
}
|
|
13197
|
+
}
|
|
13198
|
+
}
|
|
13199
|
+
up() {
|
|
13200
|
+
if (this.stroke) {
|
|
13201
|
+
try {
|
|
13202
|
+
this.stroke.end();
|
|
13203
|
+
} catch (err) {
|
|
13204
|
+
this.error = userErrorMessage(err);
|
|
13205
|
+
}
|
|
13206
|
+
}
|
|
13207
|
+
this.stroke = null;
|
|
13208
|
+
this.move = null;
|
|
13209
|
+
}
|
|
13210
|
+
cancel() {
|
|
13211
|
+
_optionalChain([this, 'access', _340 => _340.stroke, 'optionalAccess', _341 => _341.cancel, 'call', _342 => _342()]);
|
|
13212
|
+
this.stroke = null;
|
|
13213
|
+
this.move = null;
|
|
13214
|
+
}
|
|
13215
|
+
}, _class6);
|
|
13216
|
+
|
|
13217
|
+
|
|
13218
|
+
|
|
13219
|
+
|
|
13220
|
+
|
|
13221
|
+
|
|
13222
|
+
|
|
13223
|
+
|
|
13224
|
+
|
|
13225
|
+
|
|
13226
|
+
|
|
13227
|
+
|
|
13228
|
+
|
|
13229
|
+
|
|
13230
|
+
|
|
13231
|
+
|
|
13232
|
+
|
|
13233
|
+
|
|
13234
|
+
|
|
13235
|
+
|
|
13236
|
+
|
|
13237
|
+
|
|
13238
|
+
|
|
13239
|
+
|
|
13240
|
+
|
|
13241
|
+
|
|
13242
|
+
|
|
13243
|
+
|
|
13244
|
+
|
|
13245
|
+
|
|
13246
|
+
|
|
13247
|
+
|
|
13248
|
+
|
|
13249
|
+
|
|
13250
|
+
|
|
13251
|
+
|
|
13252
|
+
|
|
12080
13253
|
|
|
12081
13254
|
|
|
12082
13255
|
|
|
@@ -12442,4 +13615,4 @@ function createLayerEffectTools(host, options) {
|
|
|
12442
13615
|
|
|
12443
13616
|
|
|
12444
13617
|
|
|
12445
|
-
exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.MARGIN_FIT_MIN_GUTTER = MARGIN_FIT_MIN_GUTTER; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.layerMaskSelection = layerMaskSelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustmentLayersFloat = applyAdjustmentLayersFloat; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyLegacyFloat = applyLegacyFloat; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyProcess2Float = applyProcess2Float; exports.applyBoxBlurFloat = applyBoxBlurFloat; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.TEXT_ORIENTATIONS = TEXT_ORIENTATIONS; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.MAX_EFFECT_ANIMATION_MS = MAX_EFFECT_ANIMATION_MS; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.LayerOperationError = LayerOperationError; exports.userErrorMessage = userErrorMessage; exports.isPaintableLayer = isPaintableLayer; exports.defaultActiveLayerId = defaultActiveLayerId; exports.activeLayerAfterRemoval = activeLayerAfterRemoval; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.componentsCoverage = componentsCoverage; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.VECTOR_MASK_EDGE_DEFAULTS = VECTOR_MASK_EDGE_DEFAULTS; exports.vectorMaskSegments = vectorMaskSegments; exports.validVectorMaskEdges = validVectorMaskEdges; exports.hybridVectorMaskCoverage = hybridVectorMaskCoverage; exports.isActiveVectorMask = isActiveVectorMask; exports.vectorMaskCoverage = vectorMaskCoverage; exports.layerGuide = layerGuide; exports.effectiveLayerMask = effectiveLayerMask; exports.resolveVectorMasks = resolveVectorMasks; exports.offsetVectorMask = offsetVectorMask; exports.transformVectorMask = transformVectorMask; exports.followLayerMove = followLayerMove; exports.vectorMaskBounds = vectorMaskBounds; exports.vectorMaskThumbnail = vectorMaskThumbnail; exports.EDGE_COLOR_RADIUS = EDGE_COLOR_RADIUS; exports.hasEdgeUnmix = hasEdgeUnmix; exports.maskCoverageOverCanvas = maskCoverageOverCanvas; exports.hasSoftBand = hasSoftBand; exports.despillEdge = despillEdge; exports.applyEdgeUnmix = applyEdgeUnmix; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.runLayerFiltersFloat = runLayerFiltersFloat; exports.LayerCompositor = LayerCompositor; exports.compositeDeep = compositeDeep; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.textOrientation = textOrientation; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.ANCHOR_FRACTION = ANCHOR_FRACTION; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.isSmartSurfaceIncomplete = isSmartSurfaceIncomplete; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.activeEffectSmartFilters = activeEffectSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.translateLayer = translateLayer; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.encodeDeepSurface = encodeDeepSurface; exports.decodeDeepSurface = decodeDeepSurface; exports.readEdgeColor = readEdgeColor; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.readShapeComponents = readShapeComponents; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd; exports.describeLayerEffects = describeLayerEffects; exports.createImageEffectTools = createImageEffectTools; exports.createLayerEffectTools = createLayerEffectTools;
|
|
13618
|
+
exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.MARGIN_FIT_MIN_GUTTER = MARGIN_FIT_MIN_GUTTER; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.layerMaskSelection = layerMaskSelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustmentLayersFloat = applyAdjustmentLayersFloat; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyLegacyFloat = applyLegacyFloat; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyProcess2Float = applyProcess2Float; exports.applyBoxBlurFloat = applyBoxBlurFloat; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.TEXT_ORIENTATIONS = TEXT_ORIENTATIONS; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.MAX_EFFECT_ANIMATION_MS = MAX_EFFECT_ANIMATION_MS; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.LayerOperationError = LayerOperationError; exports.userErrorMessage = userErrorMessage; exports.isPaintableLayer = isPaintableLayer; exports.defaultActiveLayerId = defaultActiveLayerId; exports.activeLayerAfterRemoval = activeLayerAfterRemoval; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.componentsCoverage = componentsCoverage; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.VECTOR_MASK_EDGE_DEFAULTS = VECTOR_MASK_EDGE_DEFAULTS; exports.vectorMaskSegments = vectorMaskSegments; exports.validVectorMaskEdges = validVectorMaskEdges; exports.hybridVectorMaskCoverage = hybridVectorMaskCoverage; exports.isActiveVectorMask = isActiveVectorMask; exports.vectorMaskCoverage = vectorMaskCoverage; exports.layerGuide = layerGuide; exports.effectiveLayerMask = effectiveLayerMask; exports.resolveVectorMasks = resolveVectorMasks; exports.offsetVectorMask = offsetVectorMask; exports.transformVectorMask = transformVectorMask; exports.followLayerMove = followLayerMove; exports.vectorMaskBounds = vectorMaskBounds; exports.vectorMaskThumbnail = vectorMaskThumbnail; exports.EDGE_COLOR_RADIUS = EDGE_COLOR_RADIUS; exports.hasEdgeUnmix = hasEdgeUnmix; exports.maskCoverageOverCanvas = maskCoverageOverCanvas; exports.hasSoftBand = hasSoftBand; exports.despillEdge = despillEdge; exports.applyEdgeUnmix = applyEdgeUnmix; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.runLayerFiltersFloat = runLayerFiltersFloat; exports.LayerCompositor = LayerCompositor; exports.compositeDeep = compositeDeep; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.textOrientation = textOrientation; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.EdgeMap = EdgeMap; exports.snapToEdge = snapToEdge; exports.liveWire = liveWire; exports.simplifyPixelPath = simplifyPixelPath; exports.snapPolygonToEdges = snapPolygonToEdges; exports.magneticAnchorSpacing = magneticAnchorSpacing; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.ANCHOR_FRACTION = ANCHOR_FRACTION; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.isSmartSurfaceIncomplete = isSmartSurfaceIncomplete; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.activeEffectSmartFilters = activeEffectSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.translateLayer = translateLayer; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.encodeDeepSurface = encodeDeepSurface; exports.decodeDeepSurface = decodeDeepSurface; exports.readEdgeColor = readEdgeColor; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.readShapeComponents = readShapeComponents; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd; exports.SELECTION_TOOLS = SELECTION_TOOLS; exports.COLOR_RANGE_PRESET_LABELS = COLOR_RANGE_PRESET_LABELS; exports.SELECTION_MODE_LABELS = SELECTION_MODE_LABELS; exports.DEFAULT_SELECTION_TOOL_OPTIONS = DEFAULT_SELECTION_TOOL_OPTIONS; exports.selectionModeFromModifiers = selectionModeFromModifiers; exports.REFINE_EDGE_CONTROLS = REFINE_EDGE_CONTROLS; exports.REFINE_OUTPUTS = REFINE_OUTPUTS; exports.describeSelection = describeSelection; exports.describeLayerEffects = describeLayerEffects; exports.createImageEffectTools = createImageEffectTools; exports.createLayerEffectTools = createLayerEffectTools; exports.snapTo45 = snapTo45; exports.SelectionGesture = SelectionGesture; exports.handleSelectionShortcut = handleSelectionShortcut; exports.handleMaskViewKey = handleMaskViewKey; exports.handleQuickMaskKey = handleQuickMaskKey; exports.BRUSH_OPTION_CONTROLS = BRUSH_OPTION_CONTROLS; exports.MIXER_OPTION_CONTROLS = MIXER_OPTION_CONTROLS; exports.MIXER_MIXING_OPTIONS = MIXER_MIXING_OPTIONS; exports.PAINT_TOOLS = PAINT_TOOLS; exports.isPaintTool = isPaintTool; exports.isRetouchPaintTool = isRetouchPaintTool; exports.RETOUCH_OPTION_CONTROLS = RETOUCH_OPTION_CONTROLS; exports.CLONE_TRANSFORM_CONTROLS = CLONE_TRANSFORM_CONTROLS; exports.cloneTransformView = cloneTransformView; exports.setCloneTransformValue = setCloneTransformValue; exports.RETOUCH_CHOICES = RETOUCH_CHOICES; exports.RETOUCH_TOGGLES = RETOUCH_TOGGLES; exports.setRetouchChoice = setRetouchChoice; exports.cloneSourceLabel = cloneSourceLabel; exports.rgbUnitToHex = rgbUnitToHex; exports.handlePaintShortcut = handlePaintShortcut; exports.PaintGesture = PaintGesture;
|