@pixerate/editor 0.115.0 → 0.117.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 +3 -0
- package/dist/animation-editor/index.cjs +54 -54
- package/dist/animation-editor/index.d.cts +2 -2
- package/dist/animation-editor/index.d.ts +2 -2
- package/dist/animation-editor/index.js +2 -2
- package/dist/{chunk-I7FQBWMQ.cjs → chunk-2J3LS7JZ.cjs} +333 -333
- package/dist/{chunk-I7FQBWMQ.cjs.map → chunk-2J3LS7JZ.cjs.map} +1 -1
- package/dist/{chunk-TFOPHZ3U.cjs → chunk-7ISPWEJA.cjs} +302 -5
- package/dist/chunk-7ISPWEJA.cjs.map +1 -0
- package/dist/{chunk-VXR7XWMF.js → chunk-7LNZAWSJ.js} +437 -41
- package/dist/chunk-7LNZAWSJ.js.map +1 -0
- package/dist/{chunk-DFQEX3AM.cjs → chunk-BYAWOAST.cjs} +223 -30
- package/dist/chunk-BYAWOAST.cjs.map +1 -0
- package/dist/chunk-COAMRKVI.cjs +159 -0
- package/dist/chunk-COAMRKVI.cjs.map +1 -0
- package/dist/{chunk-ST7E3NEE.cjs → chunk-EBSYZRSW.cjs} +230 -732
- package/dist/chunk-EBSYZRSW.cjs.map +1 -0
- package/dist/chunk-EJVDBITD.cjs +501 -0
- package/dist/chunk-EJVDBITD.cjs.map +1 -0
- package/dist/{chunk-LPLCWZTM.cjs → chunk-FODKPD44.cjs} +555 -159
- package/dist/chunk-FODKPD44.cjs.map +1 -0
- package/dist/{chunk-XK5LZKBD.js → chunk-HKDTM6VC.js} +298 -1
- package/dist/chunk-HKDTM6VC.js.map +1 -0
- package/dist/chunk-IPFRWILU.js +1908 -0
- package/dist/chunk-IPFRWILU.js.map +1 -0
- package/dist/chunk-IVSNUXW7.js +3339 -0
- package/dist/chunk-IVSNUXW7.js.map +1 -0
- package/dist/{chunk-LKCYANMW.js → chunk-JHXMNOMF.js} +198 -5
- package/dist/chunk-JHXMNOMF.js.map +1 -0
- package/dist/{chunk-FV5AXTSF.cjs → chunk-JSSBHMMU.cjs} +36 -188
- package/dist/chunk-JSSBHMMU.cjs.map +1 -0
- package/dist/chunk-L2T6EJ5S.cjs +3339 -0
- package/dist/chunk-L2T6EJ5S.cjs.map +1 -0
- package/dist/chunk-LF4WOZXZ.js +159 -0
- package/dist/chunk-LF4WOZXZ.js.map +1 -0
- package/dist/{chunk-26PGXHY7.cjs → chunk-M7O4BJRH.cjs} +36 -36
- package/dist/{chunk-26PGXHY7.cjs.map → chunk-M7O4BJRH.cjs.map} +1 -1
- package/dist/chunk-N3467VD6.js +501 -0
- package/dist/chunk-N3467VD6.js.map +1 -0
- package/dist/{chunk-XICA4PVO.js → chunk-R2JE6SA7.js} +17 -17
- package/dist/chunk-SMJGE7HM.cjs +1908 -0
- package/dist/chunk-SMJGE7HM.cjs.map +1 -0
- package/dist/{chunk-MMVHBKMM.js → chunk-T2P5TIZ6.js} +2 -2
- package/dist/{chunk-C6C5PDKU.js → chunk-VD2UDVF7.js} +102 -604
- package/dist/chunk-VD2UDVF7.js.map +1 -0
- package/dist/{chunk-FGW5OWJ4.js → chunk-VJUML33I.js} +4 -156
- package/dist/chunk-VJUML33I.js.map +1 -0
- package/dist/export/index.cjs +4 -2
- package/dist/export/index.cjs.map +1 -1
- package/dist/export/index.js +5 -3
- package/dist/{export-BJE8T0YA.d.cts → export-DMOuzgZZ.d.cts} +9 -4
- package/dist/{export-Con3UKkm.d.ts → export-Dul1SbPv.d.ts} +9 -4
- package/dist/export-Dv0-ZVrV.d.cts +501 -0
- package/dist/export-Dv0-ZVrV.d.ts +501 -0
- package/dist/{retouch-Bxkuc0KH.d.cts → flow-4-OC-UkQ.d.cts} +582 -2
- package/dist/{retouch-Do6tBs2H.d.ts → flow-Cb7lkPm8.d.ts} +582 -2
- package/dist/image-editor/index.cjs +1345 -1095
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +8 -8
- package/dist/image-editor/index.d.ts +8 -8
- package/dist/image-editor/index.js +300 -50
- package/dist/image-editor/index.js.map +1 -1
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/kernel-wasm-WYCGNZR4.js +10 -0
- package/dist/kernel-wasm-WYCGNZR4.js.map +1 -0
- package/dist/kernel-wasm-YPVAEMVN.cjs +10 -0
- package/dist/kernel-wasm-YPVAEMVN.cjs.map +1 -0
- package/dist/paint/index.cjs +170 -4
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +225 -3
- package/dist/paint/index.d.ts +225 -3
- package/dist/paint/index.js +171 -5
- package/dist/paint-editor/index.cjs +4735 -890
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +1526 -278
- package/dist/paint-editor/index.d.ts +1526 -278
- package/dist/paint-editor/index.js +4561 -716
- package/dist/paint-editor/index.js.map +1 -1
- package/dist/raster/index.cjs +7 -4
- package/dist/raster/index.cjs.map +1 -1
- package/dist/raster/index.d.cts +2 -2
- package/dist/raster/index.d.ts +2 -2
- package/dist/raster/index.js +36 -33
- package/dist/{render-CrmHOgpo.d.ts → render-B05K68_h.d.ts} +9 -1
- package/dist/{render-B1K_OoLy.d.cts → render-DnAbIKcs.d.cts} +9 -1
- package/dist/{svg-BnRj0q8i.d.cts → svg-CVdFc80-.d.cts} +2 -2
- package/dist/{svg-CmmBFfGT.d.ts → svg-DlEuhwoX.d.ts} +2 -2
- package/dist/{types-1SUQKDAw.d.ts → types-CDLGhAZp.d.ts} +40 -2
- package/dist/{types-yINF17Ta.d.cts → types-Tfly4Aya.d.cts} +40 -2
- package/dist/vector/index.cjs +6536 -4525
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +426 -32
- package/dist/vector/index.d.ts +426 -32
- package/dist/vector/index.js +11397 -9386
- package/dist/vector/index.js.map +1 -1
- package/dist/video-editor/index.cjs +502 -2165
- package/dist/video-editor/index.cjs.map +1 -1
- package/dist/video-editor/index.d.cts +3 -501
- package/dist/video-editor/index.d.ts +3 -501
- package/dist/video-editor/index.js +151 -1814
- package/dist/video-editor/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/pixerate-image-editor/references/photoshop-files.md +7 -3
- package/skills/pixerate-vector/SKILL.md +3 -0
- package/dist/chunk-C6C5PDKU.js.map +0 -1
- package/dist/chunk-DFQEX3AM.cjs.map +0 -1
- package/dist/chunk-FGW5OWJ4.js.map +0 -1
- package/dist/chunk-FV5AXTSF.cjs.map +0 -1
- package/dist/chunk-GX332W2C.js +0 -181
- package/dist/chunk-GX332W2C.js.map +0 -1
- package/dist/chunk-LKCYANMW.js.map +0 -1
- package/dist/chunk-LPLCWZTM.cjs.map +0 -1
- package/dist/chunk-MUUXNRU4.cjs +0 -181
- package/dist/chunk-MUUXNRU4.cjs.map +0 -1
- package/dist/chunk-ST7E3NEE.cjs.map +0 -1
- package/dist/chunk-TCKIXI46.cjs +0 -1136
- package/dist/chunk-TCKIXI46.cjs.map +0 -1
- package/dist/chunk-TFOPHZ3U.cjs.map +0 -1
- package/dist/chunk-UBIXVXPR.js +0 -1136
- package/dist/chunk-UBIXVXPR.js.map +0 -1
- package/dist/chunk-VXR7XWMF.js.map +0 -1
- package/dist/chunk-XK5LZKBD.js.map +0 -1
- /package/dist/{chunk-XICA4PVO.js.map → chunk-R2JE6SA7.js.map} +0 -0
- /package/dist/{chunk-MMVHBKMM.js.map → chunk-T2P5TIZ6.js.map} +0 -0
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkEJVDBITDcjs = require('./chunk-EJVDBITD.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
11
14
|
|
|
12
15
|
|
|
13
16
|
|
|
@@ -26,255 +29,12 @@ var _chunkMUUXNRU4cjs = require('./chunk-MUUXNRU4.cjs');
|
|
|
26
29
|
|
|
27
30
|
|
|
28
31
|
|
|
29
|
-
var _chunkTFOPHZ3Ucjs = require('./chunk-TFOPHZ3U.cjs');
|
|
30
32
|
|
|
31
33
|
|
|
32
34
|
|
|
33
|
-
var _chunk643B2HKCcjs = require('./chunk-643B2HKC.cjs');
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
var
|
|
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;
|
|
80
|
-
}
|
|
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;
|
|
94
|
-
}
|
|
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;
|
|
106
|
-
}
|
|
107
|
-
return out;
|
|
108
|
-
}
|
|
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;
|
|
114
|
-
}
|
|
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]);
|
|
120
|
-
}
|
|
121
|
-
return out;
|
|
122
|
-
}
|
|
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;
|
|
131
|
-
}
|
|
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);
|
|
137
|
-
}
|
|
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
|
-
}
|
|
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);
|
|
183
|
-
}
|
|
184
|
-
return out;
|
|
185
|
-
}
|
|
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);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return out;
|
|
222
|
-
}
|
|
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);
|
|
247
|
-
}
|
|
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);
|
|
253
|
-
}
|
|
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);
|
|
256
|
-
}
|
|
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;
|
|
272
|
-
}
|
|
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;
|
|
277
|
-
}
|
|
36
|
+
|
|
37
|
+
var _chunk7ISPWEJAcjs = require('./chunk-7ISPWEJA.cjs');
|
|
278
38
|
|
|
279
39
|
// src/raster/effects/model.ts
|
|
280
40
|
var DEFAULT_GLOBAL_LIGHT = { angle: 120, altitude: 30 };
|
|
@@ -463,7 +223,7 @@ function oneOf(r, key, path, values) {
|
|
|
463
223
|
if (typeof r[key] !== "string" || !values.includes(r[key])) fail(`${path}.${key}`, `must be one of ${values.join(", ")}.`);
|
|
464
224
|
}
|
|
465
225
|
function blend(r, key, path) {
|
|
466
|
-
if (!
|
|
226
|
+
if (!_chunk7ISPWEJAcjs.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])}).`);
|
|
467
227
|
if (r[key] === "pigment") fail(`${path}.${key}`, "pigment is a layer blend mode only; effects cannot use it.");
|
|
468
228
|
}
|
|
469
229
|
function contour(v, path) {
|
|
@@ -729,10 +489,10 @@ var DeepCompositor = class {
|
|
|
729
489
|
}
|
|
730
490
|
// --- Steps (as RasterCompositor.buildSteps) ------------------------------------
|
|
731
491
|
isPixel(l) {
|
|
732
|
-
return l.type === "pixel" || (_nullishCoalesce(_optionalChain([this, 'access',
|
|
492
|
+
return l.type === "pixel" || (_nullishCoalesce(_optionalChain([this, 'access', _2 => _2.profile, 'access', _3 => _3.isPixelLike, 'optionalCall', _4 => _4(l)]), () => ( false)));
|
|
733
493
|
}
|
|
734
494
|
isFilter(l) {
|
|
735
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
495
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _5 => _5.profile, 'access', _6 => _6.isFilterLayer, 'optionalCall', _7 => _7(l)]), () => ( false));
|
|
736
496
|
}
|
|
737
497
|
buildSteps(layers) {
|
|
738
498
|
const steps = [];
|
|
@@ -837,24 +597,24 @@ var DeepCompositor = class {
|
|
|
837
597
|
}
|
|
838
598
|
if (!visible.length) return;
|
|
839
599
|
if (this.deep.applyFilterRunDeep) {
|
|
840
|
-
if (this.linear) mapColour(acc, srgbEncode);
|
|
600
|
+
if (this.linear) mapColour(acc, _chunk7ISPWEJAcjs.srgbEncode);
|
|
841
601
|
this.deep.applyFilterRunDeep(visible, acc, r, masks, this.sources);
|
|
842
|
-
if (this.linear) mapColour(acc, srgbDecode);
|
|
602
|
+
if (this.linear) mapColour(acc, _chunk7ISPWEJAcjs.srgbDecode);
|
|
843
603
|
return;
|
|
844
604
|
}
|
|
845
605
|
const bytes = this.to8(acc);
|
|
846
|
-
_optionalChain([this, 'access',
|
|
606
|
+
_optionalChain([this, 'access', _8 => _8.profile, 'access', _9 => _9.applyFilterRun, 'optionalCall', _10 => _10(visible, bytes, r, masks, this.sources)]);
|
|
847
607
|
acc.set(this.from8(bytes));
|
|
848
608
|
}
|
|
849
609
|
// --- Layer content ---------------------------------------------------------------
|
|
850
610
|
/** Layers drawn by the 8-bit compositor alone (effects, pixel filters, content the editor draws). */
|
|
851
611
|
renderedAlone(layer) {
|
|
852
612
|
if (hasActiveEffects(layer.effects) && !this.isFilter(layer)) return true;
|
|
853
|
-
if (this.isPixel(layer)) return Boolean(_optionalChain([this, 'access',
|
|
613
|
+
if (this.isPixel(layer)) return Boolean(_optionalChain([this, 'access', _11 => _11.profile, 'access', _12 => _12.pixelFilters, 'optionalCall', _13 => _13(layer)]));
|
|
854
614
|
return !isGroup(layer);
|
|
855
615
|
}
|
|
856
616
|
blendOf(layer) {
|
|
857
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
617
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _14 => _14.profile, 'access', _15 => _15.contentBlend, 'optionalCall', _16 => _16(layer)]), () => ( layer.blend));
|
|
858
618
|
}
|
|
859
619
|
/** A layer's float RGBA over `r` (straight alpha, working space), or `null` when it has none there. */
|
|
860
620
|
content(layer, r) {
|
|
@@ -865,9 +625,9 @@ var DeepCompositor = class {
|
|
|
865
625
|
}
|
|
866
626
|
const surface = this.sources.surfaceOf ? this.sources.surfaceOf(layer) : layer.surface;
|
|
867
627
|
if (!surface) return null;
|
|
868
|
-
const ox = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
869
|
-
const oy = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
870
|
-
const samples = readDeepRegion(surface, { x: r.x - ox, y: r.y - oy, width: r.width, height: r.height }, this.depth);
|
|
628
|
+
const ox = _nullishCoalesce(_optionalChain([layer, 'access', _17 => _17.offset, 'optionalAccess', _18 => _18.x]), () => ( 0));
|
|
629
|
+
const oy = _nullishCoalesce(_optionalChain([layer, 'access', _19 => _19.offset, 'optionalAccess', _20 => _20.y]), () => ( 0));
|
|
630
|
+
const samples = _chunk7ISPWEJAcjs.readDeepRegion.call(void 0, surface, { x: r.x - ox, y: r.y - oy, width: r.width, height: r.height }, this.depth);
|
|
871
631
|
if (samples instanceof Float32Array) return samples;
|
|
872
632
|
const out = new Float32Array(samples.length);
|
|
873
633
|
for (let i = 0; i < samples.length; i++) out[i] = samples[i] / 65535;
|
|
@@ -875,7 +635,7 @@ var DeepCompositor = class {
|
|
|
875
635
|
}
|
|
876
636
|
/** 8-bit RGBA to the working space. */
|
|
877
637
|
from8(bytes) {
|
|
878
|
-
if (this.linear) return to32From8(bytes, 4);
|
|
638
|
+
if (this.linear) return _chunk7ISPWEJAcjs.to32From8.call(void 0, bytes, 4);
|
|
879
639
|
const out = new Float32Array(bytes.length);
|
|
880
640
|
for (let i = 0; i < bytes.length; i++) out[i] = bytes[i] / 255;
|
|
881
641
|
return out;
|
|
@@ -884,7 +644,7 @@ var DeepCompositor = class {
|
|
|
884
644
|
to8(acc) {
|
|
885
645
|
const out = new Uint8ClampedArray(acc.length);
|
|
886
646
|
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);
|
|
647
|
+
for (let c = 0; c < 3; c++) out[i + c] = Math.round((this.linear ? _chunk7ISPWEJAcjs.srgbEncode.call(void 0, acc[i + c]) : acc[i + c]) * 255);
|
|
888
648
|
out[i + 3] = Math.round(acc[i + 3] * 255);
|
|
889
649
|
}
|
|
890
650
|
return out;
|
|
@@ -922,13 +682,13 @@ var DeepCompositor = class {
|
|
|
922
682
|
cs[c] = src[i + c];
|
|
923
683
|
}
|
|
924
684
|
if (pigment) {
|
|
925
|
-
if (this.linear) for (let c = 0; c < 3; c++) cb[c] = srgbEncode(cb[c]), cs[c] = srgbEncode(cs[c]);
|
|
926
|
-
|
|
927
|
-
for (let c = 0; c < 3; c++) dst[i + c] = this.linear ? srgbDecode(mix[c]) : mix[c];
|
|
685
|
+
if (this.linear) for (let c = 0; c < 3; c++) cb[c] = _chunk7ISPWEJAcjs.srgbEncode.call(void 0, cb[c]), cs[c] = _chunk7ISPWEJAcjs.srgbEncode.call(void 0, cs[c]);
|
|
686
|
+
_chunk7ISPWEJAcjs.mixPigmentRgb.call(void 0, cb, cs, as / ao, mix);
|
|
687
|
+
for (let c = 0; c < 3; c++) dst[i + c] = this.linear ? _chunk7ISPWEJAcjs.srgbDecode.call(void 0, mix[c]) : mix[c];
|
|
928
688
|
dst[i + 3] = ao;
|
|
929
689
|
continue;
|
|
930
690
|
}
|
|
931
|
-
const m = normal ? cs :
|
|
691
|
+
const m = normal ? cs : _chunk7ISPWEJAcjs.blendRgb.call(void 0, mode, cb, cs);
|
|
932
692
|
const wb = (1 - as) * ab;
|
|
933
693
|
const ws = (1 - ab) * as;
|
|
934
694
|
const wm = as * ab;
|
|
@@ -1130,7 +890,7 @@ function insertLayer(layers, layer, parentId, index) {
|
|
|
1130
890
|
});
|
|
1131
891
|
}
|
|
1132
892
|
function isLayerLocked(layer, what) {
|
|
1133
|
-
return Boolean(_optionalChain([layer, 'access',
|
|
893
|
+
return Boolean(_optionalChain([layer, 'access', _21 => _21.locks, 'optionalAccess', _22 => _22.all]) || _optionalChain([layer, 'access', _23 => _23.locks, 'optionalAccess', _24 => _24[what]]));
|
|
1134
894
|
}
|
|
1135
895
|
|
|
1136
896
|
// src/raster/effects/patterns.ts
|
|
@@ -2091,7 +1851,7 @@ function compositeAt(dst, i, mode, separable, sr, sg, sb, sa) {
|
|
|
2091
1851
|
rgbScratchS[0] = sr;
|
|
2092
1852
|
rgbScratchS[1] = sg;
|
|
2093
1853
|
rgbScratchS[2] = sb;
|
|
2094
|
-
|
|
1854
|
+
_chunk7ISPWEJAcjs.mixPigmentRgb.call(void 0, rgbScratchB, rgbScratchS, sa / ao, rgbScratchM);
|
|
2095
1855
|
dst[i] = rgbScratchM[0];
|
|
2096
1856
|
dst[i + 1] = rgbScratchM[1];
|
|
2097
1857
|
dst[i + 2] = rgbScratchM[2];
|
|
@@ -2106,9 +1866,9 @@ function compositeAt(dst, i, mode, separable, sr, sg, sb, sa) {
|
|
|
2106
1866
|
m1 = sg;
|
|
2107
1867
|
m2 = sb;
|
|
2108
1868
|
} else if (separable) {
|
|
2109
|
-
m0 =
|
|
2110
|
-
m1 =
|
|
2111
|
-
m2 =
|
|
1869
|
+
m0 = _chunk7ISPWEJAcjs.blendChannel.call(void 0, mode, b0, sr);
|
|
1870
|
+
m1 = _chunk7ISPWEJAcjs.blendChannel.call(void 0, mode, b1, sg);
|
|
1871
|
+
m2 = _chunk7ISPWEJAcjs.blendChannel.call(void 0, mode, b2, sb);
|
|
2112
1872
|
} else {
|
|
2113
1873
|
rgbScratchB[0] = b0;
|
|
2114
1874
|
rgbScratchB[1] = b1;
|
|
@@ -2116,7 +1876,7 @@ function compositeAt(dst, i, mode, separable, sr, sg, sb, sa) {
|
|
|
2116
1876
|
rgbScratchS[0] = sr;
|
|
2117
1877
|
rgbScratchS[1] = sg;
|
|
2118
1878
|
rgbScratchS[2] = sb;
|
|
2119
|
-
const m =
|
|
1879
|
+
const m = _chunk7ISPWEJAcjs.blendRgb.call(void 0, mode, rgbScratchB, rgbScratchS);
|
|
2120
1880
|
m0 = m[0];
|
|
2121
1881
|
m1 = m[1];
|
|
2122
1882
|
m2 = m[2];
|
|
@@ -2130,7 +1890,7 @@ function compositeAt(dst, i, mode, separable, sr, sg, sb, sa) {
|
|
|
2130
1890
|
dst[i + 3] = ao;
|
|
2131
1891
|
}
|
|
2132
1892
|
function paint(dst, m, color2, mode, opacity) {
|
|
2133
|
-
const sep = mode !== "normal" &&
|
|
1893
|
+
const sep = mode !== "normal" && _chunk7ISPWEJAcjs.isSeparableBlendMode.call(void 0, mode);
|
|
2134
1894
|
const c = [0, 0, 0, 1];
|
|
2135
1895
|
const n = m.length;
|
|
2136
1896
|
for (let i = 0; i < n; i++) {
|
|
@@ -2419,7 +2179,7 @@ function compositeLayerEffects(input) {
|
|
|
2419
2179
|
}
|
|
2420
2180
|
const premerge = !normalLike;
|
|
2421
2181
|
if (premerge) {
|
|
2422
|
-
const sep2 =
|
|
2182
|
+
const sep2 = _chunk7ISPWEJAcjs.isSeparableBlendMode.call(void 0, input.blend);
|
|
2423
2183
|
for (let i = 0; i < n; i++) {
|
|
2424
2184
|
const p = i * 4;
|
|
2425
2185
|
const sr = lay[p];
|
|
@@ -2539,7 +2299,7 @@ function compositeLayerEffects(input) {
|
|
|
2539
2299
|
paintColor(work, fx(i, 1), e.shadowColor, e.shadowBlend, e.shadowOpacity);
|
|
2540
2300
|
}
|
|
2541
2301
|
const mode = premerge ? "normal" : input.blend;
|
|
2542
|
-
const sep =
|
|
2302
|
+
const sep = _chunk7ISPWEJAcjs.isSeparableBlendMode.call(void 0, mode);
|
|
2543
2303
|
for (let i = 0; i < n; i++) {
|
|
2544
2304
|
const p = i * 4;
|
|
2545
2305
|
if (lay[p + 3] > 0) compositeAt(work, p, mode, sep, lay[p], lay[p + 1], lay[p + 2], lay[p + 3]);
|
|
@@ -2584,8 +2344,8 @@ function renderLayerEffects(effects, layer, backdrop, canvas, ctx) {
|
|
|
2584
2344
|
}
|
|
2585
2345
|
|
|
2586
2346
|
// src/raster/compositor.ts
|
|
2587
|
-
var
|
|
2588
|
-
var TILE_BYTES =
|
|
2347
|
+
var TILE_PIXELS = _chunk7ISPWEJAcjs.TILE * _chunk7ISPWEJAcjs.TILE;
|
|
2348
|
+
var TILE_BYTES = TILE_PIXELS * 4;
|
|
2589
2349
|
function sameSig(a, b) {
|
|
2590
2350
|
if (!a || a.key !== b.key || a.refs.length !== b.refs.length) return false;
|
|
2591
2351
|
for (let i = 0; i < a.refs.length; i++) if (a.refs[i] !== b.refs[i]) return false;
|
|
@@ -2596,13 +2356,13 @@ function dirtyInTile(rects, tx, ty) {
|
|
|
2596
2356
|
let y0 = Infinity;
|
|
2597
2357
|
let x1 = -Infinity;
|
|
2598
2358
|
let y1 = -Infinity;
|
|
2599
|
-
const ox = tx *
|
|
2600
|
-
const oy = ty *
|
|
2359
|
+
const ox = tx * _chunk7ISPWEJAcjs.TILE;
|
|
2360
|
+
const oy = ty * _chunk7ISPWEJAcjs.TILE;
|
|
2601
2361
|
for (const r of rects) {
|
|
2602
2362
|
const a = Math.max(ox, Math.floor(r.x));
|
|
2603
2363
|
const b = Math.max(oy, Math.floor(r.y));
|
|
2604
|
-
const c = Math.min(ox +
|
|
2605
|
-
const d = Math.min(oy +
|
|
2364
|
+
const c = Math.min(ox + _chunk7ISPWEJAcjs.TILE, Math.ceil(r.x + r.width));
|
|
2365
|
+
const d = Math.min(oy + _chunk7ISPWEJAcjs.TILE, Math.ceil(r.y + r.height));
|
|
2606
2366
|
if (c <= a || d <= b) continue;
|
|
2607
2367
|
x0 = Math.min(x0, a);
|
|
2608
2368
|
y0 = Math.min(y0, b);
|
|
@@ -2615,7 +2375,7 @@ function blendTile(dst, src, mode, alpha, coverage) {
|
|
|
2615
2375
|
if (!(alpha > 0)) return;
|
|
2616
2376
|
const normal = mode === "normal";
|
|
2617
2377
|
const pigment = mode === "pigment";
|
|
2618
|
-
const lut = !normal &&
|
|
2378
|
+
const lut = !normal && _chunk7ISPWEJAcjs.isSeparableBlendMode.call(void 0, mode) ? separableLut(mode) : null;
|
|
2619
2379
|
const cb = [0, 0, 0];
|
|
2620
2380
|
const cs = [0, 0, 0];
|
|
2621
2381
|
const n = dst.length;
|
|
@@ -2642,7 +2402,7 @@ function blendTile(dst, src, mode, alpha, coverage) {
|
|
|
2642
2402
|
const d1 = dst[i + 1];
|
|
2643
2403
|
const d2 = dst[i + 2];
|
|
2644
2404
|
if (pigment) {
|
|
2645
|
-
|
|
2405
|
+
_chunk7ISPWEJAcjs.mixPigment8.call(void 0, d0, d1, d2, src[i], src[i + 1], src[i + 2], as / ao, cb);
|
|
2646
2406
|
dst[i] = Math.round(cb[0] * 255);
|
|
2647
2407
|
dst[i + 1] = Math.round(cb[1] * 255);
|
|
2648
2408
|
dst[i + 2] = Math.round(cb[2] * 255);
|
|
@@ -2673,7 +2433,7 @@ function blendTile(dst, src, mode, alpha, coverage) {
|
|
|
2673
2433
|
cs[0] = s0;
|
|
2674
2434
|
cs[1] = s1;
|
|
2675
2435
|
cs[2] = s2;
|
|
2676
|
-
const m =
|
|
2436
|
+
const m = _chunk7ISPWEJAcjs.blendRgb.call(void 0, mode, cb, cs);
|
|
2677
2437
|
m0 = m[0];
|
|
2678
2438
|
m1 = m[1];
|
|
2679
2439
|
m2 = m[2];
|
|
@@ -2692,7 +2452,7 @@ function separableLut(mode) {
|
|
|
2692
2452
|
let lut = separableLuts.get(mode);
|
|
2693
2453
|
if (!lut) {
|
|
2694
2454
|
lut = new Float64Array(65536);
|
|
2695
|
-
for (let b = 0; b < 256; b++) for (let c = 0; c < 256; c++) lut[b << 8 | c] =
|
|
2455
|
+
for (let b = 0; b < 256; b++) for (let c = 0; c < 256; c++) lut[b << 8 | c] = _chunk7ISPWEJAcjs.blendChannel.call(void 0, mode, b / 255, c / 255);
|
|
2696
2456
|
separableLuts.set(mode, lut);
|
|
2697
2457
|
}
|
|
2698
2458
|
return lut;
|
|
@@ -2766,15 +2526,15 @@ var RasterCompositor = (_class = class {
|
|
|
2766
2526
|
composite(layers, rect, sources, options = {}) {
|
|
2767
2527
|
const out = new Uint8ClampedArray(Math.max(0, rect.width * rect.height * 4));
|
|
2768
2528
|
this.compositeTiles(layers, rect, sources, (tx, ty, data) => {
|
|
2769
|
-
const ox = tx *
|
|
2770
|
-
const oy = ty *
|
|
2529
|
+
const ox = tx * _chunk7ISPWEJAcjs.TILE;
|
|
2530
|
+
const oy = ty * _chunk7ISPWEJAcjs.TILE;
|
|
2771
2531
|
const x0 = Math.max(rect.x, ox);
|
|
2772
2532
|
const y0 = Math.max(rect.y, oy);
|
|
2773
|
-
const x1 = Math.min(rect.x + rect.width, ox +
|
|
2774
|
-
const y1 = Math.min(rect.y + rect.height, oy +
|
|
2533
|
+
const x1 = Math.min(rect.x + rect.width, ox + _chunk7ISPWEJAcjs.TILE);
|
|
2534
|
+
const y1 = Math.min(rect.y + rect.height, oy + _chunk7ISPWEJAcjs.TILE);
|
|
2775
2535
|
const span = (x1 - x0) * 4;
|
|
2776
2536
|
for (let y = y0; y < y1; y++) {
|
|
2777
|
-
const s = ((y - oy) *
|
|
2537
|
+
const s = ((y - oy) * _chunk7ISPWEJAcjs.TILE + (x0 - ox)) * 4;
|
|
2778
2538
|
out.set(data.subarray(s, s + span), ((y - rect.y) * rect.width + (x0 - rect.x)) * 4);
|
|
2779
2539
|
}
|
|
2780
2540
|
}, options);
|
|
@@ -2795,9 +2555,9 @@ var RasterCompositor = (_class = class {
|
|
|
2795
2555
|
this.callStats = stats;
|
|
2796
2556
|
const grow = options.dirty ? this.effectsReach(layers) : 0;
|
|
2797
2557
|
const dirty = grow > 0 ? options.dirty.map((d) => inflateRect(d, grow)) : options.dirty;
|
|
2798
|
-
for (const { tx, ty } of
|
|
2558
|
+
for (const { tx, ty } of _chunk7ISPWEJAcjs.tilesInRect.call(void 0, rect)) {
|
|
2799
2559
|
stats.tiles++;
|
|
2800
|
-
const before = _optionalChain([this, 'access',
|
|
2560
|
+
const before = _optionalChain([this, 'access', _25 => _25.tiles, 'access', _26 => _26.get, 'call', _27 => _27(_chunk7ISPWEJAcjs.tileKey.call(void 0, tx, ty)), 'optionalAccess', _28 => _28.result]);
|
|
2801
2561
|
const data = this.compositeTile(layers, steps, tx, ty, stats, dirty ? dirtyInTile(dirty, tx, ty) : null);
|
|
2802
2562
|
onTile(tx, ty, data, data !== before);
|
|
2803
2563
|
}
|
|
@@ -2828,10 +2588,10 @@ var RasterCompositor = (_class = class {
|
|
|
2828
2588
|
// --- Steps -------------------------------------------------------------------
|
|
2829
2589
|
/** Pixel layers, and the layer kinds the profile composites like them. */
|
|
2830
2590
|
isPixel(l) {
|
|
2831
|
-
return l.type === "pixel" || (_nullishCoalesce(_optionalChain([this, 'access',
|
|
2591
|
+
return l.type === "pixel" || (_nullishCoalesce(_optionalChain([this, 'access', _29 => _29.profile, 'access', _30 => _30.isPixelLike, 'optionalCall', _31 => _31(l)]), () => ( false)));
|
|
2832
2592
|
}
|
|
2833
2593
|
isFilter(l) {
|
|
2834
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
2594
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _32 => _32.profile, 'access', _33 => _33.isFilterLayer, 'optionalCall', _34 => _34(l)]), () => ( false));
|
|
2835
2595
|
}
|
|
2836
2596
|
/**
|
|
2837
2597
|
* Groups a layer list into compositing steps: clipped layers join the nearest unclipped
|
|
@@ -2870,16 +2630,16 @@ var RasterCompositor = (_class = class {
|
|
|
2870
2630
|
if (key !== void 0) return key;
|
|
2871
2631
|
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;
|
|
2872
2632
|
const base = [layer.type, layer.id, layer.visible, layer.opacity, layer.blend, Boolean(layer.clipped), mask];
|
|
2873
|
-
if (this.isPixel(layer)) base.push(_nullishCoalesce(_optionalChain([layer, 'access',
|
|
2633
|
+
if (this.isPixel(layer)) base.push(_nullishCoalesce(_optionalChain([layer, 'access', _35 => _35.offset, 'optionalAccess', _36 => _36.x]), () => ( 0)), _nullishCoalesce(_optionalChain([layer, 'access', _37 => _37.offset, 'optionalAccess', _38 => _38.y]), () => ( 0)), _nullishCoalesce(layer.fillOpacity, () => ( 1)));
|
|
2874
2634
|
if (this.hasEffects(layer)) base.push(effectsFingerprint(layer.effects));
|
|
2875
|
-
const extra = _optionalChain([this, 'access',
|
|
2635
|
+
const extra = _optionalChain([this, 'access', _39 => _39.profile, 'access', _40 => _40.layerKey, 'optionalCall', _41 => _41(layer)]);
|
|
2876
2636
|
if (extra !== void 0) base.push(extra);
|
|
2877
2637
|
key = JSON.stringify(base);
|
|
2878
2638
|
this.propsKeyCache.set(layer, key);
|
|
2879
2639
|
return key;
|
|
2880
2640
|
}
|
|
2881
2641
|
compositeTile(root, steps, tx, ty, stats, dirty = null) {
|
|
2882
|
-
const key =
|
|
2642
|
+
const key = _chunk7ISPWEJAcjs.tileKey.call(void 0, tx, ty);
|
|
2883
2643
|
const entry = this.tiles.get(key);
|
|
2884
2644
|
const sigs = steps.map((s) => this.stepSig(s, tx, ty));
|
|
2885
2645
|
let first = 0;
|
|
@@ -2902,20 +2662,20 @@ var RasterCompositor = (_class = class {
|
|
|
2902
2662
|
}
|
|
2903
2663
|
}
|
|
2904
2664
|
}
|
|
2905
|
-
const tileRect = { x: tx *
|
|
2665
|
+
const tileRect = { x: tx * _chunk7ISPWEJAcjs.TILE, y: ty * _chunk7ISPWEJAcjs.TILE, width: _chunk7ISPWEJAcjs.TILE, height: _chunk7ISPWEJAcjs.TILE };
|
|
2906
2666
|
const hint = this.hint;
|
|
2907
2667
|
const checkpoints = /* @__PURE__ */ new Map();
|
|
2908
2668
|
if (entry) {
|
|
2909
2669
|
for (const [index, cp] of entry.checkpoints) if (index <= start) checkpoints.set(index, cp);
|
|
2910
2670
|
}
|
|
2911
2671
|
let result;
|
|
2912
|
-
if (entry && dirty && (dirty.width <
|
|
2672
|
+
if (entry && dirty && (dirty.width < _chunk7ISPWEJAcjs.TILE || dirty.height < _chunk7ISPWEJAcjs.TILE)) {
|
|
2913
2673
|
const r = dirty;
|
|
2914
2674
|
const sub = (data) => {
|
|
2915
2675
|
const out = new Uint8ClampedArray(r.width * r.height * 4);
|
|
2916
2676
|
if (!data) return out;
|
|
2917
2677
|
for (let y = 0; y < r.height; y++) {
|
|
2918
|
-
const s = ((r.y - tileRect.y + y) *
|
|
2678
|
+
const s = ((r.y - tileRect.y + y) * _chunk7ISPWEJAcjs.TILE + (r.x - tileRect.x)) * 4;
|
|
2919
2679
|
out.set(data.subarray(s, s + r.width * 4), y * r.width * 4);
|
|
2920
2680
|
}
|
|
2921
2681
|
return out;
|
|
@@ -2928,7 +2688,7 @@ var RasterCompositor = (_class = class {
|
|
|
2928
2688
|
}
|
|
2929
2689
|
result = new Uint8ClampedArray(entry.result);
|
|
2930
2690
|
for (let y = 0; y < r.height; y++) {
|
|
2931
|
-
result.set(acc.subarray(y * r.width * 4, (y + 1) * r.width * 4), ((r.y - tileRect.y + y) *
|
|
2691
|
+
result.set(acc.subarray(y * r.width * 4, (y + 1) * r.width * 4), ((r.y - tileRect.y + y) * _chunk7ISPWEJAcjs.TILE + (r.x - tileRect.x)) * 4);
|
|
2932
2692
|
}
|
|
2933
2693
|
} else {
|
|
2934
2694
|
const acc = base ? new Uint8ClampedArray(base.data) : new Uint8ClampedArray(TILE_BYTES);
|
|
@@ -3037,9 +2797,9 @@ var RasterCompositor = (_class = class {
|
|
|
3037
2797
|
if (!this.isPixel(layer)) return { key, refs: this.maskRefs(layer, tx, ty, 0, 0) };
|
|
3038
2798
|
const { surface, dx, dy } = this.layerPixels(layer);
|
|
3039
2799
|
const refs = [surface.defaultValue];
|
|
3040
|
-
const r = { x: tx *
|
|
3041
|
-
for (const t of
|
|
3042
|
-
refs.push(...this.maskRefs(layer, tx, ty, _nullishCoalesce(_optionalChain([layer, 'access',
|
|
2800
|
+
const r = { x: tx * _chunk7ISPWEJAcjs.TILE - dx, y: ty * _chunk7ISPWEJAcjs.TILE - dy, width: _chunk7ISPWEJAcjs.TILE, height: _chunk7ISPWEJAcjs.TILE };
|
|
2801
|
+
for (const t of _chunk7ISPWEJAcjs.tilesInRect.call(void 0, r)) refs.push(_nullishCoalesce(surface.getTile(t.tx, t.ty), () => ( null)));
|
|
2802
|
+
refs.push(...this.maskRefs(layer, tx, ty, _nullishCoalesce(_optionalChain([layer, 'access', _42 => _42.offset, 'optionalAccess', _43 => _43.x]), () => ( 0)), _nullishCoalesce(_optionalChain([layer, 'access', _44 => _44.offset, 'optionalAccess', _45 => _45.y]), () => ( 0))));
|
|
3043
2803
|
return { key, refs };
|
|
3044
2804
|
}
|
|
3045
2805
|
// --- Layer effects ------------------------------------------------------------
|
|
@@ -3069,7 +2829,7 @@ var RasterCompositor = (_class = class {
|
|
|
3069
2829
|
this.fxContext = {
|
|
3070
2830
|
light: _nullishCoalesce(sources.globalLight, () => ( DEFAULT_GLOBAL_LIGHT)),
|
|
3071
2831
|
pattern: (id) => {
|
|
3072
|
-
const p = _nullishCoalesce(_optionalChain([sources, 'access',
|
|
2832
|
+
const p = _nullishCoalesce(_optionalChain([sources, 'access', _46 => _46.pattern, 'optionalCall', _47 => _47(id)]), () => ( builtinPattern(id)));
|
|
3073
2833
|
if (!p || !(p.width > 0 && p.height > 0) || p.data.length < p.width * p.height * 4) return null;
|
|
3074
2834
|
let t = tiles.get(p);
|
|
3075
2835
|
if (!t) {
|
|
@@ -3100,8 +2860,8 @@ var RasterCompositor = (_class = class {
|
|
|
3100
2860
|
const sigs = /* @__PURE__ */ new Map();
|
|
3101
2861
|
if (region.width <= 0 || region.height <= 0) return sigs;
|
|
3102
2862
|
const steps = isGroup2(layer) ? this.buildSteps(_nullishCoalesce(layer.children, () => ( []))) : null;
|
|
3103
|
-
for (const t of
|
|
3104
|
-
sigs.set(
|
|
2863
|
+
for (const t of _chunk7ISPWEJAcjs.tilesInRect.call(void 0, region)) {
|
|
2864
|
+
sigs.set(_chunk7ISPWEJAcjs.tileKey.call(void 0, t.tx, t.ty), steps ? this.plainGroupSig(layer, steps, t.tx, t.ty) : this.plainContentSig(layer, t.tx, t.ty));
|
|
3105
2865
|
}
|
|
3106
2866
|
return sigs;
|
|
3107
2867
|
}
|
|
@@ -3125,7 +2885,7 @@ var RasterCompositor = (_class = class {
|
|
|
3125
2885
|
const region = this.effectRegion(layer);
|
|
3126
2886
|
const m = effectsMargin(layer.effects);
|
|
3127
2887
|
if (effectsAreLocal(activeEffectItems(layer.effects))) {
|
|
3128
|
-
return { key, refs: this.shapeRefs(layer, intersectRect({ x: tx *
|
|
2888
|
+
return { key, refs: this.shapeRefs(layer, intersectRect({ x: tx * _chunk7ISPWEJAcjs.TILE - m, y: ty * _chunk7ISPWEJAcjs.TILE - m, width: _chunk7ISPWEJAcjs.TILE + 2 * m, height: _chunk7ISPWEJAcjs.TILE + 2 * m }, region)) };
|
|
3129
2889
|
}
|
|
3130
2890
|
return { key, refs: [`${region.x},${region.y},${region.width},${region.height}`, ...this.shapeRefs(layer, region)] };
|
|
3131
2891
|
}
|
|
@@ -3174,11 +2934,11 @@ var RasterCompositor = (_class = class {
|
|
|
3174
2934
|
*/
|
|
3175
2935
|
shapeChanges(layer, prev, tiles, region) {
|
|
3176
2936
|
const out = [];
|
|
3177
|
-
for (const { tx, ty } of
|
|
3178
|
-
const sig = tiles.get(
|
|
3179
|
-
const old = prev.tiles.get(
|
|
2937
|
+
for (const { tx, ty } of _chunk7ISPWEJAcjs.tilesInRect.call(void 0, region)) {
|
|
2938
|
+
const sig = tiles.get(_chunk7ISPWEJAcjs.tileKey.call(void 0, tx, ty));
|
|
2939
|
+
const old = prev.tiles.get(_chunk7ISPWEJAcjs.tileKey.call(void 0, tx, ty));
|
|
3180
2940
|
if (old ? sameSig(old, sig) : sig.refs.every((r2) => r2 === null || r2 === 0)) continue;
|
|
3181
|
-
const r = intersectRect({ x: tx *
|
|
2941
|
+
const r = intersectRect({ x: tx * _chunk7ISPWEJAcjs.TILE, y: ty * _chunk7ISPWEJAcjs.TILE, width: _chunk7ISPWEJAcjs.TILE, height: _chunk7ISPWEJAcjs.TILE }, region);
|
|
3182
2942
|
if (r.width > 0 && r.height > 0) out.push(r);
|
|
3183
2943
|
}
|
|
3184
2944
|
const dirty = this.callDirty;
|
|
@@ -3197,7 +2957,7 @@ var RasterCompositor = (_class = class {
|
|
|
3197
2957
|
* without filters or a feathered or parametric mask (those spread a change beyond it).
|
|
3198
2958
|
*/
|
|
3199
2959
|
dirtyCoversShape(layer) {
|
|
3200
|
-
if (!this.isPixel(layer) || _optionalChain([this, 'access',
|
|
2960
|
+
if (!this.isPixel(layer) || _optionalChain([this, 'access', _48 => _48.profile, 'access', _49 => _49.pixelFilters, 'optionalCall', _50 => _50(layer)])) return false;
|
|
3201
2961
|
const mask = layer.mask;
|
|
3202
2962
|
return !mask || mask.enabled === false || !mask.source && !((_nullishCoalesce(mask.feather, () => ( 0))) > 0);
|
|
3203
2963
|
}
|
|
@@ -3273,7 +3033,7 @@ var RasterCompositor = (_class = class {
|
|
|
3273
3033
|
if (!mask || mask.enabled === false) return [];
|
|
3274
3034
|
if (mask.source || (_nullishCoalesce(mask.feather, () => ( 0))) > 0) return [this.planeFor(mask, ox, oy)];
|
|
3275
3035
|
const refs = [];
|
|
3276
|
-
for (const t of
|
|
3036
|
+
for (const t of _chunk7ISPWEJAcjs.tilesInRect.call(void 0, { x: tx * _chunk7ISPWEJAcjs.TILE - ox, y: ty * _chunk7ISPWEJAcjs.TILE - oy, width: _chunk7ISPWEJAcjs.TILE, height: _chunk7ISPWEJAcjs.TILE })) {
|
|
3277
3037
|
refs.push(_nullishCoalesce(mask.surface.getTile(t.tx, t.ty), () => ( null)));
|
|
3278
3038
|
}
|
|
3279
3039
|
return refs;
|
|
@@ -3285,10 +3045,10 @@ var RasterCompositor = (_class = class {
|
|
|
3285
3045
|
*/
|
|
3286
3046
|
layerPixels(layer) {
|
|
3287
3047
|
const raw = this.sources.surfaceOf ? this.sources.surfaceOf(layer) : layer.surface;
|
|
3288
|
-
const ox = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
3289
|
-
const oy = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
3290
|
-
const filters = _nullishCoalesce(_optionalChain([this, 'access',
|
|
3291
|
-
if (!_optionalChain([filters, 'optionalAccess',
|
|
3048
|
+
const ox = _nullishCoalesce(_optionalChain([layer, 'access', _51 => _51.offset, 'optionalAccess', _52 => _52.x]), () => ( 0));
|
|
3049
|
+
const oy = _nullishCoalesce(_optionalChain([layer, 'access', _53 => _53.offset, 'optionalAccess', _54 => _54.y]), () => ( 0));
|
|
3050
|
+
const filters = _nullishCoalesce(_optionalChain([this, 'access', _55 => _55.profile, 'access', _56 => _56.pixelFilters, 'optionalCall', _57 => _57(layer)]), () => ( null));
|
|
3051
|
+
if (!_optionalChain([filters, 'optionalAccess', _58 => _58.spatial])) return { surface: raw, dx: ox, dy: oy, perPixel: filters };
|
|
3292
3052
|
const fkey = `${ox},${oy}:${filters.key}`;
|
|
3293
3053
|
let byKey = this.filteredCache.get(raw);
|
|
3294
3054
|
if (!byKey) {
|
|
@@ -3305,25 +3065,25 @@ var RasterCompositor = (_class = class {
|
|
|
3305
3065
|
}
|
|
3306
3066
|
/** RGBA of a content layer over `r` (document space, inside one tile), or `null` when it has nothing there. */
|
|
3307
3067
|
contentTile(layer, r) {
|
|
3308
|
-
if (!this.isPixel(layer)) return _nullishCoalesce(_optionalChain([this, 'access',
|
|
3068
|
+
if (!this.isPixel(layer)) return _nullishCoalesce(_optionalChain([this, 'access', _59 => _59.profile, 'access', _60 => _60.contentTile, 'optionalCall', _61 => _61(layer, r, this.sources)]), () => ( null));
|
|
3309
3069
|
const { surface, dx, dy, perPixel } = this.layerPixels(layer);
|
|
3310
3070
|
const src = { x: r.x - dx, y: r.y - dy, width: r.width, height: r.height };
|
|
3311
|
-
const covered =
|
|
3071
|
+
const covered = _chunk7ISPWEJAcjs.tilesInRect.call(void 0, src).map((t) => surface.getTile(t.tx, t.ty));
|
|
3312
3072
|
if (surface.defaultValue === 0 && covered.every((t) => !t)) return null;
|
|
3313
|
-
const aligned = r.width ===
|
|
3073
|
+
const aligned = r.width === _chunk7ISPWEJAcjs.TILE && r.height === _chunk7ISPWEJAcjs.TILE && src.x % _chunk7ISPWEJAcjs.TILE === 0 && src.y % _chunk7ISPWEJAcjs.TILE === 0;
|
|
3314
3074
|
if (!perPixel) {
|
|
3315
3075
|
if (aligned && covered[0]) return covered[0].data;
|
|
3316
|
-
return
|
|
3076
|
+
return _chunk7ISPWEJAcjs.readRegion.call(void 0, surface, src);
|
|
3317
3077
|
}
|
|
3318
3078
|
const fkey = `${dx},${dy}:${perPixel.key}`;
|
|
3319
3079
|
const anchor = _nullishCoalesce(covered.find(Boolean), () => ( surface));
|
|
3320
3080
|
let byKey = this.contentCache.get(anchor);
|
|
3321
3081
|
const refsKey = `${r.x},${r.y}:${fkey}`;
|
|
3322
3082
|
if (aligned) {
|
|
3323
|
-
const hit = _optionalChain([byKey, 'optionalAccess',
|
|
3083
|
+
const hit = _optionalChain([byKey, 'optionalAccess', _62 => _62.get, 'call', _63 => _63(refsKey)]);
|
|
3324
3084
|
if (hit) return hit;
|
|
3325
3085
|
}
|
|
3326
|
-
const data =
|
|
3086
|
+
const data = _chunk7ISPWEJAcjs.readRegion.call(void 0, surface, src);
|
|
3327
3087
|
perPixel.apply(data, r.width, r.height);
|
|
3328
3088
|
if (aligned) {
|
|
3329
3089
|
if (!byKey) {
|
|
@@ -3358,11 +3118,11 @@ var RasterCompositor = (_class = class {
|
|
|
3358
3118
|
const H = this.sources.height;
|
|
3359
3119
|
let v = new Float32Array(W * H);
|
|
3360
3120
|
if (mask.source) {
|
|
3361
|
-
const generated = _nullishCoalesce(_optionalChain([this, 'access',
|
|
3121
|
+
const generated = _nullishCoalesce(_optionalChain([this, 'access', _64 => _64.profile, 'access', _65 => _65.maskSourcePlane, 'optionalCall', _66 => _66(mask.source, W, H, this.sources)]), () => ( null));
|
|
3362
3122
|
if (!generated || generated.length !== W * H) v.fill(1);
|
|
3363
3123
|
else v.set(generated);
|
|
3364
3124
|
} else {
|
|
3365
|
-
const bytes =
|
|
3125
|
+
const bytes = _chunk7ISPWEJAcjs.readRegion.call(void 0, mask.surface, { x: -ox, y: -oy, width: W, height: H });
|
|
3366
3126
|
for (let i = 0; i < v.length; i++) v[i] = bytes[i] / 255;
|
|
3367
3127
|
}
|
|
3368
3128
|
const feather = _nullishCoalesce(mask.feather, () => ( 0));
|
|
@@ -3377,8 +3137,8 @@ var RasterCompositor = (_class = class {
|
|
|
3377
3137
|
maskTile(layer, r) {
|
|
3378
3138
|
const mask = layer.mask;
|
|
3379
3139
|
if (!mask || mask.enabled === false) return null;
|
|
3380
|
-
const ox = this.isPixel(layer) ? _nullishCoalesce(_optionalChain([layer, 'access',
|
|
3381
|
-
const oy = this.isPixel(layer) ? _nullishCoalesce(_optionalChain([layer, 'access',
|
|
3140
|
+
const ox = this.isPixel(layer) ? _nullishCoalesce(_optionalChain([layer, 'access', _67 => _67.offset, 'optionalAccess', _68 => _68.x]), () => ( 0)) : 0;
|
|
3141
|
+
const oy = this.isPixel(layer) ? _nullishCoalesce(_optionalChain([layer, 'access', _69 => _69.offset, 'optionalAccess', _70 => _70.y]), () => ( 0)) : 0;
|
|
3382
3142
|
const n = r.width * r.height;
|
|
3383
3143
|
const out = new Float32Array(n);
|
|
3384
3144
|
const density = _nullishCoalesce(mask.density, () => ( 1));
|
|
@@ -3398,7 +3158,7 @@ var RasterCompositor = (_class = class {
|
|
|
3398
3158
|
for (let x = x0; x < x1; x++) out[d + x] = plane.data[s + x];
|
|
3399
3159
|
}
|
|
3400
3160
|
} else {
|
|
3401
|
-
const bytes =
|
|
3161
|
+
const bytes = _chunk7ISPWEJAcjs.readRegion.call(void 0, mask.surface, { x: r.x - ox, y: r.y - oy, width: r.width, height: r.height });
|
|
3402
3162
|
let all = true;
|
|
3403
3163
|
for (let i = 0; i < n; i++) {
|
|
3404
3164
|
out[i] = bytes[i] / 255;
|
|
@@ -3452,7 +3212,7 @@ var RasterCompositor = (_class = class {
|
|
|
3452
3212
|
return empty;
|
|
3453
3213
|
}
|
|
3454
3214
|
contentBlend(layer) {
|
|
3455
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
3215
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _71 => _71.profile, 'access', _72 => _72.contentBlend, 'optionalCall', _73 => _73(layer)]), () => ( layer.blend));
|
|
3456
3216
|
}
|
|
3457
3217
|
blendOnto(acc, src, empty, mode, alpha, coverage) {
|
|
3458
3218
|
if (!(alpha > 0)) return empty;
|
|
@@ -3506,14 +3266,14 @@ var RasterCompositor = (_class = class {
|
|
|
3506
3266
|
}
|
|
3507
3267
|
visible.push(node);
|
|
3508
3268
|
}
|
|
3509
|
-
if (visible.length) _optionalChain([this, 'access',
|
|
3269
|
+
if (visible.length) _optionalChain([this, 'access', _74 => _74.profile, 'access', _75 => _75.applyFilterRun, 'optionalCall', _76 => _76(visible, acc, r, masks, this.sources)]);
|
|
3510
3270
|
}
|
|
3511
3271
|
}, _class);
|
|
3512
3272
|
function filterOverCanvas(surface, ox, oy, filters, width, height) {
|
|
3513
|
-
if (width <= 0 || height <= 0) return
|
|
3514
|
-
const data =
|
|
3273
|
+
if (width <= 0 || height <= 0) return _chunk7ISPWEJAcjs.emptySurface.call(void 0, 4);
|
|
3274
|
+
const data = _chunk7ISPWEJAcjs.readRegion.call(void 0, surface, { x: -ox, y: -oy, width, height });
|
|
3515
3275
|
filters.apply(data, width, height);
|
|
3516
|
-
return
|
|
3276
|
+
return _chunk7ISPWEJAcjs.surfaceFromPixels.call(void 0, { width, height, data }, 4, 0, 0);
|
|
3517
3277
|
}
|
|
3518
3278
|
function copyRect(data, r, a) {
|
|
3519
3279
|
const out = new Uint8ClampedArray(a.width * a.height * 4);
|
|
@@ -3602,16 +3362,16 @@ function intersect(a, b) {
|
|
|
3602
3362
|
return x1 > x && y1 > y ? { x, y, width: x1 - x, height: y1 - y } : null;
|
|
3603
3363
|
}
|
|
3604
3364
|
function hasTilesIn(src, r) {
|
|
3605
|
-
for (const { tx, ty } of
|
|
3365
|
+
for (const { tx, ty } of _chunk7ISPWEJAcjs.tilesInRect.call(void 0, r)) if (src.getTile(tx, ty)) return true;
|
|
3606
3366
|
return false;
|
|
3607
3367
|
}
|
|
3608
|
-
function readWindow(src, srcRect, rect) {
|
|
3368
|
+
function readWindow(src, srcRect, rect, depth = null) {
|
|
3609
3369
|
const n = src.channels === 4 ? 4 : 2;
|
|
3610
3370
|
const data = new Float32Array(rect.width * rect.height * n);
|
|
3611
3371
|
const win = { x: rect.x, y: rect.y, w: rect.width, h: rect.height, n, data };
|
|
3612
3372
|
const r = intersect(rect, srcRect);
|
|
3613
3373
|
if (!r) return win;
|
|
3614
|
-
const px =
|
|
3374
|
+
const px = depth ? readScaled(src, r, depth) : _chunk7ISPWEJAcjs.readRegion.call(void 0, src, r);
|
|
3615
3375
|
for (let y = 0; y < r.height; y++) {
|
|
3616
3376
|
let s = y * r.width * src.channels;
|
|
3617
3377
|
let d = ((r.y - rect.y + y) * rect.width + (r.x - rect.x)) * n;
|
|
@@ -3745,7 +3505,44 @@ function store(out, o, acc, ch, def) {
|
|
|
3745
3505
|
out[o] = acc[0] + def * (1 - inside);
|
|
3746
3506
|
return true;
|
|
3747
3507
|
}
|
|
3748
|
-
function
|
|
3508
|
+
function resampleDepth(src, step) {
|
|
3509
|
+
if (src.channels !== 4 || src.defaultValue !== 0 || step !== 1) return null;
|
|
3510
|
+
const d = _chunk7ISPWEJAcjs.surfaceDepth.call(void 0, src);
|
|
3511
|
+
return d === 8 ? null : d;
|
|
3512
|
+
}
|
|
3513
|
+
function readScaled(src, rect, depth) {
|
|
3514
|
+
const d = _chunk7ISPWEJAcjs.readDeepRegion.call(void 0, src, rect, depth);
|
|
3515
|
+
const out = new Float32Array(d.length);
|
|
3516
|
+
const k = depth === 16 ? 1 / 257 : 255;
|
|
3517
|
+
for (let i = 0; i < d.length; i++) out[i] = d[i] * k;
|
|
3518
|
+
return out;
|
|
3519
|
+
}
|
|
3520
|
+
function fromScaled(v, depth) {
|
|
3521
|
+
if (depth === 16) {
|
|
3522
|
+
const out2 = new Uint16Array(v.length);
|
|
3523
|
+
for (let i = 0; i < v.length; i++) {
|
|
3524
|
+
const x = Math.round(v[i] * 257);
|
|
3525
|
+
out2[i] = x <= 0 ? 0 : x >= 65535 ? 65535 : x;
|
|
3526
|
+
}
|
|
3527
|
+
return out2;
|
|
3528
|
+
}
|
|
3529
|
+
const out = new Float32Array(v.length);
|
|
3530
|
+
for (let i = 0; i < v.length; i++) {
|
|
3531
|
+
const x = v[i] / 255;
|
|
3532
|
+
out[i] = (i & 3) === 3 ? x <= 0 ? 0 : x >= 1 ? 1 : x : x;
|
|
3533
|
+
}
|
|
3534
|
+
return out;
|
|
3535
|
+
}
|
|
3536
|
+
function storeScaled(out, o, acc) {
|
|
3537
|
+
const al = acc[3] > 1 ? 1 : acc[3];
|
|
3538
|
+
if (!(al > 1e-6)) return false;
|
|
3539
|
+
out[o] = acc[0] / al;
|
|
3540
|
+
out[o + 1] = acc[1] / al;
|
|
3541
|
+
out[o + 2] = acc[2] / al;
|
|
3542
|
+
out[o + 3] = al * 255;
|
|
3543
|
+
return true;
|
|
3544
|
+
}
|
|
3545
|
+
function boxReduce(src, srcRect, kx, ky, depth = null) {
|
|
3749
3546
|
const ch = src.channels;
|
|
3750
3547
|
const rx0 = Math.floor(srcRect.x / kx);
|
|
3751
3548
|
const ry0 = Math.floor(srcRect.y / ky);
|
|
@@ -3753,14 +3550,14 @@ function boxReduce(src, srcRect, kx, ky) {
|
|
|
3753
3550
|
const ry1 = Math.ceil((srcRect.y + srcRect.height) / ky);
|
|
3754
3551
|
const rw = rx1 - rx0;
|
|
3755
3552
|
const rect = { x: rx0, y: ry0, width: rw, height: ry1 - ry0 };
|
|
3756
|
-
let out =
|
|
3757
|
-
const rowsPer = Math.max(1, Math.floor(
|
|
3553
|
+
let out = _chunk7ISPWEJAcjs.emptySurface.call(void 0, ch, src.defaultValue);
|
|
3554
|
+
const rowsPer = Math.max(1, Math.floor(_chunk7ISPWEJAcjs.TILE / ky));
|
|
3758
3555
|
const area = kx * ky;
|
|
3759
3556
|
for (let ry = ry0; ry < ry1; ry += rowsPer) {
|
|
3760
3557
|
const rows = Math.min(rowsPer, ry1 - ry);
|
|
3761
3558
|
const strip = { x: rx0 * kx, y: ry * ky, width: rw * kx, height: rows * ky };
|
|
3762
|
-
const px =
|
|
3763
|
-
const red = new Uint8ClampedArray(rw * rows * ch);
|
|
3559
|
+
const px = depth ? readScaled(src, strip, depth) : _chunk7ISPWEJAcjs.readRegion.call(void 0, src, strip);
|
|
3560
|
+
const red = depth ? new Float32Array(rw * rows * ch) : new Uint8ClampedArray(rw * rows * ch);
|
|
3764
3561
|
for (let j = 0; j < rows; j++) {
|
|
3765
3562
|
for (let i = 0; i < rw; i++) {
|
|
3766
3563
|
if (ch === 4) {
|
|
@@ -3795,13 +3592,14 @@ function boxReduce(src, srcRect, kx, ky) {
|
|
|
3795
3592
|
}
|
|
3796
3593
|
}
|
|
3797
3594
|
}
|
|
3798
|
-
|
|
3595
|
+
const region = { x: rx0, y: ry, width: rw, height: rows };
|
|
3596
|
+
out = depth ? _chunk7ISPWEJAcjs.writeDeepRegion.call(void 0, out, region, fromScaled(red, depth)) : _chunk7ISPWEJAcjs.writeRegion.call(void 0, out, region, red);
|
|
3799
3597
|
}
|
|
3800
3598
|
return { surface: out, rect };
|
|
3801
3599
|
}
|
|
3802
3600
|
function reduceSurface(src, factor) {
|
|
3803
3601
|
const k = Math.max(1, Math.floor(factor));
|
|
3804
|
-
const b =
|
|
3602
|
+
const b = _chunk7ISPWEJAcjs.contentBounds.call(void 0, src);
|
|
3805
3603
|
if (k === 1 || !b) return src;
|
|
3806
3604
|
return boxReduce(src, b, k, k).surface;
|
|
3807
3605
|
}
|
|
@@ -3829,47 +3627,54 @@ function checkBudget(dst, what = "result") {
|
|
|
3829
3627
|
}
|
|
3830
3628
|
}
|
|
3831
3629
|
function assemble(src, tiles) {
|
|
3832
|
-
return new (0,
|
|
3630
|
+
return new (0, _chunk7ISPWEJAcjs.TiledSurface)(src.channels, tiles, src.defaultValue);
|
|
3833
3631
|
}
|
|
3834
3632
|
function transformedBounds(source, h) {
|
|
3835
|
-
if (!(source.width > 0 && source.height > 0) || !
|
|
3836
|
-
const pts =
|
|
3633
|
+
if (!(source.width > 0 && source.height > 0) || !_chunkEJVDBITDcjs.invertHomography.call(void 0, h)) return null;
|
|
3634
|
+
const pts = _chunkEJVDBITDcjs.boxQuad.call(void 0, source).map((p) => _chunkEJVDBITDcjs.applyHomography.call(void 0, h, p));
|
|
3837
3635
|
if (pts.some((p) => !p)) return null;
|
|
3838
|
-
return
|
|
3636
|
+
return _chunkEJVDBITDcjs.cornerBounds.call(void 0, pts);
|
|
3839
3637
|
}
|
|
3840
3638
|
function transformSurface(src, h, options = {}) {
|
|
3841
3639
|
const interp = _nullishCoalesce(options.interpolation, () => ( "bicubic"));
|
|
3842
3640
|
const ch = src.channels;
|
|
3843
3641
|
const def = src.defaultValue;
|
|
3844
|
-
const empty =
|
|
3642
|
+
const empty = _chunk7ISPWEJAcjs.emptySurface.call(void 0, ch, def);
|
|
3845
3643
|
const given = options.source;
|
|
3846
3644
|
const step = normalizeStep(options.step);
|
|
3847
|
-
|
|
3645
|
+
const depth = resampleDepth(src, step);
|
|
3646
|
+
if (_chunkEJVDBITDcjs.isIdentityHomography.call(void 0, h, 1e-12) && !given && !options.clip) return src;
|
|
3848
3647
|
const dx = h[2] / h[8];
|
|
3849
3648
|
const dy = h[5] / h[8];
|
|
3850
|
-
if (!given && !options.clip &&
|
|
3851
|
-
|
|
3649
|
+
if (!given && !options.clip && _chunkEJVDBITDcjs.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) {
|
|
3650
|
+
const mx = Math.round(dx);
|
|
3651
|
+
const my = Math.round(dy);
|
|
3652
|
+
const b = src.bounds;
|
|
3653
|
+
if (depth && b && (mx % _chunk7ISPWEJAcjs.TILE !== 0 || my % _chunk7ISPWEJAcjs.TILE !== 0)) {
|
|
3654
|
+
return _chunk7ISPWEJAcjs.writeDeepRegion.call(void 0, _chunk7ISPWEJAcjs.emptySurface.call(void 0, ch, def), { ...b, x: b.x + mx, y: b.y + my }, _chunk7ISPWEJAcjs.readDeepRegion.call(void 0, src, b, depth));
|
|
3655
|
+
}
|
|
3656
|
+
return _chunk7ISPWEJAcjs.translateSurface.call(void 0, src, mx, my);
|
|
3852
3657
|
}
|
|
3853
|
-
let srcRect = given ? intersect(given, given) :
|
|
3658
|
+
let srcRect = given ? intersect(given, given) : _chunk7ISPWEJAcjs.contentBounds.call(void 0, src);
|
|
3854
3659
|
if (!srcRect) return empty;
|
|
3855
3660
|
let H = h;
|
|
3856
3661
|
let S = src;
|
|
3857
3662
|
if (interp === "bicubic") {
|
|
3858
|
-
const inv0 =
|
|
3859
|
-
const c =
|
|
3663
|
+
const inv0 = _chunkEJVDBITDcjs.invertHomography.call(void 0, H);
|
|
3664
|
+
const c = _chunkEJVDBITDcjs.applyHomography.call(void 0, H, { x: srcRect.x + srcRect.width / 2, y: srcRect.y + srcRect.height / 2 });
|
|
3860
3665
|
if (inv0 && c) {
|
|
3861
3666
|
const [su, sv] = inverseStretch(inv0, c.x, c.y);
|
|
3862
3667
|
const kx = reduction(su);
|
|
3863
3668
|
const ky = reduction(sv);
|
|
3864
3669
|
if (kx > 1 || ky > 1) {
|
|
3865
|
-
const red = boxReduce(src, srcRect, kx, ky);
|
|
3670
|
+
const red = boxReduce(src, srcRect, kx, ky, depth);
|
|
3866
3671
|
S = red.surface;
|
|
3867
3672
|
srcRect = red.rect;
|
|
3868
|
-
H =
|
|
3673
|
+
H = _chunkEJVDBITDcjs.multiplyHomographies.call(void 0, [kx, 0, 0, 0, ky, 0, 0, 0, 1], H);
|
|
3869
3674
|
}
|
|
3870
3675
|
}
|
|
3871
3676
|
}
|
|
3872
|
-
const inv =
|
|
3677
|
+
const inv = _chunkEJVDBITDcjs.invertHomography.call(void 0, H);
|
|
3873
3678
|
if (!inv) return empty;
|
|
3874
3679
|
const sr = srcRect;
|
|
3875
3680
|
const fwd = [
|
|
@@ -3877,12 +3682,12 @@ function transformSurface(src, h, options = {}) {
|
|
|
3877
3682
|
{ x: sr.x + sr.width + 1, y: sr.y - 1 },
|
|
3878
3683
|
{ x: sr.x + sr.width + 1, y: sr.y + sr.height + 1 },
|
|
3879
3684
|
{ x: sr.x - 1, y: sr.y + sr.height + 1 }
|
|
3880
|
-
].map((p) =>
|
|
3685
|
+
].map((p) => _chunkEJVDBITDcjs.homographyW.call(void 0, H, p));
|
|
3881
3686
|
const side = fwd.every((w) => w > 0) ? 1 : fwd.every((w) => w < 0) ? -1 : 0;
|
|
3882
3687
|
const wLo = 1 / fwd.reduce((m, w) => Math.max(m, Math.abs(w)), 0);
|
|
3883
|
-
const front = side === 0 ?
|
|
3884
|
-
const corners =
|
|
3885
|
-
const bounds = corners.every(Boolean) ?
|
|
3688
|
+
const front = side === 0 ? _chunkEJVDBITDcjs.homographyFrontSide.call(void 0, H, sr) : 0;
|
|
3689
|
+
const corners = _chunkEJVDBITDcjs.boxQuad.call(void 0, sr).map((p) => _chunkEJVDBITDcjs.applyHomography.call(void 0, H, p));
|
|
3690
|
+
const bounds = corners.every(Boolean) ? _chunkEJVDBITDcjs.cornerBounds.call(void 0, corners) : null;
|
|
3886
3691
|
let dst;
|
|
3887
3692
|
if (options.clip && bounds && side !== 0) dst = intersect(bounds, options.clip);
|
|
3888
3693
|
else dst = _nullishCoalesce(options.clip, () => ( bounds));
|
|
@@ -3900,8 +3705,8 @@ function transformSurface(src, h, options = {}) {
|
|
|
3900
3705
|
const sy0 = sr.y;
|
|
3901
3706
|
const sx1 = sr.x + sr.width - 1;
|
|
3902
3707
|
const sy1 = sr.y + sr.height - 1;
|
|
3903
|
-
for (const { tx, ty } of
|
|
3904
|
-
const t = intersect({ x: tx *
|
|
3708
|
+
for (const { tx, ty } of _chunk7ISPWEJAcjs.tilesInRect.call(void 0, dst)) {
|
|
3709
|
+
const t = intersect({ x: tx * _chunk7ISPWEJAcjs.TILE, y: ty * _chunk7ISPWEJAcjs.TILE, width: _chunk7ISPWEJAcjs.TILE, height: _chunk7ISPWEJAcjs.TILE }, dst);
|
|
3905
3710
|
if (!t) continue;
|
|
3906
3711
|
const tc = [
|
|
3907
3712
|
{ x: t.x, y: t.y },
|
|
@@ -3909,7 +3714,7 @@ function transformSurface(src, h, options = {}) {
|
|
|
3909
3714
|
{ x: t.x + t.width, y: t.y + t.height },
|
|
3910
3715
|
{ x: t.x, y: t.y + t.height }
|
|
3911
3716
|
];
|
|
3912
|
-
const wc = tc.map((p) =>
|
|
3717
|
+
const wc = tc.map((p) => _chunkEJVDBITDcjs.homographyW.call(void 0, inv, p));
|
|
3913
3718
|
let poly = tc;
|
|
3914
3719
|
if (side !== 0) {
|
|
3915
3720
|
const dd = wc.map((w) => side * w - wLo);
|
|
@@ -3931,7 +3736,7 @@ function transformSurface(src, h, options = {}) {
|
|
|
3931
3736
|
let foot;
|
|
3932
3737
|
if (straddles) foot = sr;
|
|
3933
3738
|
else {
|
|
3934
|
-
const fp = poly.map((p) =>
|
|
3739
|
+
const fp = poly.map((p) => _chunkEJVDBITDcjs.applyHomography.call(void 0, inv, p));
|
|
3935
3740
|
if (fp.some((p) => !p)) foot = sr;
|
|
3936
3741
|
else {
|
|
3937
3742
|
const xs = fp.map((p) => p.x);
|
|
@@ -3946,12 +3751,13 @@ function transformSurface(src, h, options = {}) {
|
|
|
3946
3751
|
if (!foot) continue;
|
|
3947
3752
|
const readable = intersect(foot, sr);
|
|
3948
3753
|
if (!readable || !hasTilesIn(S, readable)) continue;
|
|
3949
|
-
const win = readWindow(S, sr, foot);
|
|
3950
|
-
const out = new Uint8ClampedArray(
|
|
3754
|
+
const win = readWindow(S, sr, foot, depth);
|
|
3755
|
+
const out = new Uint8ClampedArray(_chunk7ISPWEJAcjs.TILE * _chunk7ISPWEJAcjs.TILE * ch);
|
|
3951
3756
|
if (def) out.fill(def);
|
|
3757
|
+
const deepOut = depth ? new Float32Array(_chunk7ISPWEJAcjs.TILE * _chunk7ISPWEJAcjs.TILE * 4) : null;
|
|
3952
3758
|
let any = false;
|
|
3953
|
-
const ox = tx *
|
|
3954
|
-
const oy = ty *
|
|
3759
|
+
const ox = tx * _chunk7ISPWEJAcjs.TILE;
|
|
3760
|
+
const oy = ty * _chunk7ISPWEJAcjs.TILE;
|
|
3955
3761
|
let su = widen(su0);
|
|
3956
3762
|
let sv = widen(sv0);
|
|
3957
3763
|
const ystart = t.y - ((t.y - oy) % step + step) % step;
|
|
@@ -3977,6 +3783,10 @@ function transformSurface(src, h, options = {}) {
|
|
|
3977
3783
|
sv = widen(s[1]);
|
|
3978
3784
|
}
|
|
3979
3785
|
sample(win, interp, u, v, su, sv, acc);
|
|
3786
|
+
if (deepOut) {
|
|
3787
|
+
if (storeScaled(deepOut, ((y - oy) * _chunk7ISPWEJAcjs.TILE + (x - ox)) * 4, acc)) any = true;
|
|
3788
|
+
continue;
|
|
3789
|
+
}
|
|
3980
3790
|
if (!store(scratch, 0, acc, ch, def)) continue;
|
|
3981
3791
|
rowSet[bi] = 1;
|
|
3982
3792
|
rowVals[bi] = ch === 4 ? scratchWord[0] : scratch[0];
|
|
@@ -3987,7 +3797,7 @@ function transformSurface(src, h, options = {}) {
|
|
|
3987
3797
|
const y0 = Math.max(y, t.y);
|
|
3988
3798
|
const y1 = Math.min(y + step, t.y + t.height);
|
|
3989
3799
|
for (let yy = y0; yy < y1; yy++) {
|
|
3990
|
-
const row = (yy - oy) *
|
|
3800
|
+
const row = (yy - oy) * _chunk7ISPWEJAcjs.TILE - ox;
|
|
3991
3801
|
for (let bi = 0, x = xstart; bi < blocks; bi++, x += step) {
|
|
3992
3802
|
if (!rowSet[bi]) continue;
|
|
3993
3803
|
const x0 = Math.max(x, t.x);
|
|
@@ -3999,8 +3809,8 @@ function transformSurface(src, h, options = {}) {
|
|
|
3999
3809
|
}
|
|
4000
3810
|
}
|
|
4001
3811
|
if (!any) continue;
|
|
4002
|
-
const tile =
|
|
4003
|
-
if (tile) tiles.set(
|
|
3812
|
+
const tile = deepOut ? _chunk7ISPWEJAcjs.deepTile.call(void 0, fromScaled(deepOut, depth), 4, def) : _chunk7ISPWEJAcjs.finishTile.call(void 0, out, ch, def);
|
|
3813
|
+
if (tile) tiles.set(_chunk7ISPWEJAcjs.tileKey.call(void 0, tx, ty), tile);
|
|
4004
3814
|
}
|
|
4005
3815
|
return assemble(src, tiles);
|
|
4006
3816
|
}
|
|
@@ -4011,10 +3821,11 @@ function warpSurface(src, f, options = {}) {
|
|
|
4011
3821
|
const interp = _nullishCoalesce(options.interpolation, () => ( "bicubic"));
|
|
4012
3822
|
const ch = src.channels;
|
|
4013
3823
|
const def = src.defaultValue;
|
|
4014
|
-
const empty =
|
|
4015
|
-
const sr = options.source ? intersect(options.source, options.source) :
|
|
3824
|
+
const empty = _chunk7ISPWEJAcjs.emptySurface.call(void 0, ch, def);
|
|
3825
|
+
const sr = options.source ? intersect(options.source, options.source) : _chunk7ISPWEJAcjs.contentBounds.call(void 0, src);
|
|
4016
3826
|
if (!sr) return empty;
|
|
4017
3827
|
const step = normalizeStep(options.step);
|
|
3828
|
+
const depth = resampleDepth(src, step);
|
|
4018
3829
|
const nx = Math.min(MAX_CELLS, Math.max(1, Math.ceil(sr.width / CELL)));
|
|
4019
3830
|
const ny = Math.min(MAX_CELLS, Math.max(1, Math.ceil(sr.height / CELL)));
|
|
4020
3831
|
const w1 = nx + 1;
|
|
@@ -4063,10 +3874,10 @@ function warpSurface(src, f, options = {}) {
|
|
|
4063
3874
|
tris[t++] = a + w1;
|
|
4064
3875
|
}
|
|
4065
3876
|
}
|
|
4066
|
-
const tx0 = Math.floor(dst.x /
|
|
4067
|
-
const ty0 = Math.floor(dst.y /
|
|
4068
|
-
const cols = Math.floor((dst.x + dst.width - 1) /
|
|
4069
|
-
const rows = Math.floor((dst.y + dst.height - 1) /
|
|
3877
|
+
const tx0 = Math.floor(dst.x / _chunk7ISPWEJAcjs.TILE);
|
|
3878
|
+
const ty0 = Math.floor(dst.y / _chunk7ISPWEJAcjs.TILE);
|
|
3879
|
+
const cols = Math.floor((dst.x + dst.width - 1) / _chunk7ISPWEJAcjs.TILE) - tx0 + 1;
|
|
3880
|
+
const rows = Math.floor((dst.y + dst.height - 1) / _chunk7ISPWEJAcjs.TILE) - ty0 + 1;
|
|
4070
3881
|
const bins = Array.from({ length: cols * rows }, () => []);
|
|
4071
3882
|
for (let k = 0; k < triCount; k++) {
|
|
4072
3883
|
const a = tris[3 * k];
|
|
@@ -4076,10 +3887,10 @@ function warpSurface(src, f, options = {}) {
|
|
|
4076
3887
|
const tminy = Math.floor(Math.min(dvy[a], dvy[b], dvy[c]));
|
|
4077
3888
|
const tmaxx = Math.ceil(Math.max(dvx[a], dvx[b], dvx[c]));
|
|
4078
3889
|
const tmaxy = Math.ceil(Math.max(dvy[a], dvy[b], dvy[c]));
|
|
4079
|
-
const cx0 = Math.max(0, Math.floor(Math.max(tminx, dst.x) /
|
|
4080
|
-
const cy0 = Math.max(0, Math.floor(Math.max(tminy, dst.y) /
|
|
4081
|
-
const cx1 = Math.min(cols - 1, Math.floor(Math.min(tmaxx, dst.x + dst.width - 1) /
|
|
4082
|
-
const cy1 = Math.min(rows - 1, Math.floor(Math.min(tmaxy, dst.y + dst.height - 1) /
|
|
3890
|
+
const cx0 = Math.max(0, Math.floor(Math.max(tminx, dst.x) / _chunk7ISPWEJAcjs.TILE) - tx0);
|
|
3891
|
+
const cy0 = Math.max(0, Math.floor(Math.max(tminy, dst.y) / _chunk7ISPWEJAcjs.TILE) - ty0);
|
|
3892
|
+
const cx1 = Math.min(cols - 1, Math.floor(Math.min(tmaxx, dst.x + dst.width - 1) / _chunk7ISPWEJAcjs.TILE) - tx0);
|
|
3893
|
+
const cy1 = Math.min(rows - 1, Math.floor(Math.min(tmaxy, dst.y + dst.height - 1) / _chunk7ISPWEJAcjs.TILE) - ty0);
|
|
4083
3894
|
for (let cy = cy0; cy <= cy1; cy++) for (let cx = cx0; cx <= cx1; cx++) bins[cy * cols + cx].push(k);
|
|
4084
3895
|
}
|
|
4085
3896
|
const tiles = /* @__PURE__ */ new Map();
|
|
@@ -4093,7 +3904,7 @@ function warpSurface(src, f, options = {}) {
|
|
|
4093
3904
|
if (!list.length) continue;
|
|
4094
3905
|
const ttx = tx0 + cx;
|
|
4095
3906
|
const tty = ty0 + cy;
|
|
4096
|
-
const t = intersect({ x: ttx *
|
|
3907
|
+
const t = intersect({ x: ttx * _chunk7ISPWEJAcjs.TILE, y: tty * _chunk7ISPWEJAcjs.TILE, width: _chunk7ISPWEJAcjs.TILE, height: _chunk7ISPWEJAcjs.TILE }, dst);
|
|
4097
3908
|
if (!t) continue;
|
|
4098
3909
|
const tw = t.width;
|
|
4099
3910
|
const th = t.height;
|
|
@@ -4182,12 +3993,13 @@ function warpSurface(src, f, options = {}) {
|
|
|
4182
3993
|
if (fx0 > fx1) continue;
|
|
4183
3994
|
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);
|
|
4184
3995
|
if (!foot || !hasTilesIn(src, foot)) continue;
|
|
4185
|
-
const win = readWindow(src, sr, foot);
|
|
4186
|
-
const out = new Uint8ClampedArray(
|
|
3996
|
+
const win = readWindow(src, sr, foot, depth);
|
|
3997
|
+
const out = new Uint8ClampedArray(_chunk7ISPWEJAcjs.TILE * _chunk7ISPWEJAcjs.TILE * ch);
|
|
4187
3998
|
if (def) out.fill(def);
|
|
3999
|
+
const deepOut = depth ? new Float32Array(_chunk7ISPWEJAcjs.TILE * _chunk7ISPWEJAcjs.TILE * 4) : null;
|
|
4188
4000
|
let any = false;
|
|
4189
|
-
const ox = ttx *
|
|
4190
|
-
const oy = tty *
|
|
4001
|
+
const ox = ttx * _chunk7ISPWEJAcjs.TILE;
|
|
4002
|
+
const oy = tty * _chunk7ISPWEJAcjs.TILE;
|
|
4191
4003
|
const pointAt = (o, into) => {
|
|
4192
4004
|
const li = owner[o];
|
|
4193
4005
|
const cnx = ssx[li];
|
|
@@ -4218,7 +4030,8 @@ function warpSurface(src, f, options = {}) {
|
|
|
4218
4030
|
pointAt(o, acc);
|
|
4219
4031
|
const x = t.x + o % tw;
|
|
4220
4032
|
const y = t.y + Math.floor(o / tw);
|
|
4221
|
-
|
|
4033
|
+
const o4 = ((y - oy) * _chunk7ISPWEJAcjs.TILE + (x - ox)) * ch;
|
|
4034
|
+
if (deepOut ? storeScaled(deepOut, o4, acc) : store(out, o4, acc, ch, def)) any = true;
|
|
4222
4035
|
}
|
|
4223
4036
|
} else {
|
|
4224
4037
|
for (let by = 0; by < th; by += step) {
|
|
@@ -4226,19 +4039,19 @@ function warpSurface(src, f, options = {}) {
|
|
|
4226
4039
|
const o = by * tw + bx;
|
|
4227
4040
|
if (Number.isNaN(us[o])) continue;
|
|
4228
4041
|
pointAt(o, acc);
|
|
4229
|
-
const first = ((t.y + by - oy) *
|
|
4042
|
+
const first = ((t.y + by - oy) * _chunk7ISPWEJAcjs.TILE + (t.x + bx - ox)) * ch;
|
|
4230
4043
|
if (!store(out, first, acc, ch, def)) continue;
|
|
4231
4044
|
any = true;
|
|
4232
4045
|
for (let yy = by; yy < Math.min(th, by + step); yy++) {
|
|
4233
|
-
const row = ((t.y + yy - oy) *
|
|
4046
|
+
const row = ((t.y + yy - oy) * _chunk7ISPWEJAcjs.TILE + (t.x - ox)) * ch;
|
|
4234
4047
|
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];
|
|
4235
4048
|
}
|
|
4236
4049
|
}
|
|
4237
4050
|
}
|
|
4238
4051
|
}
|
|
4239
4052
|
if (!any) continue;
|
|
4240
|
-
const tile =
|
|
4241
|
-
if (tile) tiles.set(
|
|
4053
|
+
const tile = deepOut ? _chunk7ISPWEJAcjs.deepTile.call(void 0, fromScaled(deepOut, depth), 4, def) : _chunk7ISPWEJAcjs.finishTile.call(void 0, out, ch, def);
|
|
4054
|
+
if (tile) tiles.set(_chunk7ISPWEJAcjs.tileKey.call(void 0, ttx, tty), tile);
|
|
4242
4055
|
}
|
|
4243
4056
|
}
|
|
4244
4057
|
return assemble(src, tiles);
|
|
@@ -4248,13 +4061,35 @@ function compositeSurfaceOver(base, top) {
|
|
|
4248
4061
|
if (!top.tiles.size) return base;
|
|
4249
4062
|
const ch = base.channels;
|
|
4250
4063
|
const tiles = new Map(base.tiles);
|
|
4064
|
+
const bd = ch === 4 && base.defaultValue === 0 ? Math.max(_chunk7ISPWEJAcjs.surfaceDepth.call(void 0, base), _chunk7ISPWEJAcjs.surfaceDepth.call(void 0, top)) : 8;
|
|
4065
|
+
const depth = bd === 8 ? null : bd;
|
|
4251
4066
|
for (const [key, t] of top.tiles) {
|
|
4252
4067
|
const under = base.tiles.get(key);
|
|
4253
4068
|
if (!under && ch === 4) {
|
|
4254
4069
|
tiles.set(key, t);
|
|
4255
4070
|
continue;
|
|
4256
4071
|
}
|
|
4257
|
-
|
|
4072
|
+
if (depth) {
|
|
4073
|
+
const k = depth === 16 ? 65535 : 1;
|
|
4074
|
+
const d2 = _chunk7ISPWEJAcjs.tileSamples.call(void 0, under, 4, depth, 0).slice();
|
|
4075
|
+
const sd = _chunk7ISPWEJAcjs.tileSamples.call(void 0, t, 4, depth, 0);
|
|
4076
|
+
for (let i = 0; i < d2.length; i += 4) {
|
|
4077
|
+
const ta = Math.min(1, sd[i + 3] / k);
|
|
4078
|
+
if (ta <= 0) continue;
|
|
4079
|
+
const da = d2[i + 3] / k;
|
|
4080
|
+
const oa = ta + da * (1 - ta);
|
|
4081
|
+
for (let c = 0; c < 3; c++) {
|
|
4082
|
+
const v = (sd[i + c] * ta + d2[i + c] * da * (1 - ta)) / oa;
|
|
4083
|
+
d2[i + c] = depth === 16 ? Math.round(v) : v;
|
|
4084
|
+
}
|
|
4085
|
+
d2[i + 3] = depth === 16 ? Math.round(oa * k) : oa;
|
|
4086
|
+
}
|
|
4087
|
+
const tile2 = _chunk7ISPWEJAcjs.deepTile.call(void 0, d2, 4, 0);
|
|
4088
|
+
if (tile2) tiles.set(key, tile2);
|
|
4089
|
+
else tiles.delete(key);
|
|
4090
|
+
continue;
|
|
4091
|
+
}
|
|
4092
|
+
const d = new Uint8ClampedArray(_chunk7ISPWEJAcjs.TILE * _chunk7ISPWEJAcjs.TILE * ch);
|
|
4258
4093
|
if (under) d.set(under.data);
|
|
4259
4094
|
else if (base.defaultValue) d.fill(base.defaultValue);
|
|
4260
4095
|
const s = t.data;
|
|
@@ -4280,349 +4115,12 @@ function compositeSurfaceOver(base, top) {
|
|
|
4280
4115
|
if (ta > 0) d[p] = s[i] * ta + d[p] * (1 - ta);
|
|
4281
4116
|
}
|
|
4282
4117
|
}
|
|
4283
|
-
const tile =
|
|
4118
|
+
const tile = _chunk7ISPWEJAcjs.finishTile.call(void 0, d, ch, base.defaultValue);
|
|
4284
4119
|
if (tile) tiles.set(key, tile);
|
|
4285
4120
|
else tiles.delete(key);
|
|
4286
4121
|
}
|
|
4287
|
-
return new (0,
|
|
4288
|
-
}
|
|
4289
|
-
|
|
4290
|
-
// src/raster/png.ts
|
|
4291
|
-
var SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
4292
|
-
var crcTable = null;
|
|
4293
|
-
function crc32(bytes, start, end) {
|
|
4294
|
-
if (!crcTable) {
|
|
4295
|
-
crcTable = new Uint32Array(256);
|
|
4296
|
-
for (let n = 0; n < 256; n++) {
|
|
4297
|
-
let c2 = n;
|
|
4298
|
-
for (let k = 0; k < 8; k++) c2 = c2 & 1 ? 3988292384 ^ c2 >>> 1 : c2 >>> 1;
|
|
4299
|
-
crcTable[n] = c2 >>> 0;
|
|
4300
|
-
}
|
|
4301
|
-
}
|
|
4302
|
-
let c = 4294967295;
|
|
4303
|
-
for (let i = start; i < end; i++) c = crcTable[(c ^ bytes[i]) & 255] ^ c >>> 8;
|
|
4304
|
-
return (c ^ 4294967295) >>> 0;
|
|
4305
|
-
}
|
|
4306
|
-
function paeth(a, b, c) {
|
|
4307
|
-
const p = a + b - c;
|
|
4308
|
-
const pa = Math.abs(p - a);
|
|
4309
|
-
const pb = Math.abs(p - b);
|
|
4310
|
-
const pc = Math.abs(p - c);
|
|
4311
|
-
return pa <= pb && pa <= pc ? a : pb <= pc ? b : c;
|
|
4312
|
-
}
|
|
4313
|
-
function encodePng(width, height, data, channels = 4) {
|
|
4314
|
-
const stride = width * channels;
|
|
4315
|
-
const raw = new Uint8Array((stride + 1) * height);
|
|
4316
|
-
const bpp = channels;
|
|
4317
|
-
const cand = [new Uint8Array(stride), new Uint8Array(stride), new Uint8Array(stride), new Uint8Array(stride), new Uint8Array(stride)];
|
|
4318
|
-
for (let y = 0; y < height; y++) {
|
|
4319
|
-
const row = y * stride;
|
|
4320
|
-
const prevRow = (y - 1) * stride;
|
|
4321
|
-
let best = 0;
|
|
4322
|
-
let bestScore = Infinity;
|
|
4323
|
-
for (let f = 0; f < 5; f++) {
|
|
4324
|
-
const out2 = cand[f];
|
|
4325
|
-
let score = 0;
|
|
4326
|
-
for (let x = 0; x < stride; x++) {
|
|
4327
|
-
const v = data[row + x];
|
|
4328
|
-
const a = x >= bpp ? data[row + x - bpp] : 0;
|
|
4329
|
-
const b = y > 0 ? data[prevRow + x] : 0;
|
|
4330
|
-
const c = x >= bpp && y > 0 ? data[prevRow + x - bpp] : 0;
|
|
4331
|
-
let r;
|
|
4332
|
-
switch (f) {
|
|
4333
|
-
case 0:
|
|
4334
|
-
r = v;
|
|
4335
|
-
break;
|
|
4336
|
-
case 1:
|
|
4337
|
-
r = v - a;
|
|
4338
|
-
break;
|
|
4339
|
-
case 2:
|
|
4340
|
-
r = v - b;
|
|
4341
|
-
break;
|
|
4342
|
-
case 3:
|
|
4343
|
-
r = v - (a + b >> 1);
|
|
4344
|
-
break;
|
|
4345
|
-
default:
|
|
4346
|
-
r = v - paeth(a, b, c);
|
|
4347
|
-
}
|
|
4348
|
-
r &= 255;
|
|
4349
|
-
out2[x] = r;
|
|
4350
|
-
score += r < 128 ? r : 256 - r;
|
|
4351
|
-
if (score >= bestScore) break;
|
|
4352
|
-
}
|
|
4353
|
-
if (score < bestScore) {
|
|
4354
|
-
bestScore = score;
|
|
4355
|
-
best = f;
|
|
4356
|
-
}
|
|
4357
|
-
}
|
|
4358
|
-
const o = y * (stride + 1);
|
|
4359
|
-
raw[o] = best;
|
|
4360
|
-
raw.set(cand[best], o + 1);
|
|
4361
|
-
}
|
|
4362
|
-
const idat = _chunk643B2HKCcjs.deflate.call(void 0, raw);
|
|
4363
|
-
const chunks = [];
|
|
4364
|
-
const ihdr = new Uint8Array(13);
|
|
4365
|
-
writeU32(ihdr, 0, width);
|
|
4366
|
-
writeU32(ihdr, 4, height);
|
|
4367
|
-
ihdr[8] = 8;
|
|
4368
|
-
ihdr[9] = channels === 1 ? 0 : 6;
|
|
4369
|
-
chunks.push(["IHDR", ihdr], ["IDAT", idat], ["IEND", new Uint8Array(0)]);
|
|
4370
|
-
let size = 8;
|
|
4371
|
-
for (const [, d] of chunks) size += 12 + d.length;
|
|
4372
|
-
const out = new Uint8Array(size);
|
|
4373
|
-
out.set(SIGNATURE, 0);
|
|
4374
|
-
let p = 8;
|
|
4375
|
-
for (const [type, d] of chunks) {
|
|
4376
|
-
writeU32(out, p, d.length);
|
|
4377
|
-
for (let i = 0; i < 4; i++) out[p + 4 + i] = type.charCodeAt(i);
|
|
4378
|
-
out.set(d, p + 8);
|
|
4379
|
-
writeU32(out, p + 8 + d.length, crc32(out, p + 4, p + 8 + d.length));
|
|
4380
|
-
p += 12 + d.length;
|
|
4381
|
-
}
|
|
4382
|
-
return out;
|
|
4122
|
+
return new (0, _chunk7ISPWEJAcjs.TiledSurface)(ch, tiles, base.defaultValue);
|
|
4383
4123
|
}
|
|
4384
|
-
function writeU32(b, o, v) {
|
|
4385
|
-
b[o] = v >>> 24;
|
|
4386
|
-
b[o + 1] = v >>> 16 & 255;
|
|
4387
|
-
b[o + 2] = v >>> 8 & 255;
|
|
4388
|
-
b[o + 3] = v & 255;
|
|
4389
|
-
}
|
|
4390
|
-
function readU32(b, o) {
|
|
4391
|
-
return (b[o] << 24 | b[o + 1] << 16 | b[o + 2] << 8 | b[o + 3]) >>> 0;
|
|
4392
|
-
}
|
|
4393
|
-
function isPng(bytes) {
|
|
4394
|
-
return bytes.length > 8 && SIGNATURE.every((v, i) => bytes[i] === v);
|
|
4395
|
-
}
|
|
4396
|
-
function decodePng(bytes, options = {}) {
|
|
4397
|
-
if (!isPng(bytes)) throw new Error("Not a PNG image.");
|
|
4398
|
-
let p = 8;
|
|
4399
|
-
let width = 0;
|
|
4400
|
-
let height = 0;
|
|
4401
|
-
let depth = 0;
|
|
4402
|
-
let type = 0;
|
|
4403
|
-
let interlace = 0;
|
|
4404
|
-
let palette = null;
|
|
4405
|
-
let trns = null;
|
|
4406
|
-
const idat = [];
|
|
4407
|
-
while (p + 8 <= bytes.length) {
|
|
4408
|
-
const len = readU32(bytes, p);
|
|
4409
|
-
const t = String.fromCharCode(bytes[p + 4], bytes[p + 5], bytes[p + 6], bytes[p + 7]);
|
|
4410
|
-
const body = bytes.subarray(p + 8, p + 8 + len);
|
|
4411
|
-
if (p + 12 + len > bytes.length) throw new Error("Truncated PNG.");
|
|
4412
|
-
if (t === "IHDR") {
|
|
4413
|
-
width = readU32(body, 0);
|
|
4414
|
-
height = readU32(body, 4);
|
|
4415
|
-
depth = body[8];
|
|
4416
|
-
type = body[9];
|
|
4417
|
-
interlace = body[12];
|
|
4418
|
-
} else if (t === "PLTE") palette = body;
|
|
4419
|
-
else if (t === "tRNS") trns = body;
|
|
4420
|
-
else if (t === "IDAT") idat.push(body);
|
|
4421
|
-
else if (t === "IEND") break;
|
|
4422
|
-
p += 12 + len;
|
|
4423
|
-
}
|
|
4424
|
-
if (!width || !height) throw new Error("PNG has no image header.");
|
|
4425
|
-
if (interlace) throw new Error("Interlaced PNGs are not supported here; decode them with a canvas.");
|
|
4426
|
-
const maxPixels = _nullishCoalesce(options.maxPixels, () => ( 1 << 28));
|
|
4427
|
-
if (width * height > maxPixels) throw new Error(`PNG is too large (${width}\xD7${height}).`);
|
|
4428
|
-
const samples = type === 0 ? 1 : type === 2 ? 3 : type === 3 ? 1 : type === 4 ? 2 : type === 6 ? 4 : 0;
|
|
4429
|
-
if (!samples || ![1, 2, 4, 8, 16].includes(depth)) throw new Error(`Unsupported PNG format (type ${type}, depth ${depth}).`);
|
|
4430
|
-
let total = 0;
|
|
4431
|
-
for (const c of idat) total += c.length;
|
|
4432
|
-
const z = new Uint8Array(total);
|
|
4433
|
-
let o = 0;
|
|
4434
|
-
for (const c of idat) {
|
|
4435
|
-
z.set(c, o);
|
|
4436
|
-
o += c.length;
|
|
4437
|
-
}
|
|
4438
|
-
const bitsPerPixel = samples * depth;
|
|
4439
|
-
const stride = Math.ceil(width * bitsPerPixel / 8);
|
|
4440
|
-
const raw = _chunk643B2HKCcjs.inflate.call(void 0, z, { maxOutput: (stride + 1) * height, sizeHint: (stride + 1) * height });
|
|
4441
|
-
if (raw.length < (stride + 1) * height) throw new Error("PNG image data is truncated.");
|
|
4442
|
-
const bpp = Math.max(1, bitsPerPixel >> 3);
|
|
4443
|
-
const lines = new Uint8Array(stride * height);
|
|
4444
|
-
for (let y = 0; y < height; y++) {
|
|
4445
|
-
const f = raw[y * (stride + 1)];
|
|
4446
|
-
const src = y * (stride + 1) + 1;
|
|
4447
|
-
const dst = y * stride;
|
|
4448
|
-
const up = dst - stride;
|
|
4449
|
-
for (let x = 0; x < stride; x++) {
|
|
4450
|
-
const v = raw[src + x];
|
|
4451
|
-
const a = x >= bpp ? lines[dst + x - bpp] : 0;
|
|
4452
|
-
const b = y > 0 ? lines[up + x] : 0;
|
|
4453
|
-
const c = x >= bpp && y > 0 ? lines[up + x - bpp] : 0;
|
|
4454
|
-
let r;
|
|
4455
|
-
switch (f) {
|
|
4456
|
-
case 0:
|
|
4457
|
-
r = v;
|
|
4458
|
-
break;
|
|
4459
|
-
case 1:
|
|
4460
|
-
r = v + a;
|
|
4461
|
-
break;
|
|
4462
|
-
case 2:
|
|
4463
|
-
r = v + b;
|
|
4464
|
-
break;
|
|
4465
|
-
case 3:
|
|
4466
|
-
r = v + (a + b >> 1);
|
|
4467
|
-
break;
|
|
4468
|
-
case 4:
|
|
4469
|
-
r = v + paeth(a, b, c);
|
|
4470
|
-
break;
|
|
4471
|
-
default:
|
|
4472
|
-
throw new Error(`Invalid PNG filter ${f}.`);
|
|
4473
|
-
}
|
|
4474
|
-
lines[dst + x] = r & 255;
|
|
4475
|
-
}
|
|
4476
|
-
}
|
|
4477
|
-
const sample2 = (y, i) => {
|
|
4478
|
-
const row = y * stride;
|
|
4479
|
-
if (depth === 8) return lines[row + i];
|
|
4480
|
-
if (depth === 16) return lines[row + i * 2];
|
|
4481
|
-
const perByte = 8 / depth;
|
|
4482
|
-
const byte = lines[row + Math.floor(i / perByte)];
|
|
4483
|
-
const shift = 8 - depth * (i % perByte + 1);
|
|
4484
|
-
const v = byte >> shift & (1 << depth) - 1;
|
|
4485
|
-
return type === 3 ? v : Math.round(v * 255 / ((1 << depth) - 1));
|
|
4486
|
-
};
|
|
4487
|
-
const gray = options.keepGray && type === 0 && !trns;
|
|
4488
|
-
const channels = gray ? 1 : 4;
|
|
4489
|
-
const out = new Uint8ClampedArray(width * height * channels);
|
|
4490
|
-
const trnsGray = trns && type === 0 ? depth === 16 ? trns[0] : sample16(trns, 0, depth) : -1;
|
|
4491
|
-
const trnsRgb = trns && type === 2 ? [0, 1, 2].map((k) => depth === 16 ? trns[k * 2] : sample16(trns, k, depth)) : null;
|
|
4492
|
-
for (let y = 0; y < height; y++) {
|
|
4493
|
-
for (let x = 0; x < width; x++) {
|
|
4494
|
-
const d = (y * width + x) * channels;
|
|
4495
|
-
if (type === 0) {
|
|
4496
|
-
const v = sample2(y, x);
|
|
4497
|
-
if (gray) out[d] = v;
|
|
4498
|
-
else {
|
|
4499
|
-
out[d] = out[d + 1] = out[d + 2] = v;
|
|
4500
|
-
out[d + 3] = v === trnsGray && trns ? 0 : 255;
|
|
4501
|
-
}
|
|
4502
|
-
} else if (type === 2) {
|
|
4503
|
-
const r = sample2(y, x * 3);
|
|
4504
|
-
const g = sample2(y, x * 3 + 1);
|
|
4505
|
-
const b = sample2(y, x * 3 + 2);
|
|
4506
|
-
out[d] = r;
|
|
4507
|
-
out[d + 1] = g;
|
|
4508
|
-
out[d + 2] = b;
|
|
4509
|
-
out[d + 3] = trnsRgb && r === trnsRgb[0] && g === trnsRgb[1] && b === trnsRgb[2] ? 0 : 255;
|
|
4510
|
-
} else if (type === 3) {
|
|
4511
|
-
const i = sample2(y, x);
|
|
4512
|
-
if (!palette || i * 3 + 2 >= palette.length) throw new Error("PNG palette index out of range.");
|
|
4513
|
-
out[d] = palette[i * 3];
|
|
4514
|
-
out[d + 1] = palette[i * 3 + 1];
|
|
4515
|
-
out[d + 2] = palette[i * 3 + 2];
|
|
4516
|
-
out[d + 3] = trns && i < trns.length ? trns[i] : 255;
|
|
4517
|
-
} else if (type === 4) {
|
|
4518
|
-
const v = sample2(y, x * 2);
|
|
4519
|
-
out[d] = out[d + 1] = out[d + 2] = v;
|
|
4520
|
-
out[d + 3] = sample2(y, x * 2 + 1);
|
|
4521
|
-
} else {
|
|
4522
|
-
out[d] = sample2(y, x * 4);
|
|
4523
|
-
out[d + 1] = sample2(y, x * 4 + 1);
|
|
4524
|
-
out[d + 2] = sample2(y, x * 4 + 2);
|
|
4525
|
-
out[d + 3] = sample2(y, x * 4 + 3);
|
|
4526
|
-
}
|
|
4527
|
-
}
|
|
4528
|
-
}
|
|
4529
|
-
return { width, height, channels, data: out };
|
|
4530
|
-
}
|
|
4531
|
-
function sample16(trns, k, depth) {
|
|
4532
|
-
const v = trns[k * 2] << 8 | trns[k * 2 + 1];
|
|
4533
|
-
if (depth === 8) return v & 255;
|
|
4534
|
-
return Math.round((v & (1 << depth) - 1) * 255 / ((1 << depth) - 1));
|
|
4535
|
-
}
|
|
4536
|
-
var B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
4537
|
-
var B64_INV = null;
|
|
4538
|
-
function bytesToBase64(bytes) {
|
|
4539
|
-
const parts = [];
|
|
4540
|
-
const CHUNK = 3 * 4096;
|
|
4541
|
-
for (let start = 0; start < bytes.length; start += CHUNK) {
|
|
4542
|
-
const end = Math.min(bytes.length, start + CHUNK);
|
|
4543
|
-
let s = "";
|
|
4544
|
-
let i = start;
|
|
4545
|
-
for (; i + 2 < end; i += 3) {
|
|
4546
|
-
const n = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2];
|
|
4547
|
-
s += B64[n >> 18] + B64[n >> 12 & 63] + B64[n >> 6 & 63] + B64[n & 63];
|
|
4548
|
-
}
|
|
4549
|
-
if (i < end) {
|
|
4550
|
-
const n = bytes[i] << 16 | (i + 1 < end ? bytes[i + 1] << 8 : 0);
|
|
4551
|
-
s += B64[n >> 18] + B64[n >> 12 & 63] + (i + 1 < end ? B64[n >> 6 & 63] : "=") + "=";
|
|
4552
|
-
}
|
|
4553
|
-
parts.push(s);
|
|
4554
|
-
}
|
|
4555
|
-
return parts.join("");
|
|
4556
|
-
}
|
|
4557
|
-
function base64ToBytes(text) {
|
|
4558
|
-
if (!B64_INV) {
|
|
4559
|
-
B64_INV = new Int16Array(128).fill(-1);
|
|
4560
|
-
for (let i = 0; i < 64; i++) B64_INV[B64.charCodeAt(i)] = i;
|
|
4561
|
-
B64_INV["-".charCodeAt(0)] = 62;
|
|
4562
|
-
B64_INV["_".charCodeAt(0)] = 63;
|
|
4563
|
-
}
|
|
4564
|
-
const inv = B64_INV;
|
|
4565
|
-
const clean = text.replace(/[\s=]/g, "");
|
|
4566
|
-
const out = new Uint8Array(Math.floor(clean.length * 3 / 4));
|
|
4567
|
-
let bits = 0;
|
|
4568
|
-
let acc = 0;
|
|
4569
|
-
let o = 0;
|
|
4570
|
-
for (let i = 0; i < clean.length; i++) {
|
|
4571
|
-
const c = clean.charCodeAt(i);
|
|
4572
|
-
const v = c < 128 ? inv[c] : -1;
|
|
4573
|
-
if (v < 0) throw new Error("Invalid base64 data.");
|
|
4574
|
-
acc = acc << 6 | v;
|
|
4575
|
-
bits += 6;
|
|
4576
|
-
if (bits >= 8) {
|
|
4577
|
-
bits -= 8;
|
|
4578
|
-
out[o++] = acc >> bits & 255;
|
|
4579
|
-
}
|
|
4580
|
-
}
|
|
4581
|
-
return out.subarray(0, o);
|
|
4582
|
-
}
|
|
4583
|
-
function parseDataUrl(url) {
|
|
4584
|
-
const m = /^data:([^;,]*)((?:;[^;,]*)*?),/i.exec(url);
|
|
4585
|
-
if (!m) return null;
|
|
4586
|
-
const body = url.slice(m[0].length);
|
|
4587
|
-
const isBase64 = /;base64/i.test(m[2]);
|
|
4588
|
-
if (isBase64) return { mime: m[1] || "text/plain", bytes: base64ToBytes(body) };
|
|
4589
|
-
const text = decodeURIComponent(body);
|
|
4590
|
-
const bytes = new Uint8Array(text.length);
|
|
4591
|
-
for (let i = 0; i < text.length; i++) bytes[i] = text.charCodeAt(i) & 255;
|
|
4592
|
-
return { mime: m[1] || "text/plain", bytes };
|
|
4593
|
-
}
|
|
4594
|
-
function pngDataUrl(width, height, data, channels = 4) {
|
|
4595
|
-
return `data:image/png;base64,${bytesToBase64(encodePng(width, height, data, channels))}`;
|
|
4596
|
-
}
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
4124
|
|
|
4627
4125
|
|
|
4628
4126
|
|
|
@@ -4687,5 +4185,5 @@ function pngDataUrl(width, height, data, channels = 4) {
|
|
|
4687
4185
|
|
|
4688
4186
|
|
|
4689
4187
|
|
|
4690
|
-
exports.
|
|
4691
|
-
//# sourceMappingURL=chunk-
|
|
4188
|
+
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;
|
|
4189
|
+
//# sourceMappingURL=chunk-EBSYZRSW.cjs.map
|