@pixerate/editor 0.112.0 → 0.114.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +11 -0
- package/dist/animation-editor/index.cjs +60 -54
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +3 -3
- package/dist/animation-editor/index.d.ts +3 -3
- package/dist/animation-editor/index.js +14 -8
- package/dist/animation-editor/index.js.map +1 -1
- package/dist/builtin-CY97ppKM.d.cts +354 -0
- package/dist/builtin-CY97ppKM.d.ts +354 -0
- package/dist/canvas/index.cjs +3 -3
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.js +9 -9
- package/dist/chunk-26PGXHY7.cjs +753 -0
- package/dist/chunk-26PGXHY7.cjs.map +1 -0
- package/dist/chunk-2OJACTPR.cjs +929 -0
- package/dist/chunk-2OJACTPR.cjs.map +1 -0
- package/dist/chunk-3UFGNHSP.js +929 -0
- package/dist/chunk-3UFGNHSP.js.map +1 -0
- package/dist/{chunk-YGIMK4NX.cjs → chunk-5OVJHMZQ.cjs} +757 -825
- package/dist/chunk-5OVJHMZQ.cjs.map +1 -0
- package/dist/chunk-643B2HKC.cjs +534 -0
- package/dist/chunk-643B2HKC.cjs.map +1 -0
- package/dist/chunk-6FCKOS2B.js +534 -0
- package/dist/chunk-6FCKOS2B.js.map +1 -0
- package/dist/chunk-BRLYOPLT.js +2574 -0
- package/dist/chunk-BRLYOPLT.js.map +1 -0
- package/dist/{chunk-LQEEDHOP.js → chunk-C6C5PDKU.js} +759 -761
- package/dist/chunk-C6C5PDKU.js.map +1 -0
- package/dist/chunk-DFQEX3AM.cjs +781 -0
- package/dist/chunk-DFQEX3AM.cjs.map +1 -0
- package/dist/{chunk-CZOXTEMN.js → chunk-EUVSQ25B.js} +336 -404
- package/dist/chunk-EUVSQ25B.js.map +1 -0
- package/dist/chunk-G5NMLUVF.cjs +2574 -0
- package/dist/chunk-G5NMLUVF.cjs.map +1 -0
- package/dist/chunk-LKCYANMW.js +781 -0
- package/dist/chunk-LKCYANMW.js.map +1 -0
- package/dist/{chunk-W3GXSUSQ.cjs → chunk-LPLCWZTM.cjs} +5087 -1283
- package/dist/chunk-LPLCWZTM.cjs.map +1 -0
- package/dist/chunk-MMVHBKMM.js +753 -0
- package/dist/chunk-MMVHBKMM.js.map +1 -0
- package/dist/{chunk-POGBUYWE.cjs → chunk-ST7E3NEE.cjs} +857 -859
- package/dist/chunk-ST7E3NEE.cjs.map +1 -0
- package/dist/{chunk-7VOHOPLW.cjs → chunk-TCKIXI46.cjs} +59 -59
- package/dist/{chunk-7VOHOPLW.cjs.map → chunk-TCKIXI46.cjs.map} +1 -1
- package/dist/{chunk-XIOMMGPD.cjs → chunk-TFOPHZ3U.cjs} +1 -1
- package/dist/chunk-TFOPHZ3U.cjs.map +1 -0
- package/dist/{chunk-Z4BC6M74.js → chunk-UBIXVXPR.js} +2 -2
- package/dist/{chunk-BLWCAQCW.js → chunk-VXR7XWMF.js} +4574 -770
- package/dist/chunk-VXR7XWMF.js.map +1 -0
- package/dist/{chunk-HNS7UHCM.js → chunk-XK5LZKBD.js} +1 -1
- package/dist/chunk-XK5LZKBD.js.map +1 -0
- package/dist/cms/index.cjs +146 -0
- package/dist/cms/index.cjs.map +1 -0
- package/dist/cms/index.d.cts +51 -0
- package/dist/cms/index.d.ts +51 -0
- package/dist/cms/index.js +146 -0
- package/dist/{export-DNu_Jr8p.d.ts → export-_1dUKwpF.d.ts} +326 -195
- package/dist/{export-DBba-buV.d.cts → export-b6NjCZ5-.d.cts} +326 -195
- package/dist/image-editor/index.cjs +2377 -1291
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +149 -97
- package/dist/image-editor/index.d.ts +149 -97
- package/dist/image-editor/index.js +1343 -257
- package/dist/image-editor/index.js.map +1 -1
- package/dist/opentype-BZEOSOX3.d.ts +188 -0
- package/dist/opentype-Dpe75vL5.d.cts +188 -0
- package/dist/paint/index.cjs +63 -4
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +30 -3
- package/dist/paint/index.d.ts +30 -3
- package/dist/paint/index.js +62 -3
- package/dist/paint-editor/index.cjs +146 -145
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +9 -8
- package/dist/paint-editor/index.d.ts +9 -8
- package/dist/paint-editor/index.js +6 -5
- package/dist/paint-editor/index.js.map +1 -1
- package/dist/raster/index.cjs +53 -3
- package/dist/raster/index.cjs.map +1 -1
- package/dist/raster/index.d.cts +62 -91
- package/dist/raster/index.d.ts +62 -91
- package/dist/raster/index.js +59 -9
- package/dist/{render-BEriFuqK.d.cts → render-B1K_OoLy.d.cts} +87 -2
- package/dist/{render-tjzKaik-.d.ts → render-CrmHOgpo.d.ts} +87 -2
- package/dist/{blending-aOE6Y3UE.d.cts → retouch-Bxkuc0KH.d.cts} +219 -2
- package/dist/{blending-DXl06NSx.d.ts → retouch-Do6tBs2H.d.ts} +219 -2
- package/dist/{surface-C8RRg_Bh.d.ts → surface-Cn30xIV6.d.cts} +6 -1
- package/dist/{surface-C8RRg_Bh.d.cts → surface-Cn30xIV6.d.ts} +6 -1
- package/dist/{svg-D_cfkhlB.d.cts → svg-BnRj0q8i.d.cts} +16 -4
- package/dist/{svg-wIaKLrU0.d.ts → svg-CmmBFfGT.d.ts} +16 -4
- package/dist/{types-DtL_qLFz.d.ts → types-1SUQKDAw.d.ts} +273 -4
- package/dist/{types-DyQq-WPY.d.cts → types-yINF17Ta.d.cts} +273 -4
- package/dist/vector/index.cjs +12170 -7343
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +1579 -16
- package/dist/vector/index.d.ts +1579 -16
- package/dist/vector/index.js +6303 -1476
- package/dist/vector/index.js.map +1 -1
- package/dist/warp-B39VsOtd.d.cts +348 -0
- package/dist/warp-DMN30aY6.d.ts +348 -0
- package/dist/zlib-dxQdgHyN.d.cts +95 -0
- package/dist/zlib-dxQdgHyN.d.ts +95 -0
- package/package.json +6 -1
- package/skills/pixerate-image-editor/SKILL.md +34 -34
- package/skills/pixerate-image-editor/references/color-management.md +37 -0
- package/skills/pixerate-image-editor/references/photoshop-files.md +39 -0
- package/skills/pixerate-image-editor/references/retouching.md +36 -0
- package/skills/pixerate-vector/SKILL.md +154 -5
- package/dist/chunk-BLWCAQCW.js.map +0 -1
- package/dist/chunk-CZOXTEMN.js.map +0 -1
- package/dist/chunk-FTBZPI77.cjs +0 -1
- package/dist/chunk-FTBZPI77.cjs.map +0 -1
- package/dist/chunk-HNS7UHCM.js.map +0 -1
- package/dist/chunk-JLYX4V57.cjs +0 -2001
- package/dist/chunk-JLYX4V57.cjs.map +0 -1
- package/dist/chunk-KB2YBCVS.js +0 -2001
- package/dist/chunk-KB2YBCVS.js.map +0 -1
- package/dist/chunk-LQEEDHOP.js.map +0 -1
- package/dist/chunk-POGBUYWE.cjs.map +0 -1
- package/dist/chunk-VKK5VS2T.js +0 -1
- package/dist/chunk-W3GXSUSQ.cjs.map +0 -1
- package/dist/chunk-XIOMMGPD.cjs.map +0 -1
- package/dist/chunk-YGIMK4NX.cjs.map +0 -1
- package/dist/homography-CZ-tFjay.d.cts +0 -50
- package/dist/homography-Ctfjoc1b.d.ts +0 -50
- package/dist/warp-CWHZzE3x.d.ts +0 -118
- package/dist/warp-D5jz_tN7.d.cts +0 -118
- /package/dist/{chunk-Z4BC6M74.js.map → chunk-UBIXVXPR.js.map} +0 -0
- /package/dist/{chunk-VKK5VS2T.js.map → cms/index.js.map} +0 -0
|
@@ -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;
|
|
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;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -26,178 +26,254 @@ var _chunkMUUXNRU4cjs = require('./chunk-MUUXNRU4.cjs');
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _chunkTFOPHZ3Ucjs = require('./chunk-TFOPHZ3U.cjs');
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
var _chunk643B2HKCcjs = require('./chunk-643B2HKC.cjs');
|
|
34
|
+
|
|
35
|
+
// src/raster/deep.ts
|
|
36
|
+
var BIT_DEPTHS = [8, 16, 32];
|
|
37
|
+
var isBitDepth = (v) => v === 8 || v === 16 || v === 32;
|
|
38
|
+
var TILE_PIXELS = _chunkTFOPHZ3Ucjs.TILE * _chunkTFOPHZ3Ucjs.TILE;
|
|
39
|
+
function srgbDecode(v) {
|
|
40
|
+
return v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
|
|
41
|
+
}
|
|
42
|
+
function srgbEncode(v) {
|
|
43
|
+
if (!(v > 0)) return 0;
|
|
44
|
+
return v <= 31308e-7 ? v * 12.92 : 1.055 * Math.pow(v, 1 / 2.4) - 0.055;
|
|
45
|
+
}
|
|
46
|
+
var LIN8 = null;
|
|
47
|
+
var LIN16 = null;
|
|
48
|
+
function lin8() {
|
|
49
|
+
if (!LIN8) {
|
|
50
|
+
LIN8 = new Float32Array(256);
|
|
51
|
+
for (let i = 0; i < 256; i++) LIN8[i] = srgbDecode(i / 255);
|
|
52
|
+
}
|
|
53
|
+
return LIN8;
|
|
54
|
+
}
|
|
55
|
+
function lin16() {
|
|
56
|
+
if (!LIN16) {
|
|
57
|
+
LIN16 = new Float32Array(65536);
|
|
58
|
+
for (let i = 0; i < 65536; i++) LIN16[i] = srgbDecode(i / 65535);
|
|
59
|
+
}
|
|
60
|
+
return LIN16;
|
|
61
|
+
}
|
|
62
|
+
function encode16(v) {
|
|
63
|
+
if (!(v > 0)) return 0;
|
|
64
|
+
if (v >= 1) return 65535;
|
|
65
|
+
return Math.round(srgbEncode(v) * 65535);
|
|
66
|
+
}
|
|
67
|
+
var ENC8 = null;
|
|
68
|
+
function encode8(v) {
|
|
69
|
+
if (!(v > 0)) return 0;
|
|
70
|
+
if (v >= 1) return 255;
|
|
71
|
+
if (!ENC8) {
|
|
72
|
+
ENC8 = new Uint8Array(65536);
|
|
73
|
+
for (let i = 0; i < 65536; i++) ENC8[i] = Math.round(srgbEncode(i / 65535) * 255);
|
|
74
|
+
}
|
|
75
|
+
return ENC8[Math.round(v * 65535)];
|
|
76
|
+
}
|
|
77
|
+
function to16From8(data, out = new Uint16Array(data.length)) {
|
|
78
|
+
for (let i = 0; i < data.length; i++) out[i] = data[i] * 257;
|
|
79
|
+
return out;
|
|
43
80
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
81
|
+
function to32From8(data, channels, out = new Float32Array(data.length)) {
|
|
82
|
+
if (channels === 1) {
|
|
83
|
+
for (let i = 0; i < data.length; i++) out[i] = data[i] / 255;
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
const t = lin8();
|
|
87
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
88
|
+
out[i] = t[data[i]];
|
|
89
|
+
out[i + 1] = t[data[i + 1]];
|
|
90
|
+
out[i + 2] = t[data[i + 2]];
|
|
91
|
+
out[i + 3] = data[i + 3] / 255;
|
|
92
|
+
}
|
|
93
|
+
return out;
|
|
55
94
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
a += src[off + x * stride] * k[j];
|
|
68
|
-
}
|
|
69
|
-
dst[i] = a;
|
|
95
|
+
function to32From16(data, channels, out = new Float32Array(data.length)) {
|
|
96
|
+
if (channels === 1) {
|
|
97
|
+
for (let i = 0; i < data.length; i++) out[i] = data[i] / 65535;
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
const t = lin16();
|
|
101
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
102
|
+
out[i] = t[data[i]];
|
|
103
|
+
out[i + 1] = t[data[i + 1]];
|
|
104
|
+
out[i + 2] = t[data[i + 2]];
|
|
105
|
+
out[i + 3] = data[i + 3] / 65535;
|
|
70
106
|
}
|
|
107
|
+
return out;
|
|
71
108
|
}
|
|
72
|
-
function
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
a[i] = j < 0 ? edge === "zero" ? 0 : src[off] : j >= len ? edge === "zero" ? 0 : src[off + (len - 1) * stride] : src[off + j * stride];
|
|
109
|
+
function to16From32(data, channels, out = new Uint16Array(data.length)) {
|
|
110
|
+
const unit = (v) => v > 0 ? v < 1 ? Math.round(v * 65535) : 65535 : 0;
|
|
111
|
+
if (channels === 1) {
|
|
112
|
+
for (let i = 0; i < data.length; i++) out[i] = unit(data[i]);
|
|
113
|
+
return out;
|
|
78
114
|
}
|
|
79
|
-
let
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const k = 2 * r + 1;
|
|
85
|
-
for (let i = 0; i < plen; i++) {
|
|
86
|
-
to[i] = sum / k;
|
|
87
|
-
const add = i + r + 1;
|
|
88
|
-
const drop = i - r;
|
|
89
|
-
if (add < plen) sum += from[add];
|
|
90
|
-
if (drop >= 0) sum -= from[drop];
|
|
91
|
-
}
|
|
92
|
-
const t = from;
|
|
93
|
-
from = to;
|
|
94
|
-
to = t;
|
|
115
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
116
|
+
out[i] = encode16(data[i]);
|
|
117
|
+
out[i + 1] = encode16(data[i + 1]);
|
|
118
|
+
out[i + 2] = encode16(data[i + 2]);
|
|
119
|
+
out[i + 3] = unit(data[i + 3]);
|
|
95
120
|
}
|
|
96
|
-
|
|
121
|
+
return out;
|
|
97
122
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
passes.push((buf, off, stride, len) => convolveLine(buf, off, stride, len, k, edge, line));
|
|
107
|
-
} else {
|
|
108
|
-
const radii = boxRadii(s);
|
|
109
|
-
const plen = Math.max(w, h) + 2 * radii.reduce((a2, r) => a2 + r, 0);
|
|
110
|
-
const a = new Float32Array(plen);
|
|
111
|
-
const b = new Float32Array(plen);
|
|
112
|
-
passes.push((buf, off, stride, len) => boxesLine(buf, off, stride, len, radii, edge, a, b, line));
|
|
123
|
+
function to8From16(data, out = new Uint8ClampedArray(data.length)) {
|
|
124
|
+
for (let i = 0; i < data.length; i++) out[i] = Math.round(data[i] / 257);
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
function to8From32(data, channels, out = new Uint8ClampedArray(data.length)) {
|
|
128
|
+
if (channels === 1) {
|
|
129
|
+
for (let i = 0; i < data.length; i++) out[i] = Math.round(data[i] * 255);
|
|
130
|
+
return out;
|
|
113
131
|
}
|
|
114
|
-
for (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
132
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
133
|
+
out[i] = encode8(data[i]);
|
|
134
|
+
out[i + 1] = encode8(data[i + 1]);
|
|
135
|
+
out[i + 2] = encode8(data[i + 2]);
|
|
136
|
+
out[i + 3] = Math.round(Math.min(1, Math.max(0, data[i + 3])) * 255);
|
|
119
137
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
function proxyOf(deep, channels, out) {
|
|
141
|
+
return deep instanceof Uint16Array ? to8From16(deep, out) : to8From32(deep, channels, out);
|
|
142
|
+
}
|
|
143
|
+
var depthOf = (deep) => deep instanceof Uint16Array ? 16 : 32;
|
|
144
|
+
function deepTile(deep, channels, defaultValue = 0) {
|
|
145
|
+
const data = proxyOf(deep, channels);
|
|
146
|
+
if (deep instanceof Uint16Array) {
|
|
147
|
+
let exact = true;
|
|
148
|
+
for (let i = 0; i < deep.length; i++) {
|
|
149
|
+
if (deep[i] % 257 !== 0) {
|
|
150
|
+
exact = false;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (exact) return _chunkTFOPHZ3Ucjs.finishTile.call(void 0, data, channels, defaultValue);
|
|
155
|
+
} else if (channels === 4 && defaultValue === 0) {
|
|
156
|
+
let empty = true;
|
|
157
|
+
for (let i = 3; i < deep.length; i += 4) {
|
|
158
|
+
if (deep[i] !== 0) {
|
|
159
|
+
empty = false;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
124
162
|
}
|
|
163
|
+
if (empty) return null;
|
|
164
|
+
}
|
|
165
|
+
return { data, uniform: null, deep };
|
|
166
|
+
}
|
|
167
|
+
function tileSamples16(tile, channels, defaultValue = 0) {
|
|
168
|
+
const deep = _optionalChain([tile, 'optionalAccess', _2 => _2.deep]);
|
|
169
|
+
if (deep instanceof Uint16Array) return deep;
|
|
170
|
+
if (deep instanceof Float32Array) return to16From32(deep, channels);
|
|
171
|
+
if (tile) return to16From8(tile.data);
|
|
172
|
+
return new Uint16Array(TILE_PIXELS * channels).fill(defaultValue * 257);
|
|
173
|
+
}
|
|
174
|
+
function tileSamples32(tile, channels, defaultValue = 0) {
|
|
175
|
+
const deep = _optionalChain([tile, 'optionalAccess', _3 => _3.deep]);
|
|
176
|
+
if (deep instanceof Float32Array) return deep;
|
|
177
|
+
if (deep instanceof Uint16Array) return to32From16(deep, channels);
|
|
178
|
+
if (tile) return to32From8(tile.data, channels);
|
|
179
|
+
const out = new Float32Array(TILE_PIXELS * channels);
|
|
180
|
+
if (defaultValue) {
|
|
181
|
+
if (channels === 1) out.fill(defaultValue / 255);
|
|
182
|
+
else to32From8(new Uint8ClampedArray(TILE_PIXELS * 4).fill(defaultValue), 4, out);
|
|
125
183
|
}
|
|
126
184
|
return out;
|
|
127
185
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
function
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
186
|
+
function tileSamples(tile, channels, depth, defaultValue = 0) {
|
|
187
|
+
return depth === 16 ? tileSamples16(tile, channels, defaultValue) : tileSamples32(tile, channels, defaultValue);
|
|
188
|
+
}
|
|
189
|
+
function surfaceDepth(surface) {
|
|
190
|
+
let d = 8;
|
|
191
|
+
for (const t of surface.tiles.values()) {
|
|
192
|
+
if (t.deep instanceof Float32Array) return 32;
|
|
193
|
+
if (t.deep) d = 16;
|
|
194
|
+
}
|
|
195
|
+
return d;
|
|
196
|
+
}
|
|
197
|
+
function readDeepRegion(surface, rect, depth) {
|
|
198
|
+
const ch = surface.channels;
|
|
199
|
+
const w = rect.width;
|
|
200
|
+
const h = rect.height;
|
|
201
|
+
const out = depth === 16 ? new Uint16Array(w * h * ch) : new Float32Array(w * h * ch);
|
|
202
|
+
const fill2 = tileSamples(void 0, ch, depth, surface.defaultValue);
|
|
203
|
+
if (surface.defaultValue) for (let i = 0; i < out.length; i += ch) for (let c = 0; c < ch; c++) out[i + c] = fill2[c];
|
|
204
|
+
for (const { tx, ty } of _chunkTFOPHZ3Ucjs.tilesInRect.call(void 0, rect)) {
|
|
205
|
+
const tile = surface.tiles.get(_chunkTFOPHZ3Ucjs.tileKey.call(void 0, tx, ty));
|
|
206
|
+
if (!tile) continue;
|
|
207
|
+
const src = tileSamples(tile, ch, depth, surface.defaultValue);
|
|
208
|
+
const ox = tx * _chunkTFOPHZ3Ucjs.TILE;
|
|
209
|
+
const oy = ty * _chunkTFOPHZ3Ucjs.TILE;
|
|
210
|
+
const x0 = Math.max(rect.x, ox);
|
|
211
|
+
const y0 = Math.max(rect.y, oy);
|
|
212
|
+
const x1 = Math.min(rect.x + w, ox + _chunkTFOPHZ3Ucjs.TILE);
|
|
213
|
+
const y1 = Math.min(rect.y + h, oy + _chunkTFOPHZ3Ucjs.TILE);
|
|
214
|
+
const span = (x1 - x0) * ch;
|
|
215
|
+
for (let yy = y0; yy < y1; yy++) {
|
|
216
|
+
const s = ((yy - oy) * _chunkTFOPHZ3Ucjs.TILE + (x0 - ox)) * ch;
|
|
217
|
+
const d = ((yy - rect.y) * w + (x0 - rect.x)) * ch;
|
|
218
|
+
out.set(src.subarray(s, s + span), d);
|
|
138
219
|
}
|
|
139
|
-
}
|
|
140
|
-
walk(layers);
|
|
220
|
+
}
|
|
141
221
|
return out;
|
|
142
222
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
223
|
+
function writeDeepRegion(surface, rect, samples) {
|
|
224
|
+
const ch = surface.channels;
|
|
225
|
+
const w = rect.width;
|
|
226
|
+
const h = rect.height;
|
|
227
|
+
if (w <= 0 || h <= 0) return surface;
|
|
228
|
+
if (samples.length < w * h * ch) throw new Error(`writeDeepRegion: expected ${w * h * ch} samples, got ${samples.length}`);
|
|
229
|
+
const depth = depthOf(samples);
|
|
230
|
+
const tiles = new Map(surface.tiles);
|
|
231
|
+
for (const { tx, ty } of _chunkTFOPHZ3Ucjs.tilesInRect.call(void 0, rect)) {
|
|
232
|
+
const key = _chunkTFOPHZ3Ucjs.tileKey.call(void 0, tx, ty);
|
|
233
|
+
const ox = tx * _chunkTFOPHZ3Ucjs.TILE;
|
|
234
|
+
const oy = ty * _chunkTFOPHZ3Ucjs.TILE;
|
|
235
|
+
const x0 = Math.max(rect.x, ox);
|
|
236
|
+
const y0 = Math.max(rect.y, oy);
|
|
237
|
+
const x1 = Math.min(rect.x + w, ox + _chunkTFOPHZ3Ucjs.TILE);
|
|
238
|
+
const y1 = Math.min(rect.y + h, oy + _chunkTFOPHZ3Ucjs.TILE);
|
|
239
|
+
const full = x0 === ox && y0 === oy && x1 === ox + _chunkTFOPHZ3Ucjs.TILE && y1 === oy + _chunkTFOPHZ3Ucjs.TILE;
|
|
240
|
+
const base = full ? null : tileSamples(surface.tiles.get(key), ch, depth, surface.defaultValue);
|
|
241
|
+
const t = base ? base.slice() : depth === 16 ? new Uint16Array(TILE_PIXELS * ch) : new Float32Array(TILE_PIXELS * ch);
|
|
242
|
+
const span = (x1 - x0) * ch;
|
|
243
|
+
for (let yy = y0; yy < y1; yy++) {
|
|
244
|
+
const s = ((yy - rect.y) * w + (x0 - rect.x)) * ch;
|
|
245
|
+
const d = ((yy - oy) * _chunkTFOPHZ3Ucjs.TILE + (x0 - ox)) * ch;
|
|
246
|
+
t.set(samples.subarray(s, s + span), d);
|
|
154
247
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
248
|
+
const tile = deepTile(t, ch, surface.defaultValue);
|
|
249
|
+
if (tile) tiles.set(key, tile);
|
|
250
|
+
else tiles.delete(key);
|
|
251
|
+
}
|
|
252
|
+
return new (0, _chunkTFOPHZ3Ucjs.TiledSurface)(ch, tiles, surface.defaultValue);
|
|
158
253
|
}
|
|
159
|
-
function
|
|
160
|
-
|
|
161
|
-
const walk = (list) => {
|
|
162
|
-
let out = null;
|
|
163
|
-
for (let i = 0; i < list.length; i++) {
|
|
164
|
-
const l = list[i];
|
|
165
|
-
let next = l;
|
|
166
|
-
if (l.id === id) {
|
|
167
|
-
next = fn(l);
|
|
168
|
-
changed = true;
|
|
169
|
-
} else {
|
|
170
|
-
const c = childrenOf(l);
|
|
171
|
-
if (c) {
|
|
172
|
-
const children = walk(c);
|
|
173
|
-
if (children !== c) next = { ...l, children };
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if (next !== l) {
|
|
177
|
-
if (!out) out = list.slice(0, i);
|
|
178
|
-
if (next) out.push(next);
|
|
179
|
-
} else if (out) out.push(l);
|
|
180
|
-
}
|
|
181
|
-
return _nullishCoalesce(out, () => ( list));
|
|
182
|
-
};
|
|
183
|
-
const result = walk(layers);
|
|
184
|
-
return changed ? result : layers;
|
|
254
|
+
function surfaceFromDeepPixels(pixels, channels = 4, x = 0, y = 0, defaultValue = 0) {
|
|
255
|
+
return writeDeepRegion(_chunkTFOPHZ3Ucjs.emptySurface.call(void 0, channels, defaultValue), { x, y, width: pixels.width, height: pixels.height }, pixels.data);
|
|
185
256
|
}
|
|
186
|
-
function
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
257
|
+
function convertSurfaceDepth(surface, depth) {
|
|
258
|
+
let changed = false;
|
|
259
|
+
const tiles = new Map(surface.tiles);
|
|
260
|
+
const ch = surface.channels;
|
|
261
|
+
for (const [key, tile] of surface.tiles) {
|
|
262
|
+
const deep = tile.deep;
|
|
263
|
+
if (!deep || depthOf(deep) === depth) continue;
|
|
264
|
+
changed = true;
|
|
265
|
+
let next;
|
|
266
|
+
if (depth === 8) next = _chunkTFOPHZ3Ucjs.finishTile.call(void 0, tile.data, ch, surface.defaultValue);
|
|
267
|
+
else next = deepTile(depth === 16 ? to16From32(deep, ch) : to32From16(deep, ch), ch, surface.defaultValue);
|
|
268
|
+
if (next) tiles.set(key, next);
|
|
269
|
+
else tiles.delete(key);
|
|
270
|
+
}
|
|
271
|
+
return changed ? new (0, _chunkTFOPHZ3Ucjs.TiledSurface)(ch, tiles, surface.defaultValue) : surface;
|
|
198
272
|
}
|
|
199
|
-
function
|
|
200
|
-
|
|
273
|
+
function deepBytes(surface) {
|
|
274
|
+
let n = 0;
|
|
275
|
+
for (const t of surface.tiles.values()) if (t.deep) n += t.deep.byteLength;
|
|
276
|
+
return n;
|
|
201
277
|
}
|
|
202
278
|
|
|
203
279
|
// src/raster/effects/model.ts
|
|
@@ -387,7 +463,7 @@ function oneOf(r, key, path, values) {
|
|
|
387
463
|
if (typeof r[key] !== "string" || !values.includes(r[key])) fail(`${path}.${key}`, `must be one of ${values.join(", ")}.`);
|
|
388
464
|
}
|
|
389
465
|
function blend(r, key, path) {
|
|
390
|
-
if (!
|
|
466
|
+
if (!_chunkTFOPHZ3Ucjs.isBlendMode.call(void 0, r[key])) fail(`${path}.${key}`, `must be a blend mode such as normal, multiply or screen (got ${JSON.stringify(r[key])}).`);
|
|
391
467
|
if (r[key] === "pigment") fail(`${path}.${key}`, "pigment is a layer blend mode only; effects cannot use it.");
|
|
392
468
|
}
|
|
393
469
|
function contour(v, path) {
|
|
@@ -559,73 +635,502 @@ function validateLayerEffect(v, path = "effect") {
|
|
|
559
635
|
break;
|
|
560
636
|
}
|
|
561
637
|
}
|
|
562
|
-
function mergeLayerEffect(effect, changes) {
|
|
563
|
-
if ("kind" in changes && changes.kind !== effect.kind) throw new LayerEffectError(`kind cannot change (${effect.kind}); remove the effect and add a new one.`);
|
|
564
|
-
if ("id" in changes && changes.id !== effect.id) throw new LayerEffectError("id cannot change.");
|
|
565
|
-
const next = { ...effect };
|
|
566
|
-
for (const [k, v] of Object.entries(changes)) {
|
|
567
|
-
if (v === null) delete next[k];
|
|
568
|
-
else next[k] = v;
|
|
638
|
+
function mergeLayerEffect(effect, changes) {
|
|
639
|
+
if ("kind" in changes && changes.kind !== effect.kind) throw new LayerEffectError(`kind cannot change (${effect.kind}); remove the effect and add a new one.`);
|
|
640
|
+
if ("id" in changes && changes.id !== effect.id) throw new LayerEffectError("id cannot change.");
|
|
641
|
+
const next = { ...effect };
|
|
642
|
+
for (const [k, v] of Object.entries(changes)) {
|
|
643
|
+
if (v === null) delete next[k];
|
|
644
|
+
else next[k] = v;
|
|
645
|
+
}
|
|
646
|
+
validateLayerEffect(next);
|
|
647
|
+
return next;
|
|
648
|
+
}
|
|
649
|
+
function validateLayerEffects(v) {
|
|
650
|
+
if (!v || typeof v !== "object") fail("effects", "must be { enabled, items }.");
|
|
651
|
+
const r = v;
|
|
652
|
+
bool(r, "enabled", "effects");
|
|
653
|
+
if (r.scale !== void 0) num(r, "scale", "effects", 0.01, 10);
|
|
654
|
+
if (!Array.isArray(r.items)) fail("effects.items", "must be a list.");
|
|
655
|
+
const ids = /* @__PURE__ */ new Set();
|
|
656
|
+
r.items.forEach((e, i) => {
|
|
657
|
+
validateLayerEffect(e, `effects.items[${i}]`);
|
|
658
|
+
if (ids.has(e.id)) fail(`effects.items[${i}].id`, `duplicate id ${e.id}.`);
|
|
659
|
+
ids.add(e.id);
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
function normalizeLayerEffects(raw) {
|
|
663
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
664
|
+
const r = raw;
|
|
665
|
+
const items = [];
|
|
666
|
+
const ids = /* @__PURE__ */ new Set();
|
|
667
|
+
if (Array.isArray(r.items)) {
|
|
668
|
+
for (const it of r.items) {
|
|
669
|
+
if (!it || typeof it !== "object" || !isLayerEffectKind(it.kind)) continue;
|
|
670
|
+
const kind = it.kind;
|
|
671
|
+
const merged = { ...defaultLayerEffect(kind), ...it };
|
|
672
|
+
if (typeof merged.id !== "string" || !merged.id || ids.has(merged.id)) merged.id = newEffectId();
|
|
673
|
+
try {
|
|
674
|
+
validateLayerEffect(merged);
|
|
675
|
+
} catch (e2) {
|
|
676
|
+
continue;
|
|
677
|
+
}
|
|
678
|
+
ids.add(merged.id);
|
|
679
|
+
items.push(merged);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
const out = { enabled: r.enabled !== false, items };
|
|
683
|
+
if (typeof r.scale === "number" && Number.isFinite(r.scale) && r.scale > 0 && r.scale !== 1) out.scale = r.scale;
|
|
684
|
+
if (r.psd && typeof r.psd === "object") {
|
|
685
|
+
const p = r.psd;
|
|
686
|
+
if (typeof p.key === "string" && p.data instanceof Uint8Array) out.psd = { key: p.key, data: p.data };
|
|
687
|
+
}
|
|
688
|
+
return items.length || out.psd ? out : void 0;
|
|
689
|
+
}
|
|
690
|
+
function effectsFingerprint(effects) {
|
|
691
|
+
if (!effects) return "";
|
|
692
|
+
const items = effects.items.map((e) => {
|
|
693
|
+
const { id: _id, ...rest } = e;
|
|
694
|
+
return rest;
|
|
695
|
+
});
|
|
696
|
+
return stableStringify([effects.enabled, effectsScale(effects), items]);
|
|
697
|
+
}
|
|
698
|
+
function stableStringify(v) {
|
|
699
|
+
if (Array.isArray(v)) return `[${v.map(stableStringify).join(",")}]`;
|
|
700
|
+
if (v && typeof v === "object") {
|
|
701
|
+
const keys = Object.keys(v).filter((k) => v[k] !== void 0).sort();
|
|
702
|
+
return `{${keys.map((k) => `${JSON.stringify(k)}:${stableStringify(v[k])}`).join(",")}}`;
|
|
703
|
+
}
|
|
704
|
+
return JSON.stringify(v);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// src/raster/deep-compositor.ts
|
|
708
|
+
var isGroup = (l) => l.type === "group";
|
|
709
|
+
var DeepCompositor = class {
|
|
710
|
+
constructor(base, profile, deep, depth) {
|
|
711
|
+
this.base = base;
|
|
712
|
+
this.profile = profile;
|
|
713
|
+
this.deep = deep;
|
|
714
|
+
this.depth = depth;
|
|
715
|
+
this.linear = depth === 32;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
/** The composite of `layers` over `rect` as float RGBA in the working space (`rect.width × rect.height × 4`). */
|
|
724
|
+
composite(layers, rect, sources) {
|
|
725
|
+
this.sources = sources;
|
|
726
|
+
const acc = new Float32Array(Math.max(0, rect.width * rect.height * 4));
|
|
727
|
+
if (rect.width > 0 && rect.height > 0) this.runSteps(this.buildSteps(layers), acc, true, rect);
|
|
728
|
+
return acc;
|
|
729
|
+
}
|
|
730
|
+
// --- Steps (as RasterCompositor.buildSteps) ------------------------------------
|
|
731
|
+
isPixel(l) {
|
|
732
|
+
return l.type === "pixel" || (_nullishCoalesce(_optionalChain([this, 'access', _4 => _4.profile, 'access', _5 => _5.isPixelLike, 'optionalCall', _6 => _6(l)]), () => ( false)));
|
|
733
|
+
}
|
|
734
|
+
isFilter(l) {
|
|
735
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _7 => _7.profile, 'access', _8 => _8.isFilterLayer, 'optionalCall', _9 => _9(l)]), () => ( false));
|
|
736
|
+
}
|
|
737
|
+
buildSteps(layers) {
|
|
738
|
+
const steps = [];
|
|
739
|
+
for (const layer of layers) {
|
|
740
|
+
const last = steps[steps.length - 1];
|
|
741
|
+
if (layer.clipped && last && (last.kind === "content" || last.kind === "group")) {
|
|
742
|
+
last.clipped.push(layer);
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
if (this.isFilter(layer)) {
|
|
746
|
+
if (last && last.kind === "adjust") last.layers.push(layer);
|
|
747
|
+
else steps.push({ kind: "adjust", layers: [layer] });
|
|
748
|
+
} else if (isGroup(layer)) steps.push({ kind: "group", layer, clipped: [], steps: this.buildSteps(_nullishCoalesce(layer.children, () => ( []))) });
|
|
749
|
+
else steps.push({ kind: "content", layer, clipped: [] });
|
|
750
|
+
}
|
|
751
|
+
return steps;
|
|
752
|
+
}
|
|
753
|
+
runSteps(steps, acc, empty, r) {
|
|
754
|
+
for (const s of steps) empty = this.runStep(s, acc, empty, r);
|
|
755
|
+
return empty;
|
|
756
|
+
}
|
|
757
|
+
runStep(step, acc, empty, r) {
|
|
758
|
+
if (step.kind === "adjust") {
|
|
759
|
+
if (empty) return true;
|
|
760
|
+
this.applyFilterRun(step.layers, acc, r);
|
|
761
|
+
return false;
|
|
762
|
+
}
|
|
763
|
+
const layer = step.layer;
|
|
764
|
+
if (!layer.visible) return empty;
|
|
765
|
+
const clipped = step.clipped.filter((l) => l.visible);
|
|
766
|
+
const coverage = this.renderedAlone(layer) ? null : this.base.maskCoverage(layer, r, this.sources);
|
|
767
|
+
if (coverage && coverage.every((v) => v <= 0)) return empty;
|
|
768
|
+
if (step.kind === "group" && !this.renderedAlone(layer)) {
|
|
769
|
+
if (layer.blend === "pass-through" && !clipped.length) {
|
|
770
|
+
if (layer.opacity >= 1 && !coverage) return this.runSteps(step.steps, acc, empty, r);
|
|
771
|
+
const before = acc.slice();
|
|
772
|
+
const stillEmpty = this.runSteps(step.steps, acc, empty, r);
|
|
773
|
+
lerp(acc, before, layer.opacity, coverage);
|
|
774
|
+
return empty && stillEmpty;
|
|
775
|
+
}
|
|
776
|
+
const buf2 = new Float32Array(acc.length);
|
|
777
|
+
if (this.runSteps(step.steps, buf2, true, r)) return empty;
|
|
778
|
+
this.applyClipped(clipped, buf2, r);
|
|
779
|
+
const mode2 = layer.blend === "pass-through" ? "normal" : layer.blend;
|
|
780
|
+
this.blend(acc, buf2, mode2, layer.opacity, coverage);
|
|
781
|
+
return false;
|
|
782
|
+
}
|
|
783
|
+
const content = this.content(layer, r);
|
|
784
|
+
if (!content) return empty;
|
|
785
|
+
const alone = this.renderedAlone(layer);
|
|
786
|
+
const fill2 = !alone && this.isPixel(layer) ? _nullishCoalesce(layer.fillOpacity, () => ( 1)) : 1;
|
|
787
|
+
const mode = this.blendOf(layer);
|
|
788
|
+
if (!clipped.length) {
|
|
789
|
+
this.blend(acc, content, mode, layer.opacity * fill2, coverage);
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
const buf = new Float32Array(acc.length);
|
|
793
|
+
this.blend(buf, content, "normal", fill2, coverage);
|
|
794
|
+
this.applyClipped(clipped, buf, r);
|
|
795
|
+
this.blend(acc, buf, mode, layer.opacity, null);
|
|
796
|
+
return false;
|
|
797
|
+
}
|
|
798
|
+
applyClipped(clipped, buf, r) {
|
|
799
|
+
let run = [];
|
|
800
|
+
const flush = () => {
|
|
801
|
+
if (run.length) this.applyFilterRun(run, buf, r);
|
|
802
|
+
run = [];
|
|
803
|
+
};
|
|
804
|
+
for (const c of clipped) {
|
|
805
|
+
if (this.isFilter(c)) {
|
|
806
|
+
run.push(c);
|
|
807
|
+
continue;
|
|
808
|
+
}
|
|
809
|
+
flush();
|
|
810
|
+
const alone = this.renderedAlone(c);
|
|
811
|
+
const coverage = alone ? null : this.base.maskCoverage(c, r, this.sources);
|
|
812
|
+
let src;
|
|
813
|
+
if (isGroup(c) && !alone) {
|
|
814
|
+
src = new Float32Array(buf.length);
|
|
815
|
+
if (this.runSteps(this.buildSteps(_nullishCoalesce(c.children, () => ( []))), src, true, r)) continue;
|
|
816
|
+
} else src = this.content(c, r);
|
|
817
|
+
if (!src) continue;
|
|
818
|
+
const fill2 = !alone && this.isPixel(c) ? _nullishCoalesce(c.fillOpacity, () => ( 1)) : 1;
|
|
819
|
+
const keep = new Float32Array(buf.length >> 2);
|
|
820
|
+
for (let i = 3, p = 0; i < buf.length; i += 4, p++) keep[p] = buf[i];
|
|
821
|
+
this.blend(buf, src, c.blend === "pass-through" ? "normal" : this.blendOf(c), c.opacity * fill2, coverage);
|
|
822
|
+
for (let i = 3, p = 0; i < buf.length; i += 4, p++) buf[i] = keep[p];
|
|
823
|
+
}
|
|
824
|
+
flush();
|
|
825
|
+
}
|
|
826
|
+
applyFilterRun(layers, acc, r) {
|
|
827
|
+
const visible = [];
|
|
828
|
+
let masks;
|
|
829
|
+
for (const node of layers) {
|
|
830
|
+
if (!node.visible) continue;
|
|
831
|
+
const cov = this.base.maskCoverage(node, r, this.sources);
|
|
832
|
+
if (cov) {
|
|
833
|
+
if (cov.every((v) => v <= 0)) continue;
|
|
834
|
+
(masks ??= /* @__PURE__ */ new Map()).set(node.id, cov);
|
|
835
|
+
}
|
|
836
|
+
visible.push(node);
|
|
837
|
+
}
|
|
838
|
+
if (!visible.length) return;
|
|
839
|
+
if (this.deep.applyFilterRunDeep) {
|
|
840
|
+
if (this.linear) mapColour(acc, srgbEncode);
|
|
841
|
+
this.deep.applyFilterRunDeep(visible, acc, r, masks, this.sources);
|
|
842
|
+
if (this.linear) mapColour(acc, srgbDecode);
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
const bytes = this.to8(acc);
|
|
846
|
+
_optionalChain([this, 'access', _10 => _10.profile, 'access', _11 => _11.applyFilterRun, 'optionalCall', _12 => _12(visible, bytes, r, masks, this.sources)]);
|
|
847
|
+
acc.set(this.from8(bytes));
|
|
848
|
+
}
|
|
849
|
+
// --- Layer content ---------------------------------------------------------------
|
|
850
|
+
/** Layers drawn by the 8-bit compositor alone (effects, pixel filters, content the editor draws). */
|
|
851
|
+
renderedAlone(layer) {
|
|
852
|
+
if (hasActiveEffects(layer.effects) && !this.isFilter(layer)) return true;
|
|
853
|
+
if (this.isPixel(layer)) return Boolean(_optionalChain([this, 'access', _13 => _13.profile, 'access', _14 => _14.pixelFilters, 'optionalCall', _15 => _15(layer)]));
|
|
854
|
+
return !isGroup(layer);
|
|
855
|
+
}
|
|
856
|
+
blendOf(layer) {
|
|
857
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _16 => _16.profile, 'access', _17 => _17.contentBlend, 'optionalCall', _18 => _18(layer)]), () => ( layer.blend));
|
|
858
|
+
}
|
|
859
|
+
/** A layer's float RGBA over `r` (straight alpha, working space), or `null` when it has none there. */
|
|
860
|
+
content(layer, r) {
|
|
861
|
+
if (this.renderedAlone(layer)) {
|
|
862
|
+
const solo = { ...layer, blend: isGroup(layer) && layer.blend === "pass-through" ? "pass-through" : "normal", opacity: 1, clipped: false };
|
|
863
|
+
const bytes = this.base.composite([solo], r, this.sources);
|
|
864
|
+
return this.from8(bytes);
|
|
865
|
+
}
|
|
866
|
+
const surface = this.sources.surfaceOf ? this.sources.surfaceOf(layer) : layer.surface;
|
|
867
|
+
if (!surface) return null;
|
|
868
|
+
const ox = _nullishCoalesce(_optionalChain([layer, 'access', _19 => _19.offset, 'optionalAccess', _20 => _20.x]), () => ( 0));
|
|
869
|
+
const oy = _nullishCoalesce(_optionalChain([layer, 'access', _21 => _21.offset, 'optionalAccess', _22 => _22.y]), () => ( 0));
|
|
870
|
+
const samples = readDeepRegion(surface, { x: r.x - ox, y: r.y - oy, width: r.width, height: r.height }, this.depth);
|
|
871
|
+
if (samples instanceof Float32Array) return samples;
|
|
872
|
+
const out = new Float32Array(samples.length);
|
|
873
|
+
for (let i = 0; i < samples.length; i++) out[i] = samples[i] / 65535;
|
|
874
|
+
return out;
|
|
875
|
+
}
|
|
876
|
+
/** 8-bit RGBA to the working space. */
|
|
877
|
+
from8(bytes) {
|
|
878
|
+
if (this.linear) return to32From8(bytes, 4);
|
|
879
|
+
const out = new Float32Array(bytes.length);
|
|
880
|
+
for (let i = 0; i < bytes.length; i++) out[i] = bytes[i] / 255;
|
|
881
|
+
return out;
|
|
882
|
+
}
|
|
883
|
+
/** The working space to 8-bit RGBA. */
|
|
884
|
+
to8(acc) {
|
|
885
|
+
const out = new Uint8ClampedArray(acc.length);
|
|
886
|
+
for (let i = 0; i < acc.length; i += 4) {
|
|
887
|
+
for (let c = 0; c < 3; c++) out[i + c] = Math.round((this.linear ? srgbEncode(acc[i + c]) : acc[i + c]) * 255);
|
|
888
|
+
out[i + 3] = Math.round(acc[i + 3] * 255);
|
|
889
|
+
}
|
|
890
|
+
return out;
|
|
891
|
+
}
|
|
892
|
+
// --- Blending --------------------------------------------------------------------
|
|
893
|
+
/** `src` over `dst` with `mode` at `alpha` × coverage (straight alpha, float), as `blendTile`. */
|
|
894
|
+
blend(dst, src, mode, alpha, coverage) {
|
|
895
|
+
if (!(alpha > 0)) return;
|
|
896
|
+
const normal = mode === "normal";
|
|
897
|
+
const pigment = mode === "pigment";
|
|
898
|
+
const cb = [0, 0, 0];
|
|
899
|
+
const cs = [0, 0, 0];
|
|
900
|
+
const mix = [0, 0, 0];
|
|
901
|
+
for (let i = 0, p = 0; i < dst.length; i += 4, p++) {
|
|
902
|
+
const sa = src[i + 3];
|
|
903
|
+
if (!(sa > 0)) continue;
|
|
904
|
+
const k = coverage ? alpha * coverage[p] : alpha;
|
|
905
|
+
if (!(k > 0)) continue;
|
|
906
|
+
const as = Math.min(1, sa * k);
|
|
907
|
+
const ab = dst[i + 3];
|
|
908
|
+
const ao = as + ab * (1 - as);
|
|
909
|
+
if (ao <= 0) {
|
|
910
|
+
dst[i] = dst[i + 1] = dst[i + 2] = dst[i + 3] = 0;
|
|
911
|
+
continue;
|
|
912
|
+
}
|
|
913
|
+
if (normal && as >= 1) {
|
|
914
|
+
dst[i] = src[i];
|
|
915
|
+
dst[i + 1] = src[i + 1];
|
|
916
|
+
dst[i + 2] = src[i + 2];
|
|
917
|
+
dst[i + 3] = 1;
|
|
918
|
+
continue;
|
|
919
|
+
}
|
|
920
|
+
for (let c = 0; c < 3; c++) {
|
|
921
|
+
cb[c] = dst[i + c];
|
|
922
|
+
cs[c] = src[i + c];
|
|
923
|
+
}
|
|
924
|
+
if (pigment) {
|
|
925
|
+
if (this.linear) for (let c = 0; c < 3; c++) cb[c] = srgbEncode(cb[c]), cs[c] = srgbEncode(cs[c]);
|
|
926
|
+
_chunkTFOPHZ3Ucjs.mixPigmentRgb.call(void 0, cb, cs, as / ao, mix);
|
|
927
|
+
for (let c = 0; c < 3; c++) dst[i + c] = this.linear ? srgbDecode(mix[c]) : mix[c];
|
|
928
|
+
dst[i + 3] = ao;
|
|
929
|
+
continue;
|
|
930
|
+
}
|
|
931
|
+
const m = normal ? cs : _chunkTFOPHZ3Ucjs.blendRgb.call(void 0, mode, cb, cs);
|
|
932
|
+
const wb = (1 - as) * ab;
|
|
933
|
+
const ws = (1 - ab) * as;
|
|
934
|
+
const wm = as * ab;
|
|
935
|
+
for (let c = 0; c < 3; c++) dst[i + c] = (wb * cb[c] + ws * cs[c] + wm * m[c]) / ao;
|
|
936
|
+
dst[i + 3] = ao;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
function lerp(dst, before, alpha, coverage) {
|
|
941
|
+
for (let i = 0, p = 0; i < dst.length; i += 4, p++) {
|
|
942
|
+
const k = coverage ? alpha * coverage[p] : alpha;
|
|
943
|
+
if (k >= 1) continue;
|
|
944
|
+
for (let c = 0; c < 4; c++) dst[i + c] = before[i + c] + (dst[i + c] - before[i + c]) * k;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
function mapColour(data, f) {
|
|
948
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
949
|
+
data[i] = f(data[i]);
|
|
950
|
+
data[i + 1] = f(data[i + 1]);
|
|
951
|
+
data[i + 2] = f(data[i + 2]);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
function workingToSamples(data, depth) {
|
|
955
|
+
if (depth === 32) return data;
|
|
956
|
+
const out = new Uint16Array(data.length);
|
|
957
|
+
for (let i = 0; i < data.length; i++) {
|
|
958
|
+
const v = data[i];
|
|
959
|
+
out[i] = v > 0 ? v < 1 ? Math.round(v * 65535) : 65535 : 0;
|
|
960
|
+
}
|
|
961
|
+
return out;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// src/raster/blur.ts
|
|
965
|
+
function gaussianKernel(sigma) {
|
|
966
|
+
const r = Math.ceil(sigma * 3);
|
|
967
|
+
const k = new Float32Array(2 * r + 1);
|
|
968
|
+
let s = 0;
|
|
969
|
+
for (let i = -r; i <= r; i++) {
|
|
970
|
+
const v = Math.exp(-(i * i) / (2 * sigma * sigma));
|
|
971
|
+
k[i + r] = v;
|
|
972
|
+
s += v;
|
|
973
|
+
}
|
|
974
|
+
for (let i = 0; i < k.length; i++) k[i] /= s;
|
|
975
|
+
return k;
|
|
976
|
+
}
|
|
977
|
+
var DIRECT_GAUSSIAN_MAX_SIGMA = 8;
|
|
978
|
+
function boxRadii(sigma) {
|
|
979
|
+
const n = 3;
|
|
980
|
+
const wIdeal = Math.sqrt(12 * sigma * sigma / n + 1);
|
|
981
|
+
let wl = Math.floor(wIdeal);
|
|
982
|
+
if (wl % 2 === 0) wl--;
|
|
983
|
+
const wu = wl + 2;
|
|
984
|
+
const mIdeal = (12 * sigma * sigma - n * wl * wl - 4 * n * wl - 3 * n) / (-4 * wl - 4);
|
|
985
|
+
const m = Math.round(mIdeal);
|
|
986
|
+
const sizes = [0, 1, 2].map((i) => i < m ? wl : wu);
|
|
987
|
+
return sizes.map((s) => (s - 1) / 2);
|
|
988
|
+
}
|
|
989
|
+
function convolveLine(src, off, stride, len, k, edge, dst) {
|
|
990
|
+
const r = (k.length - 1) / 2;
|
|
991
|
+
for (let i = 0; i < len; i++) {
|
|
992
|
+
let a = 0;
|
|
993
|
+
const lo = i - r;
|
|
994
|
+
for (let j = 0; j < k.length; j++) {
|
|
995
|
+
let x = lo + j;
|
|
996
|
+
if (x < 0 || x >= len) {
|
|
997
|
+
if (edge === "zero") continue;
|
|
998
|
+
x = x < 0 ? 0 : len - 1;
|
|
999
|
+
}
|
|
1000
|
+
a += src[off + x * stride] * k[j];
|
|
1001
|
+
}
|
|
1002
|
+
dst[i] = a;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
function boxesLine(src, off, stride, len, radii, edge, a, b, dst) {
|
|
1006
|
+
const pad = radii.reduce((s, r) => s + r, 0);
|
|
1007
|
+
const plen = len + 2 * pad;
|
|
1008
|
+
for (let i = 0; i < plen; i++) {
|
|
1009
|
+
const j = i - pad;
|
|
1010
|
+
a[i] = j < 0 ? edge === "zero" ? 0 : src[off] : j >= len ? edge === "zero" ? 0 : src[off + (len - 1) * stride] : src[off + j * stride];
|
|
1011
|
+
}
|
|
1012
|
+
let from = a;
|
|
1013
|
+
let to = b;
|
|
1014
|
+
for (const r of radii) {
|
|
1015
|
+
let sum = 0;
|
|
1016
|
+
for (let i = 0; i <= Math.min(r, plen - 1); i++) sum += from[i];
|
|
1017
|
+
const k = 2 * r + 1;
|
|
1018
|
+
for (let i = 0; i < plen; i++) {
|
|
1019
|
+
to[i] = sum / k;
|
|
1020
|
+
const add = i + r + 1;
|
|
1021
|
+
const drop = i - r;
|
|
1022
|
+
if (add < plen) sum += from[add];
|
|
1023
|
+
if (drop >= 0) sum -= from[drop];
|
|
1024
|
+
}
|
|
1025
|
+
const t = from;
|
|
1026
|
+
from = to;
|
|
1027
|
+
to = t;
|
|
1028
|
+
}
|
|
1029
|
+
for (let i = 0; i < len; i++) dst[i] = from[i + pad];
|
|
1030
|
+
}
|
|
1031
|
+
function gaussianBlur(src, w, h, sigma, edge = "zero") {
|
|
1032
|
+
const out = Float32Array.from(src);
|
|
1033
|
+
if (!(sigma >= 0.1) || w <= 0 || h <= 0) return out;
|
|
1034
|
+
const s = Math.min(sigma, 4 * Math.max(w, h));
|
|
1035
|
+
const line = new Float32Array(Math.max(w, h));
|
|
1036
|
+
const passes = [];
|
|
1037
|
+
if (s <= DIRECT_GAUSSIAN_MAX_SIGMA) {
|
|
1038
|
+
const k = gaussianKernel(s);
|
|
1039
|
+
passes.push((buf, off, stride, len) => convolveLine(buf, off, stride, len, k, edge, line));
|
|
1040
|
+
} else {
|
|
1041
|
+
const radii = boxRadii(s);
|
|
1042
|
+
const plen = Math.max(w, h) + 2 * radii.reduce((a2, r) => a2 + r, 0);
|
|
1043
|
+
const a = new Float32Array(plen);
|
|
1044
|
+
const b = new Float32Array(plen);
|
|
1045
|
+
passes.push((buf, off, stride, len) => boxesLine(buf, off, stride, len, radii, edge, a, b, line));
|
|
569
1046
|
}
|
|
570
|
-
|
|
571
|
-
|
|
1047
|
+
for (const pass of passes) {
|
|
1048
|
+
for (let y = 0; y < h; y++) {
|
|
1049
|
+
pass(out, y * w, 1, w);
|
|
1050
|
+
out.set(line.subarray(0, w), y * w);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
for (const pass of passes) {
|
|
1054
|
+
for (let x = 0; x < w; x++) {
|
|
1055
|
+
pass(out, x, w, h);
|
|
1056
|
+
for (let y = 0; y < h; y++) out[y * w + x] = line[y];
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
return out;
|
|
572
1060
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
}
|
|
1061
|
+
|
|
1062
|
+
// src/raster/layers.ts
|
|
1063
|
+
var childrenOf = (l) => l.type === "group" ? _nullishCoalesce(l.children, () => ( null)) : null;
|
|
1064
|
+
function flattenLayers(layers) {
|
|
1065
|
+
const out = [];
|
|
1066
|
+
const walk = (list) => {
|
|
1067
|
+
for (const l of list) {
|
|
1068
|
+
out.push(l);
|
|
1069
|
+
const c = childrenOf(l);
|
|
1070
|
+
if (c) walk(c);
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
walk(layers);
|
|
1074
|
+
return out;
|
|
585
1075
|
}
|
|
586
|
-
function
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
if (typeof merged.id !== "string" || !merged.id || ids.has(merged.id)) merged.id = newEffectId();
|
|
597
|
-
try {
|
|
598
|
-
validateLayerEffect(merged);
|
|
599
|
-
} catch (e2) {
|
|
600
|
-
continue;
|
|
1076
|
+
function findLayer(layers, id) {
|
|
1077
|
+
const walk = (list, parent, path) => {
|
|
1078
|
+
for (let i = 0; i < list.length; i++) {
|
|
1079
|
+
const l = list[i];
|
|
1080
|
+
if (l.id === id) return { layer: l, parent, index: i, path };
|
|
1081
|
+
const c = childrenOf(l);
|
|
1082
|
+
if (c) {
|
|
1083
|
+
const g = l;
|
|
1084
|
+
const hit = walk(c, g, [...path, g]);
|
|
1085
|
+
if (hit) return hit;
|
|
601
1086
|
}
|
|
602
|
-
ids.add(merged.id);
|
|
603
|
-
items.push(merged);
|
|
604
1087
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
if (r.psd && typeof r.psd === "object") {
|
|
609
|
-
const p = r.psd;
|
|
610
|
-
if (typeof p.key === "string" && p.data instanceof Uint8Array) out.psd = { key: p.key, data: p.data };
|
|
611
|
-
}
|
|
612
|
-
return items.length || out.psd ? out : void 0;
|
|
1088
|
+
return null;
|
|
1089
|
+
};
|
|
1090
|
+
return walk(layers, null, []);
|
|
613
1091
|
}
|
|
614
|
-
function
|
|
615
|
-
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
1092
|
+
function mapLayer(layers, id, fn) {
|
|
1093
|
+
let changed = false;
|
|
1094
|
+
const walk = (list) => {
|
|
1095
|
+
let out = null;
|
|
1096
|
+
for (let i = 0; i < list.length; i++) {
|
|
1097
|
+
const l = list[i];
|
|
1098
|
+
let next = l;
|
|
1099
|
+
if (l.id === id) {
|
|
1100
|
+
next = fn(l);
|
|
1101
|
+
changed = true;
|
|
1102
|
+
} else {
|
|
1103
|
+
const c = childrenOf(l);
|
|
1104
|
+
if (c) {
|
|
1105
|
+
const children = walk(c);
|
|
1106
|
+
if (children !== c) next = { ...l, children };
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
if (next !== l) {
|
|
1110
|
+
if (!out) out = list.slice(0, i);
|
|
1111
|
+
if (next) out.push(next);
|
|
1112
|
+
} else if (out) out.push(l);
|
|
1113
|
+
}
|
|
1114
|
+
return _nullishCoalesce(out, () => ( list));
|
|
1115
|
+
};
|
|
1116
|
+
const result = walk(layers);
|
|
1117
|
+
return changed ? result : layers;
|
|
1118
|
+
}
|
|
1119
|
+
function insertLayer(layers, layer, parentId, index) {
|
|
1120
|
+
const put = (list) => {
|
|
1121
|
+
const at = index === void 0 ? list.length : Math.max(0, Math.min(list.length, index));
|
|
1122
|
+
const next = list.slice();
|
|
1123
|
+
next.splice(at, 0, layer);
|
|
1124
|
+
return next;
|
|
1125
|
+
};
|
|
1126
|
+
if (!parentId) return put(layers);
|
|
1127
|
+
return mapLayer(layers, parentId, (g) => {
|
|
1128
|
+
const c = childrenOf(g);
|
|
1129
|
+
return c ? { ...g, children: put(c) } : g;
|
|
619
1130
|
});
|
|
620
|
-
return stableStringify([effects.enabled, effectsScale(effects), items]);
|
|
621
1131
|
}
|
|
622
|
-
function
|
|
623
|
-
|
|
624
|
-
if (v && typeof v === "object") {
|
|
625
|
-
const keys = Object.keys(v).filter((k) => v[k] !== void 0).sort();
|
|
626
|
-
return `{${keys.map((k) => `${JSON.stringify(k)}:${stableStringify(v[k])}`).join(",")}}`;
|
|
627
|
-
}
|
|
628
|
-
return JSON.stringify(v);
|
|
1132
|
+
function isLayerLocked(layer, what) {
|
|
1133
|
+
return Boolean(_optionalChain([layer, 'access', _23 => _23.locks, 'optionalAccess', _24 => _24.all]) || _optionalChain([layer, 'access', _25 => _25.locks, 'optionalAccess', _26 => _26[what]]));
|
|
629
1134
|
}
|
|
630
1135
|
|
|
631
1136
|
// src/raster/effects/patterns.ts
|
|
@@ -1586,7 +2091,7 @@ function compositeAt(dst, i, mode, separable, sr, sg, sb, sa) {
|
|
|
1586
2091
|
rgbScratchS[0] = sr;
|
|
1587
2092
|
rgbScratchS[1] = sg;
|
|
1588
2093
|
rgbScratchS[2] = sb;
|
|
1589
|
-
|
|
2094
|
+
_chunkTFOPHZ3Ucjs.mixPigmentRgb.call(void 0, rgbScratchB, rgbScratchS, sa / ao, rgbScratchM);
|
|
1590
2095
|
dst[i] = rgbScratchM[0];
|
|
1591
2096
|
dst[i + 1] = rgbScratchM[1];
|
|
1592
2097
|
dst[i + 2] = rgbScratchM[2];
|
|
@@ -1601,9 +2106,9 @@ function compositeAt(dst, i, mode, separable, sr, sg, sb, sa) {
|
|
|
1601
2106
|
m1 = sg;
|
|
1602
2107
|
m2 = sb;
|
|
1603
2108
|
} else if (separable) {
|
|
1604
|
-
m0 =
|
|
1605
|
-
m1 =
|
|
1606
|
-
m2 =
|
|
2109
|
+
m0 = _chunkTFOPHZ3Ucjs.blendChannel.call(void 0, mode, b0, sr);
|
|
2110
|
+
m1 = _chunkTFOPHZ3Ucjs.blendChannel.call(void 0, mode, b1, sg);
|
|
2111
|
+
m2 = _chunkTFOPHZ3Ucjs.blendChannel.call(void 0, mode, b2, sb);
|
|
1607
2112
|
} else {
|
|
1608
2113
|
rgbScratchB[0] = b0;
|
|
1609
2114
|
rgbScratchB[1] = b1;
|
|
@@ -1611,7 +2116,7 @@ function compositeAt(dst, i, mode, separable, sr, sg, sb, sa) {
|
|
|
1611
2116
|
rgbScratchS[0] = sr;
|
|
1612
2117
|
rgbScratchS[1] = sg;
|
|
1613
2118
|
rgbScratchS[2] = sb;
|
|
1614
|
-
const m =
|
|
2119
|
+
const m = _chunkTFOPHZ3Ucjs.blendRgb.call(void 0, mode, rgbScratchB, rgbScratchS);
|
|
1615
2120
|
m0 = m[0];
|
|
1616
2121
|
m1 = m[1];
|
|
1617
2122
|
m2 = m[2];
|
|
@@ -1625,7 +2130,7 @@ function compositeAt(dst, i, mode, separable, sr, sg, sb, sa) {
|
|
|
1625
2130
|
dst[i + 3] = ao;
|
|
1626
2131
|
}
|
|
1627
2132
|
function paint(dst, m, color2, mode, opacity) {
|
|
1628
|
-
const sep = mode !== "normal" &&
|
|
2133
|
+
const sep = mode !== "normal" && _chunkTFOPHZ3Ucjs.isSeparableBlendMode.call(void 0, mode);
|
|
1629
2134
|
const c = [0, 0, 0, 1];
|
|
1630
2135
|
const n = m.length;
|
|
1631
2136
|
for (let i = 0; i < n; i++) {
|
|
@@ -1914,7 +2419,7 @@ function compositeLayerEffects(input) {
|
|
|
1914
2419
|
}
|
|
1915
2420
|
const premerge = !normalLike;
|
|
1916
2421
|
if (premerge) {
|
|
1917
|
-
const sep2 =
|
|
2422
|
+
const sep2 = _chunkTFOPHZ3Ucjs.isSeparableBlendMode.call(void 0, input.blend);
|
|
1918
2423
|
for (let i = 0; i < n; i++) {
|
|
1919
2424
|
const p = i * 4;
|
|
1920
2425
|
const sr = lay[p];
|
|
@@ -2034,7 +2539,7 @@ function compositeLayerEffects(input) {
|
|
|
2034
2539
|
paintColor(work, fx(i, 1), e.shadowColor, e.shadowBlend, e.shadowOpacity);
|
|
2035
2540
|
}
|
|
2036
2541
|
const mode = premerge ? "normal" : input.blend;
|
|
2037
|
-
const sep =
|
|
2542
|
+
const sep = _chunkTFOPHZ3Ucjs.isSeparableBlendMode.call(void 0, mode);
|
|
2038
2543
|
for (let i = 0; i < n; i++) {
|
|
2039
2544
|
const p = i * 4;
|
|
2040
2545
|
if (lay[p + 3] > 0) compositeAt(work, p, mode, sep, lay[p], lay[p + 1], lay[p + 2], lay[p + 3]);
|
|
@@ -2079,8 +2584,8 @@ function renderLayerEffects(effects, layer, backdrop, canvas, ctx) {
|
|
|
2079
2584
|
}
|
|
2080
2585
|
|
|
2081
2586
|
// src/raster/compositor.ts
|
|
2082
|
-
var
|
|
2083
|
-
var TILE_BYTES =
|
|
2587
|
+
var TILE_PIXELS2 = _chunkTFOPHZ3Ucjs.TILE * _chunkTFOPHZ3Ucjs.TILE;
|
|
2588
|
+
var TILE_BYTES = TILE_PIXELS2 * 4;
|
|
2084
2589
|
function sameSig(a, b) {
|
|
2085
2590
|
if (!a || a.key !== b.key || a.refs.length !== b.refs.length) return false;
|
|
2086
2591
|
for (let i = 0; i < a.refs.length; i++) if (a.refs[i] !== b.refs[i]) return false;
|
|
@@ -2091,13 +2596,13 @@ function dirtyInTile(rects, tx, ty) {
|
|
|
2091
2596
|
let y0 = Infinity;
|
|
2092
2597
|
let x1 = -Infinity;
|
|
2093
2598
|
let y1 = -Infinity;
|
|
2094
|
-
const ox = tx *
|
|
2095
|
-
const oy = ty *
|
|
2599
|
+
const ox = tx * _chunkTFOPHZ3Ucjs.TILE;
|
|
2600
|
+
const oy = ty * _chunkTFOPHZ3Ucjs.TILE;
|
|
2096
2601
|
for (const r of rects) {
|
|
2097
2602
|
const a = Math.max(ox, Math.floor(r.x));
|
|
2098
2603
|
const b = Math.max(oy, Math.floor(r.y));
|
|
2099
|
-
const c = Math.min(ox +
|
|
2100
|
-
const d = Math.min(oy +
|
|
2604
|
+
const c = Math.min(ox + _chunkTFOPHZ3Ucjs.TILE, Math.ceil(r.x + r.width));
|
|
2605
|
+
const d = Math.min(oy + _chunkTFOPHZ3Ucjs.TILE, Math.ceil(r.y + r.height));
|
|
2101
2606
|
if (c <= a || d <= b) continue;
|
|
2102
2607
|
x0 = Math.min(x0, a);
|
|
2103
2608
|
y0 = Math.min(y0, b);
|
|
@@ -2110,7 +2615,7 @@ function blendTile(dst, src, mode, alpha, coverage) {
|
|
|
2110
2615
|
if (!(alpha > 0)) return;
|
|
2111
2616
|
const normal = mode === "normal";
|
|
2112
2617
|
const pigment = mode === "pigment";
|
|
2113
|
-
const lut = !normal &&
|
|
2618
|
+
const lut = !normal && _chunkTFOPHZ3Ucjs.isSeparableBlendMode.call(void 0, mode) ? separableLut(mode) : null;
|
|
2114
2619
|
const cb = [0, 0, 0];
|
|
2115
2620
|
const cs = [0, 0, 0];
|
|
2116
2621
|
const n = dst.length;
|
|
@@ -2137,7 +2642,7 @@ function blendTile(dst, src, mode, alpha, coverage) {
|
|
|
2137
2642
|
const d1 = dst[i + 1];
|
|
2138
2643
|
const d2 = dst[i + 2];
|
|
2139
2644
|
if (pigment) {
|
|
2140
|
-
|
|
2645
|
+
_chunkTFOPHZ3Ucjs.mixPigment8.call(void 0, d0, d1, d2, src[i], src[i + 1], src[i + 2], as / ao, cb);
|
|
2141
2646
|
dst[i] = Math.round(cb[0] * 255);
|
|
2142
2647
|
dst[i + 1] = Math.round(cb[1] * 255);
|
|
2143
2648
|
dst[i + 2] = Math.round(cb[2] * 255);
|
|
@@ -2168,7 +2673,7 @@ function blendTile(dst, src, mode, alpha, coverage) {
|
|
|
2168
2673
|
cs[0] = s0;
|
|
2169
2674
|
cs[1] = s1;
|
|
2170
2675
|
cs[2] = s2;
|
|
2171
|
-
const m =
|
|
2676
|
+
const m = _chunkTFOPHZ3Ucjs.blendRgb.call(void 0, mode, cb, cs);
|
|
2172
2677
|
m0 = m[0];
|
|
2173
2678
|
m1 = m[1];
|
|
2174
2679
|
m2 = m[2];
|
|
@@ -2187,7 +2692,7 @@ function separableLut(mode) {
|
|
|
2187
2692
|
let lut = separableLuts.get(mode);
|
|
2188
2693
|
if (!lut) {
|
|
2189
2694
|
lut = new Float64Array(65536);
|
|
2190
|
-
for (let b = 0; b < 256; b++) for (let c = 0; c < 256; c++) lut[b << 8 | c] =
|
|
2695
|
+
for (let b = 0; b < 256; b++) for (let c = 0; c < 256; c++) lut[b << 8 | c] = _chunkTFOPHZ3Ucjs.blendChannel.call(void 0, mode, b / 255, c / 255);
|
|
2191
2696
|
separableLuts.set(mode, lut);
|
|
2192
2697
|
}
|
|
2193
2698
|
return lut;
|
|
@@ -2206,7 +2711,7 @@ function lerpTile(dst, before, alpha, coverage) {
|
|
|
2206
2711
|
}
|
|
2207
2712
|
}
|
|
2208
2713
|
var ZERO_TILE = new Uint8ClampedArray(TILE_BYTES);
|
|
2209
|
-
var
|
|
2714
|
+
var isGroup2 = (l) => l.type === "group";
|
|
2210
2715
|
var RasterCompositor = (_class = class {
|
|
2211
2716
|
constructor(profile = {}, options = {}) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);_class.prototype.__init10.call(this);_class.prototype.__init11.call(this);_class.prototype.__init12.call(this);_class.prototype.__init13.call(this);_class.prototype.__init14.call(this);_class.prototype.__init15.call(this);_class.prototype.__init16.call(this);_class.prototype.__init17.call(this);_class.prototype.__init18.call(this);_class.prototype.__init19.call(this);_class.prototype.__init20.call(this);_class.prototype.__init21.call(this);
|
|
2212
2717
|
this.profile = profile;
|
|
@@ -2261,15 +2766,15 @@ var RasterCompositor = (_class = class {
|
|
|
2261
2766
|
composite(layers, rect, sources, options = {}) {
|
|
2262
2767
|
const out = new Uint8ClampedArray(Math.max(0, rect.width * rect.height * 4));
|
|
2263
2768
|
this.compositeTiles(layers, rect, sources, (tx, ty, data) => {
|
|
2264
|
-
const ox = tx *
|
|
2265
|
-
const oy = ty *
|
|
2769
|
+
const ox = tx * _chunkTFOPHZ3Ucjs.TILE;
|
|
2770
|
+
const oy = ty * _chunkTFOPHZ3Ucjs.TILE;
|
|
2266
2771
|
const x0 = Math.max(rect.x, ox);
|
|
2267
2772
|
const y0 = Math.max(rect.y, oy);
|
|
2268
|
-
const x1 = Math.min(rect.x + rect.width, ox +
|
|
2269
|
-
const y1 = Math.min(rect.y + rect.height, oy +
|
|
2773
|
+
const x1 = Math.min(rect.x + rect.width, ox + _chunkTFOPHZ3Ucjs.TILE);
|
|
2774
|
+
const y1 = Math.min(rect.y + rect.height, oy + _chunkTFOPHZ3Ucjs.TILE);
|
|
2270
2775
|
const span = (x1 - x0) * 4;
|
|
2271
2776
|
for (let y = y0; y < y1; y++) {
|
|
2272
|
-
const s = ((y - oy) *
|
|
2777
|
+
const s = ((y - oy) * _chunkTFOPHZ3Ucjs.TILE + (x0 - ox)) * 4;
|
|
2273
2778
|
out.set(data.subarray(s, s + span), ((y - rect.y) * rect.width + (x0 - rect.x)) * 4);
|
|
2274
2779
|
}
|
|
2275
2780
|
}, options);
|
|
@@ -2290,9 +2795,9 @@ var RasterCompositor = (_class = class {
|
|
|
2290
2795
|
this.callStats = stats;
|
|
2291
2796
|
const grow = options.dirty ? this.effectsReach(layers) : 0;
|
|
2292
2797
|
const dirty = grow > 0 ? options.dirty.map((d) => inflateRect(d, grow)) : options.dirty;
|
|
2293
|
-
for (const { tx, ty } of
|
|
2798
|
+
for (const { tx, ty } of _chunkTFOPHZ3Ucjs.tilesInRect.call(void 0, rect)) {
|
|
2294
2799
|
stats.tiles++;
|
|
2295
|
-
const before = _optionalChain([this, 'access',
|
|
2800
|
+
const before = _optionalChain([this, 'access', _27 => _27.tiles, 'access', _28 => _28.get, 'call', _29 => _29(_chunkTFOPHZ3Ucjs.tileKey.call(void 0, tx, ty)), 'optionalAccess', _30 => _30.result]);
|
|
2296
2801
|
const data = this.compositeTile(layers, steps, tx, ty, stats, dirty ? dirtyInTile(dirty, tx, ty) : null);
|
|
2297
2802
|
onTile(tx, ty, data, data !== before);
|
|
2298
2803
|
}
|
|
@@ -2323,10 +2828,10 @@ var RasterCompositor = (_class = class {
|
|
|
2323
2828
|
// --- Steps -------------------------------------------------------------------
|
|
2324
2829
|
/** Pixel layers, and the layer kinds the profile composites like them. */
|
|
2325
2830
|
isPixel(l) {
|
|
2326
|
-
return l.type === "pixel" || (_nullishCoalesce(_optionalChain([this, 'access',
|
|
2831
|
+
return l.type === "pixel" || (_nullishCoalesce(_optionalChain([this, 'access', _31 => _31.profile, 'access', _32 => _32.isPixelLike, 'optionalCall', _33 => _33(l)]), () => ( false)));
|
|
2327
2832
|
}
|
|
2328
2833
|
isFilter(l) {
|
|
2329
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
2834
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _34 => _34.profile, 'access', _35 => _35.isFilterLayer, 'optionalCall', _36 => _36(l)]), () => ( false));
|
|
2330
2835
|
}
|
|
2331
2836
|
/**
|
|
2332
2837
|
* Groups a layer list into compositing steps: clipped layers join the nearest unclipped
|
|
@@ -2345,7 +2850,7 @@ var RasterCompositor = (_class = class {
|
|
|
2345
2850
|
if (this.isFilter(layer)) {
|
|
2346
2851
|
if (last && last.kind === "adjust") last.layers.push(layer);
|
|
2347
2852
|
else steps.push({ kind: "adjust", layers: [layer] });
|
|
2348
|
-
} else if (
|
|
2853
|
+
} else if (isGroup2(layer)) {
|
|
2349
2854
|
steps.push({ kind: "group", layer, clipped: [], steps: this.buildSteps(_nullishCoalesce(layer.children, () => ( []))) });
|
|
2350
2855
|
} else {
|
|
2351
2856
|
steps.push({ kind: "content", layer, clipped: [] });
|
|
@@ -2356,7 +2861,7 @@ var RasterCompositor = (_class = class {
|
|
|
2356
2861
|
}
|
|
2357
2862
|
/** The index of the top-level step that holds layer `id` (searching groups and clipped layers), or -1. */
|
|
2358
2863
|
stepIndexOf(steps, id) {
|
|
2359
|
-
const holds = (l) => l.id === id ||
|
|
2864
|
+
const holds = (l) => l.id === id || isGroup2(l) && (_nullishCoalesce(l.children, () => ( []))).some(holds);
|
|
2360
2865
|
return steps.findIndex((s) => s.kind === "adjust" ? s.layers.some(holds) : holds(s.layer) || s.clipped.some(holds));
|
|
2361
2866
|
}
|
|
2362
2867
|
/** Properties of a layer that change pixels, minus its surfaces (memoised per object). */
|
|
@@ -2365,16 +2870,16 @@ var RasterCompositor = (_class = class {
|
|
|
2365
2870
|
if (key !== void 0) return key;
|
|
2366
2871
|
const mask = layer.mask ? [layer.mask.enabled !== false, _nullishCoalesce(layer.mask.density, () => ( 1)), _nullishCoalesce(layer.mask.feather, () => ( 0)), layer.mask.defaultValue, _nullishCoalesce(layer.mask.source, () => ( null))] : null;
|
|
2367
2872
|
const base = [layer.type, layer.id, layer.visible, layer.opacity, layer.blend, Boolean(layer.clipped), mask];
|
|
2368
|
-
if (this.isPixel(layer)) base.push(_nullishCoalesce(_optionalChain([layer, 'access',
|
|
2873
|
+
if (this.isPixel(layer)) base.push(_nullishCoalesce(_optionalChain([layer, 'access', _37 => _37.offset, 'optionalAccess', _38 => _38.x]), () => ( 0)), _nullishCoalesce(_optionalChain([layer, 'access', _39 => _39.offset, 'optionalAccess', _40 => _40.y]), () => ( 0)), _nullishCoalesce(layer.fillOpacity, () => ( 1)));
|
|
2369
2874
|
if (this.hasEffects(layer)) base.push(effectsFingerprint(layer.effects));
|
|
2370
|
-
const extra = _optionalChain([this, 'access',
|
|
2875
|
+
const extra = _optionalChain([this, 'access', _41 => _41.profile, 'access', _42 => _42.layerKey, 'optionalCall', _43 => _43(layer)]);
|
|
2371
2876
|
if (extra !== void 0) base.push(extra);
|
|
2372
2877
|
key = JSON.stringify(base);
|
|
2373
2878
|
this.propsKeyCache.set(layer, key);
|
|
2374
2879
|
return key;
|
|
2375
2880
|
}
|
|
2376
2881
|
compositeTile(root, steps, tx, ty, stats, dirty = null) {
|
|
2377
|
-
const key =
|
|
2882
|
+
const key = _chunkTFOPHZ3Ucjs.tileKey.call(void 0, tx, ty);
|
|
2378
2883
|
const entry = this.tiles.get(key);
|
|
2379
2884
|
const sigs = steps.map((s) => this.stepSig(s, tx, ty));
|
|
2380
2885
|
let first = 0;
|
|
@@ -2397,20 +2902,20 @@ var RasterCompositor = (_class = class {
|
|
|
2397
2902
|
}
|
|
2398
2903
|
}
|
|
2399
2904
|
}
|
|
2400
|
-
const tileRect = { x: tx *
|
|
2905
|
+
const tileRect = { x: tx * _chunkTFOPHZ3Ucjs.TILE, y: ty * _chunkTFOPHZ3Ucjs.TILE, width: _chunkTFOPHZ3Ucjs.TILE, height: _chunkTFOPHZ3Ucjs.TILE };
|
|
2401
2906
|
const hint = this.hint;
|
|
2402
2907
|
const checkpoints = /* @__PURE__ */ new Map();
|
|
2403
2908
|
if (entry) {
|
|
2404
2909
|
for (const [index, cp] of entry.checkpoints) if (index <= start) checkpoints.set(index, cp);
|
|
2405
2910
|
}
|
|
2406
2911
|
let result;
|
|
2407
|
-
if (entry && dirty && (dirty.width <
|
|
2912
|
+
if (entry && dirty && (dirty.width < _chunkTFOPHZ3Ucjs.TILE || dirty.height < _chunkTFOPHZ3Ucjs.TILE)) {
|
|
2408
2913
|
const r = dirty;
|
|
2409
2914
|
const sub = (data) => {
|
|
2410
2915
|
const out = new Uint8ClampedArray(r.width * r.height * 4);
|
|
2411
2916
|
if (!data) return out;
|
|
2412
2917
|
for (let y = 0; y < r.height; y++) {
|
|
2413
|
-
const s = ((r.y - tileRect.y + y) *
|
|
2918
|
+
const s = ((r.y - tileRect.y + y) * _chunkTFOPHZ3Ucjs.TILE + (r.x - tileRect.x)) * 4;
|
|
2414
2919
|
out.set(data.subarray(s, s + r.width * 4), y * r.width * 4);
|
|
2415
2920
|
}
|
|
2416
2921
|
return out;
|
|
@@ -2423,7 +2928,7 @@ var RasterCompositor = (_class = class {
|
|
|
2423
2928
|
}
|
|
2424
2929
|
result = new Uint8ClampedArray(entry.result);
|
|
2425
2930
|
for (let y = 0; y < r.height; y++) {
|
|
2426
|
-
result.set(acc.subarray(y * r.width * 4, (y + 1) * r.width * 4), ((r.y - tileRect.y + y) *
|
|
2931
|
+
result.set(acc.subarray(y * r.width * 4, (y + 1) * r.width * 4), ((r.y - tileRect.y + y) * _chunkTFOPHZ3Ucjs.TILE + (r.x - tileRect.x)) * 4);
|
|
2427
2932
|
}
|
|
2428
2933
|
} else {
|
|
2429
2934
|
const acc = base ? new Uint8ClampedArray(base.data) : new Uint8ClampedArray(TILE_BYTES);
|
|
@@ -2504,7 +3009,7 @@ var RasterCompositor = (_class = class {
|
|
|
2504
3009
|
}
|
|
2505
3010
|
layerSig(layer, tx, ty) {
|
|
2506
3011
|
if (this.isFilter(layer)) return { key: this.propsKey(layer), refs: this.maskRefs(layer, tx, ty, 0, 0) };
|
|
2507
|
-
if (
|
|
3012
|
+
if (isGroup2(layer)) return this.groupSig(layer, this.buildSteps(_nullishCoalesce(layer.children, () => ( []))), tx, ty);
|
|
2508
3013
|
return this.contentSig(layer, tx, ty);
|
|
2509
3014
|
}
|
|
2510
3015
|
groupSig(group, steps, tx, ty) {
|
|
@@ -2532,9 +3037,9 @@ var RasterCompositor = (_class = class {
|
|
|
2532
3037
|
if (!this.isPixel(layer)) return { key, refs: this.maskRefs(layer, tx, ty, 0, 0) };
|
|
2533
3038
|
const { surface, dx, dy } = this.layerPixels(layer);
|
|
2534
3039
|
const refs = [surface.defaultValue];
|
|
2535
|
-
const r = { x: tx *
|
|
2536
|
-
for (const t of
|
|
2537
|
-
refs.push(...this.maskRefs(layer, tx, ty, _nullishCoalesce(_optionalChain([layer, 'access',
|
|
3040
|
+
const r = { x: tx * _chunkTFOPHZ3Ucjs.TILE - dx, y: ty * _chunkTFOPHZ3Ucjs.TILE - dy, width: _chunkTFOPHZ3Ucjs.TILE, height: _chunkTFOPHZ3Ucjs.TILE };
|
|
3041
|
+
for (const t of _chunkTFOPHZ3Ucjs.tilesInRect.call(void 0, r)) refs.push(_nullishCoalesce(surface.getTile(t.tx, t.ty), () => ( null)));
|
|
3042
|
+
refs.push(...this.maskRefs(layer, tx, ty, _nullishCoalesce(_optionalChain([layer, 'access', _44 => _44.offset, 'optionalAccess', _45 => _45.x]), () => ( 0)), _nullishCoalesce(_optionalChain([layer, 'access', _46 => _46.offset, 'optionalAccess', _47 => _47.y]), () => ( 0))));
|
|
2538
3043
|
return { key, refs };
|
|
2539
3044
|
}
|
|
2540
3045
|
// --- Layer effects ------------------------------------------------------------
|
|
@@ -2564,7 +3069,7 @@ var RasterCompositor = (_class = class {
|
|
|
2564
3069
|
this.fxContext = {
|
|
2565
3070
|
light: _nullishCoalesce(sources.globalLight, () => ( DEFAULT_GLOBAL_LIGHT)),
|
|
2566
3071
|
pattern: (id) => {
|
|
2567
|
-
const p = _nullishCoalesce(_optionalChain([sources, 'access',
|
|
3072
|
+
const p = _nullishCoalesce(_optionalChain([sources, 'access', _48 => _48.pattern, 'optionalCall', _49 => _49(id)]), () => ( builtinPattern(id)));
|
|
2568
3073
|
if (!p || !(p.width > 0 && p.height > 0) || p.data.length < p.width * p.height * 4) return null;
|
|
2569
3074
|
let t = tiles.get(p);
|
|
2570
3075
|
if (!t) {
|
|
@@ -2594,9 +3099,9 @@ var RasterCompositor = (_class = class {
|
|
|
2594
3099
|
shapeSigs(layer, region) {
|
|
2595
3100
|
const sigs = /* @__PURE__ */ new Map();
|
|
2596
3101
|
if (region.width <= 0 || region.height <= 0) return sigs;
|
|
2597
|
-
const steps =
|
|
2598
|
-
for (const t of
|
|
2599
|
-
sigs.set(
|
|
3102
|
+
const steps = isGroup2(layer) ? this.buildSteps(_nullishCoalesce(layer.children, () => ( []))) : null;
|
|
3103
|
+
for (const t of _chunkTFOPHZ3Ucjs.tilesInRect.call(void 0, region)) {
|
|
3104
|
+
sigs.set(_chunkTFOPHZ3Ucjs.tileKey.call(void 0, t.tx, t.ty), steps ? this.plainGroupSig(layer, steps, t.tx, t.ty) : this.plainContentSig(layer, t.tx, t.ty));
|
|
2600
3105
|
}
|
|
2601
3106
|
return sigs;
|
|
2602
3107
|
}
|
|
@@ -2616,11 +3121,11 @@ var RasterCompositor = (_class = class {
|
|
|
2616
3121
|
* laid out over the layer's bounds.
|
|
2617
3122
|
*/
|
|
2618
3123
|
effectSig(layer, tx, ty) {
|
|
2619
|
-
const key = (
|
|
3124
|
+
const key = (isGroup2(layer) ? "Gfx" : "Cfx") + this.propsKey(layer) + this.lightKey();
|
|
2620
3125
|
const region = this.effectRegion(layer);
|
|
2621
3126
|
const m = effectsMargin(layer.effects);
|
|
2622
3127
|
if (effectsAreLocal(activeEffectItems(layer.effects))) {
|
|
2623
|
-
return { key, refs: this.shapeRefs(layer, intersectRect({ x: tx *
|
|
3128
|
+
return { key, refs: this.shapeRefs(layer, intersectRect({ x: tx * _chunkTFOPHZ3Ucjs.TILE - m, y: ty * _chunkTFOPHZ3Ucjs.TILE - m, width: _chunkTFOPHZ3Ucjs.TILE + 2 * m, height: _chunkTFOPHZ3Ucjs.TILE + 2 * m }, region)) };
|
|
2624
3129
|
}
|
|
2625
3130
|
return { key, refs: [`${region.x},${region.y},${region.width},${region.height}`, ...this.shapeRefs(layer, region)] };
|
|
2626
3131
|
}
|
|
@@ -2669,11 +3174,11 @@ var RasterCompositor = (_class = class {
|
|
|
2669
3174
|
*/
|
|
2670
3175
|
shapeChanges(layer, prev, tiles, region) {
|
|
2671
3176
|
const out = [];
|
|
2672
|
-
for (const { tx, ty } of
|
|
2673
|
-
const sig = tiles.get(
|
|
2674
|
-
const old = prev.tiles.get(
|
|
3177
|
+
for (const { tx, ty } of _chunkTFOPHZ3Ucjs.tilesInRect.call(void 0, region)) {
|
|
3178
|
+
const sig = tiles.get(_chunkTFOPHZ3Ucjs.tileKey.call(void 0, tx, ty));
|
|
3179
|
+
const old = prev.tiles.get(_chunkTFOPHZ3Ucjs.tileKey.call(void 0, tx, ty));
|
|
2675
3180
|
if (old ? sameSig(old, sig) : sig.refs.every((r2) => r2 === null || r2 === 0)) continue;
|
|
2676
|
-
const r = intersectRect({ x: tx *
|
|
3181
|
+
const r = intersectRect({ x: tx * _chunkTFOPHZ3Ucjs.TILE, y: ty * _chunkTFOPHZ3Ucjs.TILE, width: _chunkTFOPHZ3Ucjs.TILE, height: _chunkTFOPHZ3Ucjs.TILE }, region);
|
|
2677
3182
|
if (r.width > 0 && r.height > 0) out.push(r);
|
|
2678
3183
|
}
|
|
2679
3184
|
const dirty = this.callDirty;
|
|
@@ -2692,7 +3197,7 @@ var RasterCompositor = (_class = class {
|
|
|
2692
3197
|
* without filters or a feathered or parametric mask (those spread a change beyond it).
|
|
2693
3198
|
*/
|
|
2694
3199
|
dirtyCoversShape(layer) {
|
|
2695
|
-
if (!this.isPixel(layer) || _optionalChain([this, 'access',
|
|
3200
|
+
if (!this.isPixel(layer) || _optionalChain([this, 'access', _50 => _50.profile, 'access', _51 => _51.pixelFilters, 'optionalCall', _52 => _52(layer)])) return false;
|
|
2696
3201
|
const mask = layer.mask;
|
|
2697
3202
|
return !mask || mask.enabled === false || !mask.source && !((_nullishCoalesce(mask.feather, () => ( 0))) > 0);
|
|
2698
3203
|
}
|
|
@@ -2709,7 +3214,7 @@ var RasterCompositor = (_class = class {
|
|
|
2709
3214
|
/** A content or group layer's own pixels over `r` with its mask applied to alpha, or `null` when empty. */
|
|
2710
3215
|
ownPixels(layer, r) {
|
|
2711
3216
|
let rgba;
|
|
2712
|
-
if (
|
|
3217
|
+
if (isGroup2(layer)) {
|
|
2713
3218
|
const buf = new Uint8ClampedArray(r.width * r.height * 4);
|
|
2714
3219
|
rgba = this.runSteps(this.buildSteps(_nullishCoalesce(layer.children, () => ( []))), buf, true, r) ? null : buf;
|
|
2715
3220
|
} else {
|
|
@@ -2743,7 +3248,7 @@ var RasterCompositor = (_class = class {
|
|
|
2743
3248
|
const content = _nullishCoalesce(this.ownPixels(layer, a), () => ( new Uint8ClampedArray(a.width * a.height * 4)));
|
|
2744
3249
|
if (clipped.length) this.applyClipped(clipped, content, a);
|
|
2745
3250
|
const keep = keepAlpha ? sub.filter((_, i) => (i & 3) === 3) : null;
|
|
2746
|
-
const blend2 =
|
|
3251
|
+
const blend2 = isGroup2(layer) ? layer.blend === "pass-through" ? "normal" : layer.blend : this.contentBlend(layer);
|
|
2747
3252
|
compositeLayerEffects({
|
|
2748
3253
|
backdrop: sub,
|
|
2749
3254
|
content,
|
|
@@ -2768,7 +3273,7 @@ var RasterCompositor = (_class = class {
|
|
|
2768
3273
|
if (!mask || mask.enabled === false) return [];
|
|
2769
3274
|
if (mask.source || (_nullishCoalesce(mask.feather, () => ( 0))) > 0) return [this.planeFor(mask, ox, oy)];
|
|
2770
3275
|
const refs = [];
|
|
2771
|
-
for (const t of
|
|
3276
|
+
for (const t of _chunkTFOPHZ3Ucjs.tilesInRect.call(void 0, { x: tx * _chunkTFOPHZ3Ucjs.TILE - ox, y: ty * _chunkTFOPHZ3Ucjs.TILE - oy, width: _chunkTFOPHZ3Ucjs.TILE, height: _chunkTFOPHZ3Ucjs.TILE })) {
|
|
2772
3277
|
refs.push(_nullishCoalesce(mask.surface.getTile(t.tx, t.ty), () => ( null)));
|
|
2773
3278
|
}
|
|
2774
3279
|
return refs;
|
|
@@ -2780,10 +3285,10 @@ var RasterCompositor = (_class = class {
|
|
|
2780
3285
|
*/
|
|
2781
3286
|
layerPixels(layer) {
|
|
2782
3287
|
const raw = this.sources.surfaceOf ? this.sources.surfaceOf(layer) : layer.surface;
|
|
2783
|
-
const ox = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
2784
|
-
const oy = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
2785
|
-
const filters = _nullishCoalesce(_optionalChain([this, 'access',
|
|
2786
|
-
if (!_optionalChain([filters, 'optionalAccess',
|
|
3288
|
+
const ox = _nullishCoalesce(_optionalChain([layer, 'access', _53 => _53.offset, 'optionalAccess', _54 => _54.x]), () => ( 0));
|
|
3289
|
+
const oy = _nullishCoalesce(_optionalChain([layer, 'access', _55 => _55.offset, 'optionalAccess', _56 => _56.y]), () => ( 0));
|
|
3290
|
+
const filters = _nullishCoalesce(_optionalChain([this, 'access', _57 => _57.profile, 'access', _58 => _58.pixelFilters, 'optionalCall', _59 => _59(layer)]), () => ( null));
|
|
3291
|
+
if (!_optionalChain([filters, 'optionalAccess', _60 => _60.spatial])) return { surface: raw, dx: ox, dy: oy, perPixel: filters };
|
|
2787
3292
|
const fkey = `${ox},${oy}:${filters.key}`;
|
|
2788
3293
|
let byKey = this.filteredCache.get(raw);
|
|
2789
3294
|
if (!byKey) {
|
|
@@ -2800,25 +3305,25 @@ var RasterCompositor = (_class = class {
|
|
|
2800
3305
|
}
|
|
2801
3306
|
/** RGBA of a content layer over `r` (document space, inside one tile), or `null` when it has nothing there. */
|
|
2802
3307
|
contentTile(layer, r) {
|
|
2803
|
-
if (!this.isPixel(layer)) return _nullishCoalesce(_optionalChain([this, 'access',
|
|
3308
|
+
if (!this.isPixel(layer)) return _nullishCoalesce(_optionalChain([this, 'access', _61 => _61.profile, 'access', _62 => _62.contentTile, 'optionalCall', _63 => _63(layer, r, this.sources)]), () => ( null));
|
|
2804
3309
|
const { surface, dx, dy, perPixel } = this.layerPixels(layer);
|
|
2805
3310
|
const src = { x: r.x - dx, y: r.y - dy, width: r.width, height: r.height };
|
|
2806
|
-
const covered =
|
|
3311
|
+
const covered = _chunkTFOPHZ3Ucjs.tilesInRect.call(void 0, src).map((t) => surface.getTile(t.tx, t.ty));
|
|
2807
3312
|
if (surface.defaultValue === 0 && covered.every((t) => !t)) return null;
|
|
2808
|
-
const aligned = r.width ===
|
|
3313
|
+
const aligned = r.width === _chunkTFOPHZ3Ucjs.TILE && r.height === _chunkTFOPHZ3Ucjs.TILE && src.x % _chunkTFOPHZ3Ucjs.TILE === 0 && src.y % _chunkTFOPHZ3Ucjs.TILE === 0;
|
|
2809
3314
|
if (!perPixel) {
|
|
2810
3315
|
if (aligned && covered[0]) return covered[0].data;
|
|
2811
|
-
return
|
|
3316
|
+
return _chunkTFOPHZ3Ucjs.readRegion.call(void 0, surface, src);
|
|
2812
3317
|
}
|
|
2813
3318
|
const fkey = `${dx},${dy}:${perPixel.key}`;
|
|
2814
3319
|
const anchor = _nullishCoalesce(covered.find(Boolean), () => ( surface));
|
|
2815
3320
|
let byKey = this.contentCache.get(anchor);
|
|
2816
3321
|
const refsKey = `${r.x},${r.y}:${fkey}`;
|
|
2817
3322
|
if (aligned) {
|
|
2818
|
-
const hit = _optionalChain([byKey, 'optionalAccess',
|
|
3323
|
+
const hit = _optionalChain([byKey, 'optionalAccess', _64 => _64.get, 'call', _65 => _65(refsKey)]);
|
|
2819
3324
|
if (hit) return hit;
|
|
2820
3325
|
}
|
|
2821
|
-
const data =
|
|
3326
|
+
const data = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, surface, src);
|
|
2822
3327
|
perPixel.apply(data, r.width, r.height);
|
|
2823
3328
|
if (aligned) {
|
|
2824
3329
|
if (!byKey) {
|
|
@@ -2853,11 +3358,11 @@ var RasterCompositor = (_class = class {
|
|
|
2853
3358
|
const H = this.sources.height;
|
|
2854
3359
|
let v = new Float32Array(W * H);
|
|
2855
3360
|
if (mask.source) {
|
|
2856
|
-
const generated = _nullishCoalesce(_optionalChain([this, 'access',
|
|
3361
|
+
const generated = _nullishCoalesce(_optionalChain([this, 'access', _66 => _66.profile, 'access', _67 => _67.maskSourcePlane, 'optionalCall', _68 => _68(mask.source, W, H, this.sources)]), () => ( null));
|
|
2857
3362
|
if (!generated || generated.length !== W * H) v.fill(1);
|
|
2858
3363
|
else v.set(generated);
|
|
2859
3364
|
} else {
|
|
2860
|
-
const bytes =
|
|
3365
|
+
const bytes = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, mask.surface, { x: -ox, y: -oy, width: W, height: H });
|
|
2861
3366
|
for (let i = 0; i < v.length; i++) v[i] = bytes[i] / 255;
|
|
2862
3367
|
}
|
|
2863
3368
|
const feather = _nullishCoalesce(mask.feather, () => ( 0));
|
|
@@ -2872,8 +3377,8 @@ var RasterCompositor = (_class = class {
|
|
|
2872
3377
|
maskTile(layer, r) {
|
|
2873
3378
|
const mask = layer.mask;
|
|
2874
3379
|
if (!mask || mask.enabled === false) return null;
|
|
2875
|
-
const ox = this.isPixel(layer) ? _nullishCoalesce(_optionalChain([layer, 'access',
|
|
2876
|
-
const oy = this.isPixel(layer) ? _nullishCoalesce(_optionalChain([layer, 'access',
|
|
3380
|
+
const ox = this.isPixel(layer) ? _nullishCoalesce(_optionalChain([layer, 'access', _69 => _69.offset, 'optionalAccess', _70 => _70.x]), () => ( 0)) : 0;
|
|
3381
|
+
const oy = this.isPixel(layer) ? _nullishCoalesce(_optionalChain([layer, 'access', _71 => _71.offset, 'optionalAccess', _72 => _72.y]), () => ( 0)) : 0;
|
|
2877
3382
|
const n = r.width * r.height;
|
|
2878
3383
|
const out = new Float32Array(n);
|
|
2879
3384
|
const density = _nullishCoalesce(mask.density, () => ( 1));
|
|
@@ -2893,7 +3398,7 @@ var RasterCompositor = (_class = class {
|
|
|
2893
3398
|
for (let x = x0; x < x1; x++) out[d + x] = plane.data[s + x];
|
|
2894
3399
|
}
|
|
2895
3400
|
} else {
|
|
2896
|
-
const bytes =
|
|
3401
|
+
const bytes = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, mask.surface, { x: r.x - ox, y: r.y - oy, width: r.width, height: r.height });
|
|
2897
3402
|
let all = true;
|
|
2898
3403
|
for (let i = 0; i < n; i++) {
|
|
2899
3404
|
out[i] = bytes[i] / 255;
|
|
@@ -2947,7 +3452,7 @@ var RasterCompositor = (_class = class {
|
|
|
2947
3452
|
return empty;
|
|
2948
3453
|
}
|
|
2949
3454
|
contentBlend(layer) {
|
|
2950
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
3455
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _73 => _73.profile, 'access', _74 => _74.contentBlend, 'optionalCall', _75 => _75(layer)]), () => ( layer.blend));
|
|
2951
3456
|
}
|
|
2952
3457
|
blendOnto(acc, src, empty, mode, alpha, coverage) {
|
|
2953
3458
|
if (!(alpha > 0)) return empty;
|
|
@@ -2970,12 +3475,12 @@ var RasterCompositor = (_class = class {
|
|
|
2970
3475
|
continue;
|
|
2971
3476
|
}
|
|
2972
3477
|
flush();
|
|
2973
|
-
if (this.hasEffects(c) && !
|
|
3478
|
+
if (this.hasEffects(c) && !isGroup2(c)) {
|
|
2974
3479
|
this.compositeEffects(c, [], buf, r, true);
|
|
2975
3480
|
continue;
|
|
2976
3481
|
}
|
|
2977
3482
|
const coverage = this.maskTile(c, r);
|
|
2978
|
-
if (
|
|
3483
|
+
if (isGroup2(c)) {
|
|
2979
3484
|
const inner = new Uint8ClampedArray(buf.length);
|
|
2980
3485
|
if (this.runSteps(this.buildSteps(_nullishCoalesce(c.children, () => ( []))), inner, true, r)) continue;
|
|
2981
3486
|
const mode = c.blend === "pass-through" ? "normal" : c.blend;
|
|
@@ -3001,14 +3506,14 @@ var RasterCompositor = (_class = class {
|
|
|
3001
3506
|
}
|
|
3002
3507
|
visible.push(node);
|
|
3003
3508
|
}
|
|
3004
|
-
if (visible.length) _optionalChain([this, 'access',
|
|
3509
|
+
if (visible.length) _optionalChain([this, 'access', _76 => _76.profile, 'access', _77 => _77.applyFilterRun, 'optionalCall', _78 => _78(visible, acc, r, masks, this.sources)]);
|
|
3005
3510
|
}
|
|
3006
3511
|
}, _class);
|
|
3007
3512
|
function filterOverCanvas(surface, ox, oy, filters, width, height) {
|
|
3008
|
-
if (width <= 0 || height <= 0) return
|
|
3009
|
-
const data =
|
|
3513
|
+
if (width <= 0 || height <= 0) return _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4);
|
|
3514
|
+
const data = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, surface, { x: -ox, y: -oy, width, height });
|
|
3010
3515
|
filters.apply(data, width, height);
|
|
3011
|
-
return
|
|
3516
|
+
return _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, { width, height, data }, 4, 0, 0);
|
|
3012
3517
|
}
|
|
3013
3518
|
function copyRect(data, r, a) {
|
|
3014
3519
|
const out = new Uint8ClampedArray(a.width * a.height * 4);
|
|
@@ -3097,7 +3602,7 @@ function intersect(a, b) {
|
|
|
3097
3602
|
return x1 > x && y1 > y ? { x, y, width: x1 - x, height: y1 - y } : null;
|
|
3098
3603
|
}
|
|
3099
3604
|
function hasTilesIn(src, r) {
|
|
3100
|
-
for (const { tx, ty } of
|
|
3605
|
+
for (const { tx, ty } of _chunkTFOPHZ3Ucjs.tilesInRect.call(void 0, r)) if (src.getTile(tx, ty)) return true;
|
|
3101
3606
|
return false;
|
|
3102
3607
|
}
|
|
3103
3608
|
function readWindow(src, srcRect, rect) {
|
|
@@ -3106,7 +3611,7 @@ function readWindow(src, srcRect, rect) {
|
|
|
3106
3611
|
const win = { x: rect.x, y: rect.y, w: rect.width, h: rect.height, n, data };
|
|
3107
3612
|
const r = intersect(rect, srcRect);
|
|
3108
3613
|
if (!r) return win;
|
|
3109
|
-
const px =
|
|
3614
|
+
const px = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, src, r);
|
|
3110
3615
|
for (let y = 0; y < r.height; y++) {
|
|
3111
3616
|
let s = y * r.width * src.channels;
|
|
3112
3617
|
let d = ((r.y - rect.y + y) * rect.width + (r.x - rect.x)) * n;
|
|
@@ -3248,13 +3753,13 @@ function boxReduce(src, srcRect, kx, ky) {
|
|
|
3248
3753
|
const ry1 = Math.ceil((srcRect.y + srcRect.height) / ky);
|
|
3249
3754
|
const rw = rx1 - rx0;
|
|
3250
3755
|
const rect = { x: rx0, y: ry0, width: rw, height: ry1 - ry0 };
|
|
3251
|
-
let out =
|
|
3252
|
-
const rowsPer = Math.max(1, Math.floor(
|
|
3756
|
+
let out = _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, ch, src.defaultValue);
|
|
3757
|
+
const rowsPer = Math.max(1, Math.floor(_chunkTFOPHZ3Ucjs.TILE / ky));
|
|
3253
3758
|
const area = kx * ky;
|
|
3254
3759
|
for (let ry = ry0; ry < ry1; ry += rowsPer) {
|
|
3255
3760
|
const rows = Math.min(rowsPer, ry1 - ry);
|
|
3256
3761
|
const strip = { x: rx0 * kx, y: ry * ky, width: rw * kx, height: rows * ky };
|
|
3257
|
-
const px =
|
|
3762
|
+
const px = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, src, strip);
|
|
3258
3763
|
const red = new Uint8ClampedArray(rw * rows * ch);
|
|
3259
3764
|
for (let j = 0; j < rows; j++) {
|
|
3260
3765
|
for (let i = 0; i < rw; i++) {
|
|
@@ -3290,13 +3795,13 @@ function boxReduce(src, srcRect, kx, ky) {
|
|
|
3290
3795
|
}
|
|
3291
3796
|
}
|
|
3292
3797
|
}
|
|
3293
|
-
out =
|
|
3798
|
+
out = _chunkTFOPHZ3Ucjs.writeRegion.call(void 0, out, { x: rx0, y: ry, width: rw, height: rows }, red);
|
|
3294
3799
|
}
|
|
3295
3800
|
return { surface: out, rect };
|
|
3296
3801
|
}
|
|
3297
3802
|
function reduceSurface(src, factor) {
|
|
3298
3803
|
const k = Math.max(1, Math.floor(factor));
|
|
3299
|
-
const b =
|
|
3804
|
+
const b = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, src);
|
|
3300
3805
|
if (k === 1 || !b) return src;
|
|
3301
3806
|
return boxReduce(src, b, k, k).surface;
|
|
3302
3807
|
}
|
|
@@ -3324,7 +3829,7 @@ function checkBudget(dst, what = "result") {
|
|
|
3324
3829
|
}
|
|
3325
3830
|
}
|
|
3326
3831
|
function assemble(src, tiles) {
|
|
3327
|
-
return new (0,
|
|
3832
|
+
return new (0, _chunkTFOPHZ3Ucjs.TiledSurface)(src.channels, tiles, src.defaultValue);
|
|
3328
3833
|
}
|
|
3329
3834
|
function transformedBounds(source, h) {
|
|
3330
3835
|
if (!(source.width > 0 && source.height > 0) || !_chunkMUUXNRU4cjs.invertHomography.call(void 0, h)) return null;
|
|
@@ -3336,16 +3841,16 @@ function transformSurface(src, h, options = {}) {
|
|
|
3336
3841
|
const interp = _nullishCoalesce(options.interpolation, () => ( "bicubic"));
|
|
3337
3842
|
const ch = src.channels;
|
|
3338
3843
|
const def = src.defaultValue;
|
|
3339
|
-
const empty =
|
|
3844
|
+
const empty = _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, ch, def);
|
|
3340
3845
|
const given = options.source;
|
|
3341
3846
|
const step = normalizeStep(options.step);
|
|
3342
3847
|
if (_chunkMUUXNRU4cjs.isIdentityHomography.call(void 0, h, 1e-12) && !given && !options.clip) return src;
|
|
3343
3848
|
const dx = h[2] / h[8];
|
|
3344
3849
|
const dy = h[5] / h[8];
|
|
3345
3850
|
if (!given && !options.clip && _chunkMUUXNRU4cjs.isIdentityHomography.call(void 0, [h[0], h[1], 0, h[3], h[4], 0, h[6], h[7], h[8]], 1e-12) && Math.abs(dx - Math.round(dx)) < 1e-9 && Math.abs(dy - Math.round(dy)) < 1e-9) {
|
|
3346
|
-
return
|
|
3851
|
+
return _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, src, Math.round(dx), Math.round(dy));
|
|
3347
3852
|
}
|
|
3348
|
-
let srcRect = given ? intersect(given, given) :
|
|
3853
|
+
let srcRect = given ? intersect(given, given) : _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, src);
|
|
3349
3854
|
if (!srcRect) return empty;
|
|
3350
3855
|
let H = h;
|
|
3351
3856
|
let S = src;
|
|
@@ -3395,8 +3900,8 @@ function transformSurface(src, h, options = {}) {
|
|
|
3395
3900
|
const sy0 = sr.y;
|
|
3396
3901
|
const sx1 = sr.x + sr.width - 1;
|
|
3397
3902
|
const sy1 = sr.y + sr.height - 1;
|
|
3398
|
-
for (const { tx, ty } of
|
|
3399
|
-
const t = intersect({ x: tx *
|
|
3903
|
+
for (const { tx, ty } of _chunkTFOPHZ3Ucjs.tilesInRect.call(void 0, dst)) {
|
|
3904
|
+
const t = intersect({ x: tx * _chunkTFOPHZ3Ucjs.TILE, y: ty * _chunkTFOPHZ3Ucjs.TILE, width: _chunkTFOPHZ3Ucjs.TILE, height: _chunkTFOPHZ3Ucjs.TILE }, dst);
|
|
3400
3905
|
if (!t) continue;
|
|
3401
3906
|
const tc = [
|
|
3402
3907
|
{ x: t.x, y: t.y },
|
|
@@ -3442,11 +3947,11 @@ function transformSurface(src, h, options = {}) {
|
|
|
3442
3947
|
const readable = intersect(foot, sr);
|
|
3443
3948
|
if (!readable || !hasTilesIn(S, readable)) continue;
|
|
3444
3949
|
const win = readWindow(S, sr, foot);
|
|
3445
|
-
const out = new Uint8ClampedArray(
|
|
3950
|
+
const out = new Uint8ClampedArray(_chunkTFOPHZ3Ucjs.TILE * _chunkTFOPHZ3Ucjs.TILE * ch);
|
|
3446
3951
|
if (def) out.fill(def);
|
|
3447
3952
|
let any = false;
|
|
3448
|
-
const ox = tx *
|
|
3449
|
-
const oy = ty *
|
|
3953
|
+
const ox = tx * _chunkTFOPHZ3Ucjs.TILE;
|
|
3954
|
+
const oy = ty * _chunkTFOPHZ3Ucjs.TILE;
|
|
3450
3955
|
let su = widen(su0);
|
|
3451
3956
|
let sv = widen(sv0);
|
|
3452
3957
|
const ystart = t.y - ((t.y - oy) % step + step) % step;
|
|
@@ -3482,7 +3987,7 @@ function transformSurface(src, h, options = {}) {
|
|
|
3482
3987
|
const y0 = Math.max(y, t.y);
|
|
3483
3988
|
const y1 = Math.min(y + step, t.y + t.height);
|
|
3484
3989
|
for (let yy = y0; yy < y1; yy++) {
|
|
3485
|
-
const row = (yy - oy) *
|
|
3990
|
+
const row = (yy - oy) * _chunkTFOPHZ3Ucjs.TILE - ox;
|
|
3486
3991
|
for (let bi = 0, x = xstart; bi < blocks; bi++, x += step) {
|
|
3487
3992
|
if (!rowSet[bi]) continue;
|
|
3488
3993
|
const x0 = Math.max(x, t.x);
|
|
@@ -3494,8 +3999,8 @@ function transformSurface(src, h, options = {}) {
|
|
|
3494
3999
|
}
|
|
3495
4000
|
}
|
|
3496
4001
|
if (!any) continue;
|
|
3497
|
-
const tile =
|
|
3498
|
-
if (tile) tiles.set(
|
|
4002
|
+
const tile = _chunkTFOPHZ3Ucjs.finishTile.call(void 0, out, ch, def);
|
|
4003
|
+
if (tile) tiles.set(_chunkTFOPHZ3Ucjs.tileKey.call(void 0, tx, ty), tile);
|
|
3499
4004
|
}
|
|
3500
4005
|
return assemble(src, tiles);
|
|
3501
4006
|
}
|
|
@@ -3506,8 +4011,8 @@ function warpSurface(src, f, options = {}) {
|
|
|
3506
4011
|
const interp = _nullishCoalesce(options.interpolation, () => ( "bicubic"));
|
|
3507
4012
|
const ch = src.channels;
|
|
3508
4013
|
const def = src.defaultValue;
|
|
3509
|
-
const empty =
|
|
3510
|
-
const sr = options.source ? intersect(options.source, options.source) :
|
|
4014
|
+
const empty = _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, ch, def);
|
|
4015
|
+
const sr = options.source ? intersect(options.source, options.source) : _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, src);
|
|
3511
4016
|
if (!sr) return empty;
|
|
3512
4017
|
const step = normalizeStep(options.step);
|
|
3513
4018
|
const nx = Math.min(MAX_CELLS, Math.max(1, Math.ceil(sr.width / CELL)));
|
|
@@ -3558,10 +4063,10 @@ function warpSurface(src, f, options = {}) {
|
|
|
3558
4063
|
tris[t++] = a + w1;
|
|
3559
4064
|
}
|
|
3560
4065
|
}
|
|
3561
|
-
const tx0 = Math.floor(dst.x /
|
|
3562
|
-
const ty0 = Math.floor(dst.y /
|
|
3563
|
-
const cols = Math.floor((dst.x + dst.width - 1) /
|
|
3564
|
-
const rows = Math.floor((dst.y + dst.height - 1) /
|
|
4066
|
+
const tx0 = Math.floor(dst.x / _chunkTFOPHZ3Ucjs.TILE);
|
|
4067
|
+
const ty0 = Math.floor(dst.y / _chunkTFOPHZ3Ucjs.TILE);
|
|
4068
|
+
const cols = Math.floor((dst.x + dst.width - 1) / _chunkTFOPHZ3Ucjs.TILE) - tx0 + 1;
|
|
4069
|
+
const rows = Math.floor((dst.y + dst.height - 1) / _chunkTFOPHZ3Ucjs.TILE) - ty0 + 1;
|
|
3565
4070
|
const bins = Array.from({ length: cols * rows }, () => []);
|
|
3566
4071
|
for (let k = 0; k < triCount; k++) {
|
|
3567
4072
|
const a = tris[3 * k];
|
|
@@ -3571,10 +4076,10 @@ function warpSurface(src, f, options = {}) {
|
|
|
3571
4076
|
const tminy = Math.floor(Math.min(dvy[a], dvy[b], dvy[c]));
|
|
3572
4077
|
const tmaxx = Math.ceil(Math.max(dvx[a], dvx[b], dvx[c]));
|
|
3573
4078
|
const tmaxy = Math.ceil(Math.max(dvy[a], dvy[b], dvy[c]));
|
|
3574
|
-
const cx0 = Math.max(0, Math.floor(Math.max(tminx, dst.x) /
|
|
3575
|
-
const cy0 = Math.max(0, Math.floor(Math.max(tminy, dst.y) /
|
|
3576
|
-
const cx1 = Math.min(cols - 1, Math.floor(Math.min(tmaxx, dst.x + dst.width - 1) /
|
|
3577
|
-
const cy1 = Math.min(rows - 1, Math.floor(Math.min(tmaxy, dst.y + dst.height - 1) /
|
|
4079
|
+
const cx0 = Math.max(0, Math.floor(Math.max(tminx, dst.x) / _chunkTFOPHZ3Ucjs.TILE) - tx0);
|
|
4080
|
+
const cy0 = Math.max(0, Math.floor(Math.max(tminy, dst.y) / _chunkTFOPHZ3Ucjs.TILE) - ty0);
|
|
4081
|
+
const cx1 = Math.min(cols - 1, Math.floor(Math.min(tmaxx, dst.x + dst.width - 1) / _chunkTFOPHZ3Ucjs.TILE) - tx0);
|
|
4082
|
+
const cy1 = Math.min(rows - 1, Math.floor(Math.min(tmaxy, dst.y + dst.height - 1) / _chunkTFOPHZ3Ucjs.TILE) - ty0);
|
|
3578
4083
|
for (let cy = cy0; cy <= cy1; cy++) for (let cx = cx0; cx <= cx1; cx++) bins[cy * cols + cx].push(k);
|
|
3579
4084
|
}
|
|
3580
4085
|
const tiles = /* @__PURE__ */ new Map();
|
|
@@ -3588,7 +4093,7 @@ function warpSurface(src, f, options = {}) {
|
|
|
3588
4093
|
if (!list.length) continue;
|
|
3589
4094
|
const ttx = tx0 + cx;
|
|
3590
4095
|
const tty = ty0 + cy;
|
|
3591
|
-
const t = intersect({ x: ttx *
|
|
4096
|
+
const t = intersect({ x: ttx * _chunkTFOPHZ3Ucjs.TILE, y: tty * _chunkTFOPHZ3Ucjs.TILE, width: _chunkTFOPHZ3Ucjs.TILE, height: _chunkTFOPHZ3Ucjs.TILE }, dst);
|
|
3592
4097
|
if (!t) continue;
|
|
3593
4098
|
const tw = t.width;
|
|
3594
4099
|
const th = t.height;
|
|
@@ -3678,11 +4183,11 @@ function warpSurface(src, f, options = {}) {
|
|
|
3678
4183
|
const foot = intersect({ x: Math.floor(fx0) - 3, y: Math.floor(fy0) - 3, width: Math.ceil(fx1) - Math.floor(fx0) + 6, height: Math.ceil(fy1) - Math.floor(fy0) + 6 }, sr);
|
|
3679
4184
|
if (!foot || !hasTilesIn(src, foot)) continue;
|
|
3680
4185
|
const win = readWindow(src, sr, foot);
|
|
3681
|
-
const out = new Uint8ClampedArray(
|
|
4186
|
+
const out = new Uint8ClampedArray(_chunkTFOPHZ3Ucjs.TILE * _chunkTFOPHZ3Ucjs.TILE * ch);
|
|
3682
4187
|
if (def) out.fill(def);
|
|
3683
4188
|
let any = false;
|
|
3684
|
-
const ox = ttx *
|
|
3685
|
-
const oy = tty *
|
|
4189
|
+
const ox = ttx * _chunkTFOPHZ3Ucjs.TILE;
|
|
4190
|
+
const oy = tty * _chunkTFOPHZ3Ucjs.TILE;
|
|
3686
4191
|
const pointAt = (o, into) => {
|
|
3687
4192
|
const li = owner[o];
|
|
3688
4193
|
const cnx = ssx[li];
|
|
@@ -3713,7 +4218,7 @@ function warpSurface(src, f, options = {}) {
|
|
|
3713
4218
|
pointAt(o, acc);
|
|
3714
4219
|
const x = t.x + o % tw;
|
|
3715
4220
|
const y = t.y + Math.floor(o / tw);
|
|
3716
|
-
if (store(out, ((y - oy) *
|
|
4221
|
+
if (store(out, ((y - oy) * _chunkTFOPHZ3Ucjs.TILE + (x - ox)) * ch, acc, ch, def)) any = true;
|
|
3717
4222
|
}
|
|
3718
4223
|
} else {
|
|
3719
4224
|
for (let by = 0; by < th; by += step) {
|
|
@@ -3721,19 +4226,19 @@ function warpSurface(src, f, options = {}) {
|
|
|
3721
4226
|
const o = by * tw + bx;
|
|
3722
4227
|
if (Number.isNaN(us[o])) continue;
|
|
3723
4228
|
pointAt(o, acc);
|
|
3724
|
-
const first = ((t.y + by - oy) *
|
|
4229
|
+
const first = ((t.y + by - oy) * _chunkTFOPHZ3Ucjs.TILE + (t.x + bx - ox)) * ch;
|
|
3725
4230
|
if (!store(out, first, acc, ch, def)) continue;
|
|
3726
4231
|
any = true;
|
|
3727
4232
|
for (let yy = by; yy < Math.min(th, by + step); yy++) {
|
|
3728
|
-
const row = ((t.y + yy - oy) *
|
|
4233
|
+
const row = ((t.y + yy - oy) * _chunkTFOPHZ3Ucjs.TILE + (t.x - ox)) * ch;
|
|
3729
4234
|
for (let xx = bx; xx < Math.min(tw, bx + step); xx++) for (let c = 0; c < ch; c++) out[row + xx * ch + c] = out[first + c];
|
|
3730
4235
|
}
|
|
3731
4236
|
}
|
|
3732
4237
|
}
|
|
3733
4238
|
}
|
|
3734
4239
|
if (!any) continue;
|
|
3735
|
-
const tile =
|
|
3736
|
-
if (tile) tiles.set(
|
|
4240
|
+
const tile = _chunkTFOPHZ3Ucjs.finishTile.call(void 0, out, ch, def);
|
|
4241
|
+
if (tile) tiles.set(_chunkTFOPHZ3Ucjs.tileKey.call(void 0, ttx, tty), tile);
|
|
3737
4242
|
}
|
|
3738
4243
|
}
|
|
3739
4244
|
return assemble(src, tiles);
|
|
@@ -3749,7 +4254,7 @@ function compositeSurfaceOver(base, top) {
|
|
|
3749
4254
|
tiles.set(key, t);
|
|
3750
4255
|
continue;
|
|
3751
4256
|
}
|
|
3752
|
-
const d = new Uint8ClampedArray(
|
|
4257
|
+
const d = new Uint8ClampedArray(_chunkTFOPHZ3Ucjs.TILE * _chunkTFOPHZ3Ucjs.TILE * ch);
|
|
3753
4258
|
if (under) d.set(under.data);
|
|
3754
4259
|
else if (base.defaultValue) d.fill(base.defaultValue);
|
|
3755
4260
|
const s = t.data;
|
|
@@ -3775,536 +4280,11 @@ function compositeSurfaceOver(base, top) {
|
|
|
3775
4280
|
if (ta > 0) d[p] = s[i] * ta + d[p] * (1 - ta);
|
|
3776
4281
|
}
|
|
3777
4282
|
}
|
|
3778
|
-
const tile =
|
|
4283
|
+
const tile = _chunkTFOPHZ3Ucjs.finishTile.call(void 0, d, ch, base.defaultValue);
|
|
3779
4284
|
if (tile) tiles.set(key, tile);
|
|
3780
4285
|
else tiles.delete(key);
|
|
3781
4286
|
}
|
|
3782
|
-
return new (0,
|
|
3783
|
-
}
|
|
3784
|
-
|
|
3785
|
-
// src/raster/zlib.ts
|
|
3786
|
-
var LENGTH_BASE = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258];
|
|
3787
|
-
var LENGTH_EXTRA = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0];
|
|
3788
|
-
var DIST_BASE = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577];
|
|
3789
|
-
var DIST_EXTRA = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13];
|
|
3790
|
-
var CL_ORDER = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
|
|
3791
|
-
var ZlibError = class extends Error {
|
|
3792
|
-
constructor(message) {
|
|
3793
|
-
super(message);
|
|
3794
|
-
this.name = "ZlibError";
|
|
3795
|
-
}
|
|
3796
|
-
};
|
|
3797
|
-
function buildHuffman(lengths, n) {
|
|
3798
|
-
const counts = new Uint16Array(16);
|
|
3799
|
-
for (let i = 0; i < n; i++) counts[lengths[i]]++;
|
|
3800
|
-
counts[0] = 0;
|
|
3801
|
-
const offs = new Uint16Array(16);
|
|
3802
|
-
for (let i = 1; i < 16; i++) offs[i] = offs[i - 1] + counts[i - 1];
|
|
3803
|
-
const symbols = new Uint16Array(n);
|
|
3804
|
-
for (let i = 0; i < n; i++) if (lengths[i]) symbols[offs[lengths[i]]++] = i;
|
|
3805
|
-
return { counts, symbols };
|
|
3806
|
-
}
|
|
3807
|
-
var fixedLit = null;
|
|
3808
|
-
var fixedDist = null;
|
|
3809
|
-
function fixedTables() {
|
|
3810
|
-
if (!fixedLit || !fixedDist) {
|
|
3811
|
-
const l = new Uint8Array(288);
|
|
3812
|
-
for (let i = 0; i < 144; i++) l[i] = 8;
|
|
3813
|
-
for (let i = 144; i < 256; i++) l[i] = 9;
|
|
3814
|
-
for (let i = 256; i < 280; i++) l[i] = 7;
|
|
3815
|
-
for (let i = 280; i < 288; i++) l[i] = 8;
|
|
3816
|
-
fixedLit = buildHuffman(l, 288);
|
|
3817
|
-
const d = new Uint8Array(30).fill(5);
|
|
3818
|
-
fixedDist = buildHuffman(d, 30);
|
|
3819
|
-
}
|
|
3820
|
-
return [fixedLit, fixedDist];
|
|
3821
|
-
}
|
|
3822
|
-
var BitReader = (_class2 = class {
|
|
3823
|
-
constructor(data) {;_class2.prototype.__init22.call(this);_class2.prototype.__init23.call(this);_class2.prototype.__init24.call(this);
|
|
3824
|
-
this.data = data;
|
|
3825
|
-
}
|
|
3826
|
-
|
|
3827
|
-
__init22() {this.pos = 0}
|
|
3828
|
-
__init23() {this.bit = 0}
|
|
3829
|
-
__init24() {this.bits = 0}
|
|
3830
|
-
need(n) {
|
|
3831
|
-
while (this.bits < n) {
|
|
3832
|
-
if (this.pos >= this.data.length) throw new ZlibError("Unexpected end of compressed data");
|
|
3833
|
-
this.bit |= this.data[this.pos++] << this.bits;
|
|
3834
|
-
this.bits += 8;
|
|
3835
|
-
}
|
|
3836
|
-
const v = this.bit & (1 << n) - 1;
|
|
3837
|
-
this.bit >>>= n;
|
|
3838
|
-
this.bits -= n;
|
|
3839
|
-
return v;
|
|
3840
|
-
}
|
|
3841
|
-
decode(h) {
|
|
3842
|
-
let code = 0;
|
|
3843
|
-
let first = 0;
|
|
3844
|
-
let index = 0;
|
|
3845
|
-
for (let len = 1; len < 16; len++) {
|
|
3846
|
-
code |= this.need(1);
|
|
3847
|
-
const count = h.counts[len];
|
|
3848
|
-
if (code - count < first) return h.symbols[index + (code - first)];
|
|
3849
|
-
index += count;
|
|
3850
|
-
first += count;
|
|
3851
|
-
first <<= 1;
|
|
3852
|
-
code <<= 1;
|
|
3853
|
-
}
|
|
3854
|
-
throw new ZlibError("Invalid Huffman code");
|
|
3855
|
-
}
|
|
3856
|
-
align() {
|
|
3857
|
-
this.bit = 0;
|
|
3858
|
-
this.bits = 0;
|
|
3859
|
-
}
|
|
3860
|
-
}, _class2);
|
|
3861
|
-
var Output = (_class3 = class {
|
|
3862
|
-
constructor(hint, max) {;_class3.prototype.__init25.call(this);
|
|
3863
|
-
this.max = max;
|
|
3864
|
-
this.buf = new Uint8Array(Math.max(1024, Math.min(hint, max)));
|
|
3865
|
-
}
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
__init25() {this.len = 0}
|
|
3869
|
-
ensure(n) {
|
|
3870
|
-
if (this.len + n > this.max) throw new ZlibError(`Decompressed data exceeds ${this.max} bytes`);
|
|
3871
|
-
if (this.len + n <= this.buf.length) return;
|
|
3872
|
-
let size = this.buf.length * 2;
|
|
3873
|
-
while (size < this.len + n) size *= 2;
|
|
3874
|
-
const next = new Uint8Array(Math.min(size, Math.max(this.max, this.len + n)));
|
|
3875
|
-
next.set(this.buf.subarray(0, this.len));
|
|
3876
|
-
this.buf = next;
|
|
3877
|
-
}
|
|
3878
|
-
}, _class3);
|
|
3879
|
-
function inflateRaw(data, options = {}) {
|
|
3880
|
-
const max = _nullishCoalesce(options.maxOutput, () => ( 512 * 1024 * 1024));
|
|
3881
|
-
const out = new Output(_nullishCoalesce(options.sizeHint, () => ( data.length * 4)), max);
|
|
3882
|
-
const br = new BitReader(data);
|
|
3883
|
-
let final = 0;
|
|
3884
|
-
while (!final) {
|
|
3885
|
-
final = br.need(1);
|
|
3886
|
-
const type = br.need(2);
|
|
3887
|
-
if (type === 0) {
|
|
3888
|
-
br.align();
|
|
3889
|
-
if (br.pos + 4 > data.length) throw new ZlibError("Unexpected end of compressed data");
|
|
3890
|
-
const len = data[br.pos] | data[br.pos + 1] << 8;
|
|
3891
|
-
const nlen = data[br.pos + 2] | data[br.pos + 3] << 8;
|
|
3892
|
-
br.pos += 4;
|
|
3893
|
-
if ((len ^ 65535) !== nlen) throw new ZlibError("Stored block length mismatch");
|
|
3894
|
-
if (br.pos + len > data.length) throw new ZlibError("Unexpected end of compressed data");
|
|
3895
|
-
out.ensure(len);
|
|
3896
|
-
out.buf.set(data.subarray(br.pos, br.pos + len), out.len);
|
|
3897
|
-
out.len += len;
|
|
3898
|
-
br.pos += len;
|
|
3899
|
-
continue;
|
|
3900
|
-
}
|
|
3901
|
-
let lit;
|
|
3902
|
-
let dist;
|
|
3903
|
-
if (type === 1) [lit, dist] = fixedTables();
|
|
3904
|
-
else if (type === 2) {
|
|
3905
|
-
const hlit = br.need(5) + 257;
|
|
3906
|
-
const hdist = br.need(5) + 1;
|
|
3907
|
-
const hclen = br.need(4) + 4;
|
|
3908
|
-
const cl = new Uint8Array(19);
|
|
3909
|
-
for (let i2 = 0; i2 < hclen; i2++) cl[CL_ORDER[i2]] = br.need(3);
|
|
3910
|
-
const clh = buildHuffman(cl, 19);
|
|
3911
|
-
const lengths = new Uint8Array(hlit + hdist);
|
|
3912
|
-
let i = 0;
|
|
3913
|
-
while (i < hlit + hdist) {
|
|
3914
|
-
const sym = br.decode(clh);
|
|
3915
|
-
if (sym < 16) lengths[i++] = sym;
|
|
3916
|
-
else {
|
|
3917
|
-
let rep = 0;
|
|
3918
|
-
let val = 0;
|
|
3919
|
-
if (sym === 16) {
|
|
3920
|
-
if (i === 0) throw new ZlibError("Repeat with no previous length");
|
|
3921
|
-
val = lengths[i - 1];
|
|
3922
|
-
rep = 3 + br.need(2);
|
|
3923
|
-
} else if (sym === 17) rep = 3 + br.need(3);
|
|
3924
|
-
else rep = 11 + br.need(7);
|
|
3925
|
-
if (i + rep > hlit + hdist) throw new ZlibError("Too many code lengths");
|
|
3926
|
-
while (rep--) lengths[i++] = val;
|
|
3927
|
-
}
|
|
3928
|
-
}
|
|
3929
|
-
lit = buildHuffman(lengths.subarray(0, hlit), hlit);
|
|
3930
|
-
dist = buildHuffman(lengths.subarray(hlit), hdist);
|
|
3931
|
-
} else throw new ZlibError("Invalid block type");
|
|
3932
|
-
for (; ; ) {
|
|
3933
|
-
const sym = br.decode(lit);
|
|
3934
|
-
if (sym < 256) {
|
|
3935
|
-
out.ensure(1);
|
|
3936
|
-
out.buf[out.len++] = sym;
|
|
3937
|
-
} else if (sym === 256) break;
|
|
3938
|
-
else {
|
|
3939
|
-
const li = sym - 257;
|
|
3940
|
-
if (li >= 29) throw new ZlibError("Invalid length symbol");
|
|
3941
|
-
const len = LENGTH_BASE[li] + br.need(LENGTH_EXTRA[li]);
|
|
3942
|
-
const di = br.decode(dist);
|
|
3943
|
-
if (di >= 30) throw new ZlibError("Invalid distance symbol");
|
|
3944
|
-
const d = DIST_BASE[di] + br.need(DIST_EXTRA[di]);
|
|
3945
|
-
if (d > out.len) throw new ZlibError("Distance too far back");
|
|
3946
|
-
out.ensure(len);
|
|
3947
|
-
const buf = out.buf;
|
|
3948
|
-
let p = out.len;
|
|
3949
|
-
for (let k = 0; k < len; k++, p++) buf[p] = buf[p - d];
|
|
3950
|
-
out.len = p;
|
|
3951
|
-
}
|
|
3952
|
-
}
|
|
3953
|
-
}
|
|
3954
|
-
return out.buf.slice(0, out.len);
|
|
3955
|
-
}
|
|
3956
|
-
function adler32(data) {
|
|
3957
|
-
let a = 1;
|
|
3958
|
-
let b = 0;
|
|
3959
|
-
const n = data.length;
|
|
3960
|
-
let i = 0;
|
|
3961
|
-
while (i < n) {
|
|
3962
|
-
const end = Math.min(n, i + 3800);
|
|
3963
|
-
for (; i < end; i++) {
|
|
3964
|
-
a += data[i];
|
|
3965
|
-
b += a;
|
|
3966
|
-
}
|
|
3967
|
-
a %= 65521;
|
|
3968
|
-
b %= 65521;
|
|
3969
|
-
}
|
|
3970
|
-
return (b << 16 | a) >>> 0;
|
|
3971
|
-
}
|
|
3972
|
-
function inflate(data, options = {}) {
|
|
3973
|
-
if (data.length < 6) throw new ZlibError("Truncated zlib stream");
|
|
3974
|
-
const cmf = data[0];
|
|
3975
|
-
const flg = data[1];
|
|
3976
|
-
if ((cmf & 15) !== 8 || (cmf << 8 | flg) % 31 !== 0) throw new ZlibError("Not a zlib stream");
|
|
3977
|
-
if (flg & 32) throw new ZlibError("Preset dictionaries are not supported");
|
|
3978
|
-
const out = inflateRaw(data.subarray(2), options);
|
|
3979
|
-
if (options.verify !== false && data.length >= 6) {
|
|
3980
|
-
const t = data.length - 4;
|
|
3981
|
-
const want = (data[t] << 24 | data[t + 1] << 16 | data[t + 2] << 8 | data[t + 3]) >>> 0;
|
|
3982
|
-
if (adler32(out) !== want) throw new ZlibError("Adler-32 mismatch");
|
|
3983
|
-
}
|
|
3984
|
-
return out;
|
|
3985
|
-
}
|
|
3986
|
-
var BitWriter = (_class4 = class {
|
|
3987
|
-
|
|
3988
|
-
__init26() {this.len = 0}
|
|
3989
|
-
__init27() {this.bit = 0}
|
|
3990
|
-
__init28() {this.bits = 0}
|
|
3991
|
-
constructor(hint) {;_class4.prototype.__init26.call(this);_class4.prototype.__init27.call(this);_class4.prototype.__init28.call(this);
|
|
3992
|
-
this.buf = new Uint8Array(Math.max(1024, hint));
|
|
3993
|
-
}
|
|
3994
|
-
grow() {
|
|
3995
|
-
const next = new Uint8Array(this.buf.length * 2);
|
|
3996
|
-
next.set(this.buf);
|
|
3997
|
-
this.buf = next;
|
|
3998
|
-
}
|
|
3999
|
-
write(value, n) {
|
|
4000
|
-
this.bit |= value << this.bits;
|
|
4001
|
-
this.bits += n;
|
|
4002
|
-
while (this.bits >= 8) {
|
|
4003
|
-
if (this.len >= this.buf.length) this.grow();
|
|
4004
|
-
this.buf[this.len++] = this.bit & 255;
|
|
4005
|
-
this.bit >>>= 8;
|
|
4006
|
-
this.bits -= 8;
|
|
4007
|
-
}
|
|
4008
|
-
}
|
|
4009
|
-
flush() {
|
|
4010
|
-
if (this.bits > 0) {
|
|
4011
|
-
if (this.len >= this.buf.length) this.grow();
|
|
4012
|
-
this.buf[this.len++] = this.bit & 255;
|
|
4013
|
-
}
|
|
4014
|
-
this.bit = 0;
|
|
4015
|
-
this.bits = 0;
|
|
4016
|
-
}
|
|
4017
|
-
bytes() {
|
|
4018
|
-
return this.buf.slice(0, this.len);
|
|
4019
|
-
}
|
|
4020
|
-
}, _class4);
|
|
4021
|
-
function codeLengths(freqs, maxBits) {
|
|
4022
|
-
const n = freqs.length;
|
|
4023
|
-
const lengths = new Uint8Array(n);
|
|
4024
|
-
const f = Float64Array.from(freqs);
|
|
4025
|
-
for (; ; ) {
|
|
4026
|
-
const nodes = [];
|
|
4027
|
-
for (let i = 0; i < n; i++) if (f[i] > 0) nodes.push({ w: f[i], sym: i });
|
|
4028
|
-
lengths.fill(0);
|
|
4029
|
-
if (nodes.length === 0) return lengths;
|
|
4030
|
-
if (nodes.length === 1) {
|
|
4031
|
-
lengths[nodes[0].sym] = 1;
|
|
4032
|
-
return lengths;
|
|
4033
|
-
}
|
|
4034
|
-
const heap = nodes.map((_, i) => i);
|
|
4035
|
-
const less = (a, b) => nodes[a].w < nodes[b].w || nodes[a].w === nodes[b].w && a < b;
|
|
4036
|
-
const down = (i) => {
|
|
4037
|
-
for (; ; ) {
|
|
4038
|
-
const l = 2 * i + 1;
|
|
4039
|
-
const r = l + 1;
|
|
4040
|
-
let m = i;
|
|
4041
|
-
if (l < heap.length && less(heap[l], heap[m])) m = l;
|
|
4042
|
-
if (r < heap.length && less(heap[r], heap[m])) m = r;
|
|
4043
|
-
if (m === i) return;
|
|
4044
|
-
[heap[i], heap[m]] = [heap[m], heap[i]];
|
|
4045
|
-
i = m;
|
|
4046
|
-
}
|
|
4047
|
-
};
|
|
4048
|
-
const up = (i) => {
|
|
4049
|
-
while (i > 0) {
|
|
4050
|
-
const p = i - 1 >> 1;
|
|
4051
|
-
if (!less(heap[i], heap[p])) return;
|
|
4052
|
-
[heap[i], heap[p]] = [heap[p], heap[i]];
|
|
4053
|
-
i = p;
|
|
4054
|
-
}
|
|
4055
|
-
};
|
|
4056
|
-
for (let i = (heap.length >> 1) - 1; i >= 0; i--) down(i);
|
|
4057
|
-
const pop = () => {
|
|
4058
|
-
const top = heap[0];
|
|
4059
|
-
const last = heap.pop();
|
|
4060
|
-
if (heap.length) {
|
|
4061
|
-
heap[0] = last;
|
|
4062
|
-
down(0);
|
|
4063
|
-
}
|
|
4064
|
-
return top;
|
|
4065
|
-
};
|
|
4066
|
-
while (heap.length > 1) {
|
|
4067
|
-
const a = pop();
|
|
4068
|
-
const b = pop();
|
|
4069
|
-
nodes.push({ w: nodes[a].w + nodes[b].w, sym: -1, left: a, right: b });
|
|
4070
|
-
heap.push(nodes.length - 1);
|
|
4071
|
-
up(heap.length - 1);
|
|
4072
|
-
}
|
|
4073
|
-
let maxLen = 0;
|
|
4074
|
-
const stack = [[heap[0], 0]];
|
|
4075
|
-
while (stack.length) {
|
|
4076
|
-
const [i, d] = stack.pop();
|
|
4077
|
-
const node = nodes[i];
|
|
4078
|
-
if (node.sym >= 0) {
|
|
4079
|
-
lengths[node.sym] = d;
|
|
4080
|
-
if (d > maxLen) maxLen = d;
|
|
4081
|
-
} else {
|
|
4082
|
-
stack.push([node.left, d + 1], [node.right, d + 1]);
|
|
4083
|
-
}
|
|
4084
|
-
}
|
|
4085
|
-
if (maxLen <= maxBits) return lengths;
|
|
4086
|
-
for (let i = 0; i < n; i++) if (f[i] > 0) f[i] = Math.floor(f[i] / 2) + 1;
|
|
4087
|
-
}
|
|
4088
|
-
}
|
|
4089
|
-
function canonicalCodes(lengths) {
|
|
4090
|
-
const blCount = new Uint16Array(16);
|
|
4091
|
-
for (const l of lengths) blCount[l]++;
|
|
4092
|
-
blCount[0] = 0;
|
|
4093
|
-
const next = new Uint16Array(16);
|
|
4094
|
-
let code = 0;
|
|
4095
|
-
for (let bits = 1; bits < 16; bits++) {
|
|
4096
|
-
code = code + blCount[bits - 1] << 1;
|
|
4097
|
-
next[bits] = code;
|
|
4098
|
-
}
|
|
4099
|
-
const codes = new Uint16Array(lengths.length);
|
|
4100
|
-
for (let i = 0; i < lengths.length; i++) {
|
|
4101
|
-
const len = lengths[i];
|
|
4102
|
-
if (!len) continue;
|
|
4103
|
-
let c = next[len]++;
|
|
4104
|
-
let r = 0;
|
|
4105
|
-
for (let k = 0; k < len; k++) {
|
|
4106
|
-
r = r << 1 | c & 1;
|
|
4107
|
-
c >>= 1;
|
|
4108
|
-
}
|
|
4109
|
-
codes[i] = r;
|
|
4110
|
-
}
|
|
4111
|
-
return codes;
|
|
4112
|
-
}
|
|
4113
|
-
function lengthSymbol(len) {
|
|
4114
|
-
let i = 28;
|
|
4115
|
-
while (LENGTH_BASE[i] > len) i--;
|
|
4116
|
-
return i;
|
|
4117
|
-
}
|
|
4118
|
-
function distSymbol(d) {
|
|
4119
|
-
let i = 29;
|
|
4120
|
-
while (DIST_BASE[i] > d) i--;
|
|
4121
|
-
return i;
|
|
4122
|
-
}
|
|
4123
|
-
var WINDOW = 32768;
|
|
4124
|
-
var HASH_BITS = 15;
|
|
4125
|
-
var HASH_SIZE = 1 << HASH_BITS;
|
|
4126
|
-
var MAX_CHAIN = 24;
|
|
4127
|
-
var MAX_MATCH = 258;
|
|
4128
|
-
var BLOCK_SYMBOLS = 65536;
|
|
4129
|
-
function deflateRaw(data, level = 1) {
|
|
4130
|
-
const w = new BitWriter(Math.ceil(data.length / 2) + 64);
|
|
4131
|
-
const n = data.length;
|
|
4132
|
-
if (level === 0 || n === 0) {
|
|
4133
|
-
let pos = 0;
|
|
4134
|
-
do {
|
|
4135
|
-
const len = Math.min(65535, n - pos);
|
|
4136
|
-
const final = pos + len >= n ? 1 : 0;
|
|
4137
|
-
w.write(final, 1);
|
|
4138
|
-
w.write(0, 2);
|
|
4139
|
-
w.flush();
|
|
4140
|
-
w.write(len & 65535, 16);
|
|
4141
|
-
w.write(~len & 65535, 16);
|
|
4142
|
-
for (let i2 = 0; i2 < len; i2++) w.write(data[pos + i2], 8);
|
|
4143
|
-
pos += len;
|
|
4144
|
-
} while (pos < n);
|
|
4145
|
-
return w.bytes();
|
|
4146
|
-
}
|
|
4147
|
-
const head = new Int32Array(HASH_SIZE).fill(-1);
|
|
4148
|
-
const prev = new Int32Array(WINDOW);
|
|
4149
|
-
const litLen = new Uint16Array(BLOCK_SYMBOLS);
|
|
4150
|
-
const dists = new Uint16Array(BLOCK_SYMBOLS);
|
|
4151
|
-
let count = 0;
|
|
4152
|
-
const hash = (i2) => (data[i2] << 10 ^ data[i2 + 1] << 5 ^ data[i2 + 2]) * 2654435761 >>> 32 - HASH_BITS;
|
|
4153
|
-
const insert = (i2) => {
|
|
4154
|
-
if (i2 + 2 >= n) return;
|
|
4155
|
-
const h = hash(i2);
|
|
4156
|
-
prev[i2 & WINDOW - 1] = head[h];
|
|
4157
|
-
head[h] = i2;
|
|
4158
|
-
};
|
|
4159
|
-
const flushBlock = (final) => {
|
|
4160
|
-
const litFreq = new Uint32Array(286);
|
|
4161
|
-
const distFreq = new Uint32Array(30);
|
|
4162
|
-
for (let k = 0; k < count; k++) {
|
|
4163
|
-
if (dists[k] === 0) litFreq[litLen[k]]++;
|
|
4164
|
-
else {
|
|
4165
|
-
litFreq[257 + lengthSymbol(litLen[k])]++;
|
|
4166
|
-
distFreq[distSymbol(dists[k])]++;
|
|
4167
|
-
}
|
|
4168
|
-
}
|
|
4169
|
-
litFreq[256] = 1;
|
|
4170
|
-
let anyDist = false;
|
|
4171
|
-
for (const v of distFreq) if (v) anyDist = true;
|
|
4172
|
-
if (!anyDist) distFreq[0] = 1;
|
|
4173
|
-
const litLengths = codeLengths(litFreq, 15);
|
|
4174
|
-
const distLengths = codeLengths(distFreq, 15);
|
|
4175
|
-
let hlit = 286;
|
|
4176
|
-
while (hlit > 257 && !litLengths[hlit - 1]) hlit--;
|
|
4177
|
-
let hdist = 30;
|
|
4178
|
-
while (hdist > 1 && !distLengths[hdist - 1]) hdist--;
|
|
4179
|
-
const all = new Uint8Array(hlit + hdist);
|
|
4180
|
-
all.set(litLengths.subarray(0, hlit));
|
|
4181
|
-
all.set(distLengths.subarray(0, hdist), hlit);
|
|
4182
|
-
const clSyms = [];
|
|
4183
|
-
const clExtra = [];
|
|
4184
|
-
for (let i2 = 0; i2 < all.length; ) {
|
|
4185
|
-
const v = all[i2];
|
|
4186
|
-
let run = 1;
|
|
4187
|
-
while (i2 + run < all.length && all[i2 + run] === v) run++;
|
|
4188
|
-
if (v === 0 && run >= 3) {
|
|
4189
|
-
const r = Math.min(run, 138);
|
|
4190
|
-
if (r >= 11) {
|
|
4191
|
-
clSyms.push(18);
|
|
4192
|
-
clExtra.push(r - 11);
|
|
4193
|
-
} else {
|
|
4194
|
-
clSyms.push(17);
|
|
4195
|
-
clExtra.push(r - 3);
|
|
4196
|
-
}
|
|
4197
|
-
i2 += r;
|
|
4198
|
-
} else if (v !== 0 && run >= 4) {
|
|
4199
|
-
clSyms.push(v);
|
|
4200
|
-
clExtra.push(0);
|
|
4201
|
-
const r = Math.min(run - 1, 6);
|
|
4202
|
-
clSyms.push(16);
|
|
4203
|
-
clExtra.push(r - 3);
|
|
4204
|
-
i2 += r + 1;
|
|
4205
|
-
} else {
|
|
4206
|
-
clSyms.push(v);
|
|
4207
|
-
clExtra.push(0);
|
|
4208
|
-
i2++;
|
|
4209
|
-
}
|
|
4210
|
-
}
|
|
4211
|
-
const clFreq = new Uint32Array(19);
|
|
4212
|
-
for (const s of clSyms) clFreq[s]++;
|
|
4213
|
-
const clLengths = codeLengths(clFreq, 7);
|
|
4214
|
-
let hclen = 19;
|
|
4215
|
-
while (hclen > 4 && !clLengths[CL_ORDER[hclen - 1]]) hclen--;
|
|
4216
|
-
const clCodes = canonicalCodes(clLengths);
|
|
4217
|
-
const litCodes = canonicalCodes(litLengths);
|
|
4218
|
-
const distCodes = canonicalCodes(distLengths);
|
|
4219
|
-
w.write(final ? 1 : 0, 1);
|
|
4220
|
-
w.write(2, 2);
|
|
4221
|
-
w.write(hlit - 257, 5);
|
|
4222
|
-
w.write(hdist - 1, 5);
|
|
4223
|
-
w.write(hclen - 4, 4);
|
|
4224
|
-
for (let i2 = 0; i2 < hclen; i2++) w.write(clLengths[CL_ORDER[i2]], 3);
|
|
4225
|
-
for (let i2 = 0; i2 < clSyms.length; i2++) {
|
|
4226
|
-
const s = clSyms[i2];
|
|
4227
|
-
w.write(clCodes[s], clLengths[s]);
|
|
4228
|
-
if (s === 16) w.write(clExtra[i2], 2);
|
|
4229
|
-
else if (s === 17) w.write(clExtra[i2], 3);
|
|
4230
|
-
else if (s === 18) w.write(clExtra[i2], 7);
|
|
4231
|
-
}
|
|
4232
|
-
for (let k = 0; k < count; k++) {
|
|
4233
|
-
const d = dists[k];
|
|
4234
|
-
if (d === 0) {
|
|
4235
|
-
const s = litLen[k];
|
|
4236
|
-
w.write(litCodes[s], litLengths[s]);
|
|
4237
|
-
} else {
|
|
4238
|
-
const len = litLen[k];
|
|
4239
|
-
const li = lengthSymbol(len);
|
|
4240
|
-
w.write(litCodes[257 + li], litLengths[257 + li]);
|
|
4241
|
-
if (LENGTH_EXTRA[li]) w.write(len - LENGTH_BASE[li], LENGTH_EXTRA[li]);
|
|
4242
|
-
const di = distSymbol(d);
|
|
4243
|
-
w.write(distCodes[di], distLengths[di]);
|
|
4244
|
-
if (DIST_EXTRA[di]) w.write(d - DIST_BASE[di], DIST_EXTRA[di]);
|
|
4245
|
-
}
|
|
4246
|
-
}
|
|
4247
|
-
w.write(litCodes[256], litLengths[256]);
|
|
4248
|
-
count = 0;
|
|
4249
|
-
};
|
|
4250
|
-
let i = 0;
|
|
4251
|
-
while (i < n) {
|
|
4252
|
-
let bestLen = 0;
|
|
4253
|
-
let bestDist = 0;
|
|
4254
|
-
if (i + 2 < n) {
|
|
4255
|
-
let cand = head[hash(i)];
|
|
4256
|
-
let chain = MAX_CHAIN;
|
|
4257
|
-
const limit = Math.min(MAX_MATCH, n - i);
|
|
4258
|
-
while (cand >= 0 && i - cand <= WINDOW - 1 && chain-- > 0) {
|
|
4259
|
-
if (data[cand + bestLen] === data[i + bestLen]) {
|
|
4260
|
-
let l = 0;
|
|
4261
|
-
while (l < limit && data[cand + l] === data[i + l]) l++;
|
|
4262
|
-
if (l > bestLen) {
|
|
4263
|
-
bestLen = l;
|
|
4264
|
-
bestDist = i - cand;
|
|
4265
|
-
if (l === limit) break;
|
|
4266
|
-
}
|
|
4267
|
-
}
|
|
4268
|
-
const next = prev[cand & WINDOW - 1];
|
|
4269
|
-
if (next >= cand) break;
|
|
4270
|
-
cand = next;
|
|
4271
|
-
}
|
|
4272
|
-
}
|
|
4273
|
-
if (bestLen >= 3) {
|
|
4274
|
-
litLen[count] = bestLen;
|
|
4275
|
-
dists[count] = bestDist;
|
|
4276
|
-
count++;
|
|
4277
|
-
const end = i + bestLen;
|
|
4278
|
-
const insertEnd = bestLen > 64 ? i + 64 : end;
|
|
4279
|
-
for (let k = i; k < insertEnd; k++) insert(k);
|
|
4280
|
-
for (let k = Math.max(insertEnd, end - 3); k < end; k++) insert(k);
|
|
4281
|
-
i = end;
|
|
4282
|
-
} else {
|
|
4283
|
-
litLen[count] = data[i];
|
|
4284
|
-
dists[count] = 0;
|
|
4285
|
-
count++;
|
|
4286
|
-
insert(i);
|
|
4287
|
-
i++;
|
|
4288
|
-
}
|
|
4289
|
-
if (count >= BLOCK_SYMBOLS - 1 && i < n) flushBlock(false);
|
|
4290
|
-
}
|
|
4291
|
-
flushBlock(true);
|
|
4292
|
-
w.flush();
|
|
4293
|
-
return w.bytes();
|
|
4294
|
-
}
|
|
4295
|
-
function deflate(data, level = 1) {
|
|
4296
|
-
const raw = deflateRaw(data, level);
|
|
4297
|
-
const out = new Uint8Array(raw.length + 6);
|
|
4298
|
-
out[0] = 120;
|
|
4299
|
-
out[1] = 1;
|
|
4300
|
-
out.set(raw, 2);
|
|
4301
|
-
const a = adler32(data);
|
|
4302
|
-
const t = out.length - 4;
|
|
4303
|
-
out[t] = a >>> 24;
|
|
4304
|
-
out[t + 1] = a >>> 16 & 255;
|
|
4305
|
-
out[t + 2] = a >>> 8 & 255;
|
|
4306
|
-
out[t + 3] = a & 255;
|
|
4307
|
-
return out;
|
|
4287
|
+
return new (0, _chunkTFOPHZ3Ucjs.TiledSurface)(ch, tiles, base.defaultValue);
|
|
4308
4288
|
}
|
|
4309
4289
|
|
|
4310
4290
|
// src/raster/png.ts
|
|
@@ -4379,7 +4359,7 @@ function encodePng(width, height, data, channels = 4) {
|
|
|
4379
4359
|
raw[o] = best;
|
|
4380
4360
|
raw.set(cand[best], o + 1);
|
|
4381
4361
|
}
|
|
4382
|
-
const idat = deflate(raw);
|
|
4362
|
+
const idat = _chunk643B2HKCcjs.deflate.call(void 0, raw);
|
|
4383
4363
|
const chunks = [];
|
|
4384
4364
|
const ihdr = new Uint8Array(13);
|
|
4385
4365
|
writeU32(ihdr, 0, width);
|
|
@@ -4457,7 +4437,7 @@ function decodePng(bytes, options = {}) {
|
|
|
4457
4437
|
}
|
|
4458
4438
|
const bitsPerPixel = samples * depth;
|
|
4459
4439
|
const stride = Math.ceil(width * bitsPerPixel / 8);
|
|
4460
|
-
const raw = inflate(z, { maxOutput: (stride + 1) * height, sizeHint: (stride + 1) * height });
|
|
4440
|
+
const raw = _chunk643B2HKCcjs.inflate.call(void 0, z, { maxOutput: (stride + 1) * height, sizeHint: (stride + 1) * height });
|
|
4461
4441
|
if (raw.length < (stride + 1) * height) throw new Error("PNG image data is truncated.");
|
|
4462
4442
|
const bpp = Math.max(1, bitsPerPixel >> 3);
|
|
4463
4443
|
const lines = new Uint8Array(stride * height);
|
|
@@ -4689,5 +4669,23 @@ function pngDataUrl(width, height, data, channels = 4) {
|
|
|
4689
4669
|
|
|
4690
4670
|
|
|
4691
4671
|
|
|
4692
|
-
|
|
4693
|
-
|
|
4672
|
+
|
|
4673
|
+
|
|
4674
|
+
|
|
4675
|
+
|
|
4676
|
+
|
|
4677
|
+
|
|
4678
|
+
|
|
4679
|
+
|
|
4680
|
+
|
|
4681
|
+
|
|
4682
|
+
|
|
4683
|
+
|
|
4684
|
+
|
|
4685
|
+
|
|
4686
|
+
|
|
4687
|
+
|
|
4688
|
+
|
|
4689
|
+
|
|
4690
|
+
exports.BIT_DEPTHS = BIT_DEPTHS; exports.isBitDepth = isBitDepth; exports.srgbDecode = srgbDecode; exports.srgbEncode = srgbEncode; exports.to16From8 = to16From8; exports.to32From8 = to32From8; exports.to32From16 = to32From16; exports.to16From32 = to16From32; exports.to8From16 = to8From16; exports.to8From32 = to8From32; exports.proxyOf = proxyOf; exports.depthOf = depthOf; exports.deepTile = deepTile; exports.tileSamples16 = tileSamples16; exports.tileSamples32 = tileSamples32; exports.tileSamples = tileSamples; exports.surfaceDepth = surfaceDepth; exports.readDeepRegion = readDeepRegion; exports.writeDeepRegion = writeDeepRegion; exports.surfaceFromDeepPixels = surfaceFromDeepPixels; exports.convertSurfaceDepth = convertSurfaceDepth; exports.deepBytes = deepBytes; exports.DEFAULT_GLOBAL_LIGHT = DEFAULT_GLOBAL_LIGHT; exports.LAYER_EFFECT_KINDS = LAYER_EFFECT_KINDS; exports.layerEffectLabel = layerEffectLabel; exports.isLayerEffectKind = isLayerEffectKind; exports.defaultEffectGradient = defaultEffectGradient; exports.newEffectId = newEffectId; exports.defaultLayerEffect = defaultLayerEffect; exports.hasActiveEffects = hasActiveEffects; exports.MAX_EFFECT_REACH = MAX_EFFECT_REACH; exports.effectReach = effectReach; exports.effectsMargin = effectsMargin; exports.effectsScale = effectsScale; exports.scaleLayerEffect = scaleLayerEffect; exports.parseEffectColor = parseEffectColor; exports.effectColorHex = effectColorHex; exports.LayerEffectError = LayerEffectError; exports.validateEffectGradient = validateEffectGradient; exports.layerEffectFields = layerEffectFields; exports.validateLayerEffect = validateLayerEffect; exports.mergeLayerEffect = mergeLayerEffect; exports.validateLayerEffects = validateLayerEffects; exports.normalizeLayerEffects = normalizeLayerEffects; exports.effectsFingerprint = effectsFingerprint; exports.DeepCompositor = DeepCompositor; exports.workingToSamples = workingToSamples; exports.DIRECT_GAUSSIAN_MAX_SIGMA = DIRECT_GAUSSIAN_MAX_SIGMA; exports.gaussianBlur = gaussianBlur; exports.flattenLayers = flattenLayers; exports.findLayer = findLayer; exports.mapLayer = mapLayer; exports.insertLayer = insertLayer; exports.isLayerLocked = isLayerLocked; exports.PatternTile = PatternTile; exports.PatternPlacement = PatternPlacement; exports.builtinPatternIds = builtinPatternIds; exports.builtinPattern = builtinPattern; exports.hashNoise = hashNoise; exports.CURVE_LUT_SIZE = CURVE_LUT_SIZE; exports.curveLut = curveLut; exports.STROKE_CHAMFER_MAX = STROKE_CHAMFER_MAX; exports.contourLut = contourLut; exports.activeEffectItems = activeEffectItems; exports.effectsAreLocal = effectsAreLocal; exports.buildEffectMaps = buildEffectMaps; exports.patchEffectMaps = patchEffectMaps; exports.gradientT = gradientT; exports.effectFillColors = effectFillColors; exports.compositeLayerEffects = compositeLayerEffects; exports.renderLayerEffects = renderLayerEffects; exports.blendTile = blendTile; exports.RasterCompositor = RasterCompositor; exports.changedTiles = changedTiles; exports.INTERPOLATIONS = INTERPOLATIONS; exports.isInterpolation = isInterpolation; exports.MAX_TRANSFORM_PIXELS = MAX_TRANSFORM_PIXELS; exports.TransformTooLargeError = TransformTooLargeError; exports.keysWeight = keysWeight; exports.reduceSurface = reduceSurface; exports.transformedBounds = transformedBounds; exports.transformSurface = transformSurface; exports.warpSurface = warpSurface; exports.compositeSurfaceOver = compositeSurfaceOver; exports.encodePng = encodePng; exports.isPng = isPng; exports.decodePng = decodePng; exports.bytesToBase64 = bytesToBase64; exports.base64ToBytes = base64ToBytes; exports.parseDataUrl = parseDataUrl; exports.pngDataUrl = pngDataUrl;
|
|
4691
|
+
//# sourceMappingURL=chunk-ST7E3NEE.cjs.map
|