imagescript 1.2.9 → 1.2.16
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/ImageScript.d.ts +223 -0
- package/ImageScript.js +1646 -1682
- package/LICENSE +619 -0
- package/README.md +46 -45
- package/bench/_.mjs +166 -0
- package/bench/all.mjs +4 -0
- package/bench/blur.mjs +59 -0
- package/bench/flip.mjs +63 -0
- package/bench/overlay.mjs +35 -0
- package/bench/package.json +7 -0
- package/bench/readme.md +64 -0
- package/bench/resize.mjs +52 -0
- package/codecs/LICENSE +21 -0
- package/codecs/lib.d.ts +50 -0
- package/codecs/lib.js +6 -0
- package/codecs/lib.mjs +1 -0
- package/codecs/node/bin/arm64-darwin.node +0 -0
- package/{node → codecs/node/bin}/arm64-linux.node +0 -0
- package/codecs/node/bin/x64-darwin.node +0 -0
- package/{node → codecs/node/bin}/x64-linux.node +0 -0
- package/{node → codecs/node/bin}/x64-win32.node +0 -0
- package/codecs/node/index.js +3 -0
- package/codecs/node/index.mjs +6 -0
- package/codecs/package.json +14 -0
- package/codecs/readme.md +38 -0
- package/{wasm/simd.wasm → codecs/tests/gif.js} +0 -0
- package/{wasm/unknown.wasm → codecs/tests/jpeg.js} +0 -0
- package/codecs/tests/png.js +0 -0
- package/codecs/tests/results/gif/1024.nis.gif +0 -0
- package/codecs/tests/results/gif/1024.skyra.gif +0 -0
- package/codecs/tests/results/gif/256.nis.gif +0 -0
- package/codecs/tests/results/gif/256.skyra.gif +0 -0
- package/codecs/tests/results/jpeg/256.jpegjs.jpeg +0 -0
- package/codecs/tests/results/jpeg/256.nis.jpeg +0 -0
- package/codecs/tests/results/jpeg/256.sharp.jpeg +0 -0
- package/codecs/tests/results/jpeg/512.jpegjs.jpeg +0 -0
- package/codecs/tests/results/jpeg/512.nis.jpeg +0 -0
- package/codecs/tests/results/jpeg/512.sharp.jpeg +0 -0
- package/codecs/tests/results/jpeg/64.jpegjs.jpeg +0 -0
- package/codecs/tests/results/jpeg/64.nis.jpeg +0 -0
- package/codecs/tests/results/jpeg/64.sharp.jpeg +0 -0
- package/codecs/tests/results/png/256.jis.png +0 -0
- package/codecs/tests/results/png/256.nis.png +0 -0
- package/codecs/tests/results/png/256.sharp.png +0 -0
- package/codecs/tests/results/png/256.upng.png +0 -0
- package/codecs/tests/results/png/512.jis.png +0 -0
- package/codecs/tests/results/png/512.nis.png +0 -0
- package/codecs/tests/results/png/512.sharp.png +0 -0
- package/codecs/tests/results/png/512.upng.png +0 -0
- package/codecs/tests/results/png/64.jis.png +0 -0
- package/codecs/tests/results/png/64.nis.png +0 -0
- package/codecs/tests/results/png/64.sharp.png +0 -0
- package/codecs/tests/results/png/64.upng.png +0 -0
- package/codecs/tests/webp.js +0 -0
- package/codecs/wasm/bin/codecs.wasm +0 -0
- package/codecs/wasm/bin/simd.wasm +0 -0
- package/codecs/wasm/bundle/browser.js +1 -0
- package/codecs/wasm/index.js +1 -0
- package/codecs/wasm/index.mjs +1 -0
- package/package.json +41 -28
- package/png/node.js +1137 -1137
- package/png/src/{crc.js → crc.mjs} +48 -48
- package/png/src/{mem.js → mem.mjs} +23 -23
- package/png/src/{png.js → png.mjs} +254 -254
- package/png/src/{zlib.js → zlib.mjs} +617 -617
- package/tsconfig.json +21 -0
- package/utils/mem.js +25 -25
- package/v2/codecs/magic.js +24 -24
- package/v2/framebuffer.d.ts +66 -66
- package/v2/framebuffer.js +2352 -2371
- package/v2/framebuffer.mjs +125 -125
- package/v2/framebuffer.rs +1264 -0
- package/v2/index.d.ts +83 -83
- package/v2/index.js +260 -260
- package/v2/ops/{blur.js → blur.mjs} +302 -302
- package/v2/ops/{color.js → color.mjs} +276 -276
- package/v2/ops/{crop.js → crop.mjs} +63 -63
- package/v2/ops/{fill.js → fill.mjs} +32 -32
- package/v2/ops/{flip.js → flip.mjs} +32 -32
- package/v2/ops/index.mjs +9 -0
- package/v2/ops/{iterator.js → iterator.mjs} +33 -33
- package/v2/ops/overlay.mjs +63 -0
- package/v2/ops/{resize.js → resize.mjs} +165 -165
- package/v2/ops/{rotate.js → rotate.mjs} +116 -117
- package/v2/util/{mem.js → mem.mjs} +24 -26
- package/wasm/any/font.wasm +0 -0
- package/wasm/any/png.wasm +0 -0
- package/wasm/node/font.js +141 -141
- package/wasm/node/gif.js +76 -76
- package/wasm/node/jpeg.js +91 -91
- package/wasm/node/png.js +49 -0
- package/wasm/node/svg.js +55 -55
- package/wasm/node/tiff.js +46 -46
- package/node/arm64-darwin.node +0 -0
- package/node/index.js +0 -7
- package/node/x64-darwin.node +0 -0
- package/v2/ops/index.js +0 -9
- package/v2/ops/overlay.js +0 -56
- package/wasm/node.js +0 -23
- package/wasm/web.js +0 -10
package/v2/framebuffer.js
CHANGED
|
@@ -1,2371 +1,2352 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
["
|
|
193
|
-
["
|
|
194
|
-
["
|
|
195
|
-
["
|
|
196
|
-
["
|
|
197
|
-
["
|
|
198
|
-
["
|
|
199
|
-
["
|
|
200
|
-
["
|
|
201
|
-
["
|
|
202
|
-
["
|
|
203
|
-
["
|
|
204
|
-
["
|
|
205
|
-
["
|
|
206
|
-
["
|
|
207
|
-
["
|
|
208
|
-
["
|
|
209
|
-
["
|
|
210
|
-
["
|
|
211
|
-
["
|
|
212
|
-
["
|
|
213
|
-
["
|
|
214
|
-
["
|
|
215
|
-
["
|
|
216
|
-
["
|
|
217
|
-
["
|
|
218
|
-
["
|
|
219
|
-
["
|
|
220
|
-
["
|
|
221
|
-
["
|
|
222
|
-
["
|
|
223
|
-
["
|
|
224
|
-
["
|
|
225
|
-
["
|
|
226
|
-
["
|
|
227
|
-
["
|
|
228
|
-
["
|
|
229
|
-
["
|
|
230
|
-
["
|
|
231
|
-
["
|
|
232
|
-
["
|
|
233
|
-
["
|
|
234
|
-
["
|
|
235
|
-
["
|
|
236
|
-
["
|
|
237
|
-
["
|
|
238
|
-
["
|
|
239
|
-
["
|
|
240
|
-
["
|
|
241
|
-
["
|
|
242
|
-
["
|
|
243
|
-
["
|
|
244
|
-
["
|
|
245
|
-
["
|
|
246
|
-
["
|
|
247
|
-
["
|
|
248
|
-
["
|
|
249
|
-
["
|
|
250
|
-
["
|
|
251
|
-
["
|
|
252
|
-
["
|
|
253
|
-
["
|
|
254
|
-
["
|
|
255
|
-
["
|
|
256
|
-
["
|
|
257
|
-
["
|
|
258
|
-
["
|
|
259
|
-
["
|
|
260
|
-
["
|
|
261
|
-
["
|
|
262
|
-
["
|
|
263
|
-
["
|
|
264
|
-
["
|
|
265
|
-
["
|
|
266
|
-
["
|
|
267
|
-
["
|
|
268
|
-
["
|
|
269
|
-
["
|
|
270
|
-
["
|
|
271
|
-
["
|
|
272
|
-
["
|
|
273
|
-
["
|
|
274
|
-
["
|
|
275
|
-
["
|
|
276
|
-
["
|
|
277
|
-
["
|
|
278
|
-
["
|
|
279
|
-
["
|
|
280
|
-
["
|
|
281
|
-
["
|
|
282
|
-
["
|
|
283
|
-
["
|
|
284
|
-
["
|
|
285
|
-
["
|
|
286
|
-
["
|
|
287
|
-
["
|
|
288
|
-
["
|
|
289
|
-
["
|
|
290
|
-
["
|
|
291
|
-
["
|
|
292
|
-
["
|
|
293
|
-
["
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
function
|
|
353
|
-
let offset = 0 | 0;
|
|
354
|
-
const
|
|
355
|
-
const width = framebuffer2.width | 0;
|
|
356
|
-
const height = framebuffer2.height | 0;
|
|
357
|
-
for (let y =
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
u323[
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
framebuffer2.
|
|
389
|
-
framebuffer2.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
const
|
|
411
|
-
const
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
u82[
|
|
526
|
-
u82[
|
|
527
|
-
u82[
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
let
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
let
|
|
621
|
-
let
|
|
622
|
-
let
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
const
|
|
626
|
-
const
|
|
627
|
-
const
|
|
628
|
-
const
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
const
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
const
|
|
738
|
-
const
|
|
739
|
-
const
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
const
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
const
|
|
809
|
-
const
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
const
|
|
821
|
-
const
|
|
822
|
-
const
|
|
823
|
-
const
|
|
824
|
-
const
|
|
825
|
-
const
|
|
826
|
-
const
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
framebuffer2.
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
framebuffer2.
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
const
|
|
915
|
-
const
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
const
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
const
|
|
973
|
-
const
|
|
974
|
-
const
|
|
975
|
-
const
|
|
976
|
-
const
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
for (let
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
let
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
var
|
|
1388
|
-
var
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
var
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
var
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
var
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
var
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
var
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
var
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
var
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
var
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
var
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
var
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
var
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
if (
|
|
1590
|
-
throw "
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
if (
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
}
|
|
1639
|
-
var
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
};
|
|
1652
|
-
var
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
var
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
var
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
var
|
|
1763
|
-
|
|
1764
|
-
var
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
;
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
if (
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
var
|
|
1837
|
-
var
|
|
1838
|
-
var
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
};
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
return
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
var
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
};
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
array
|
|
2043
|
-
array
|
|
2044
|
-
array
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
array.
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
const
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
}
|
|
2118
|
-
if (
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
if (
|
|
2122
|
-
for (let i = 0; i <
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
while (i < bytespp)
|
|
2179
|
-
pixels[i] = slice[i++];
|
|
2180
|
-
while (i < row_length)
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
this.
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
return
|
|
2234
|
-
}
|
|
2235
|
-
|
|
2236
|
-
return this.
|
|
2237
|
-
}
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
}
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
if (
|
|
2288
|
-
|
|
2289
|
-
else if (
|
|
2290
|
-
|
|
2291
|
-
else
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
else
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
else
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
if (
|
|
2330
|
-
fill_exports.
|
|
2331
|
-
else
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
}
|
|
2354
|
-
resize(type, width, height) {
|
|
2355
|
-
if (width === this.width && height === this.height)
|
|
2356
|
-
return this;
|
|
2357
|
-
else if (type === "cubic")
|
|
2358
|
-
resize_exports.cubic(width, height, this);
|
|
2359
|
-
else if (type === "linear")
|
|
2360
|
-
resize_exports.linear(width, height, this);
|
|
2361
|
-
else if (type === "nearest")
|
|
2362
|
-
resize_exports.nearest(width, height, this);
|
|
2363
|
-
else
|
|
2364
|
-
throw new RangeError("invalid resize type");
|
|
2365
|
-
return this;
|
|
2366
|
-
}
|
|
2367
|
-
};
|
|
2368
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
2369
|
-
0 && (module.exports = {
|
|
2370
|
-
Color
|
|
2371
|
-
});
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
__markAsModule(target);
|
|
5
|
+
for (var name in all)
|
|
6
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// v2/framebuffer.mjs
|
|
10
|
+
__export(exports, {
|
|
11
|
+
Color: () => color,
|
|
12
|
+
default: () => framebuffer
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// v2/ops/color.js
|
|
16
|
+
var color_exports = {};
|
|
17
|
+
__export(color_exports, {
|
|
18
|
+
blend: () => blend,
|
|
19
|
+
default: () => color,
|
|
20
|
+
from_rgba: () => from_rgba,
|
|
21
|
+
parse: () => parse,
|
|
22
|
+
to_rgba: () => to_rgba
|
|
23
|
+
});
|
|
24
|
+
var short_hex_regex = /^#?([\da-f]{3,4})$/;
|
|
25
|
+
var long_hex_regex = /^#?((?:[\da-f]{2}){3,4})$/;
|
|
26
|
+
var rgb_regex = /^rgba?\((?<r>(?:\d*\.)?\d+)(?: +| *, *)(?<g>(?:\d*\.)?\d+)(?: +| *, *)(?<b>(?:\d*\.)?\d+)(?:(?: +| *, *)(?<a>\d+|\d*\.\d+|\d+(?:\.\d+)?%))?\)$/;
|
|
27
|
+
var rgb_percentage_regex = /^rgba?\((?<r>(?:\d*\.)?\d+)%(?: +| *, *)(?<g>(?:\d*\.)?\d+)%(?: +| *, *)(?<b>(?:\d*\.)?\d+)%(?:(?: +| *, *)(?<a>\d+|\d*\.\d+|\d+(?:\.\d+)?%))?\)$/;
|
|
28
|
+
var hsl_regex = /^hsla?\((?<h>(?:\d*\.)?\d+)(?<t>|deg|rad|grad|turn)(?: +| *, *)(?<s>(?:\d*\.)?\d+)%(?: +| *, *)(?<l>(?:\d*\.)?\d+)%(?:(?: +| *, *)(?<a>\d+|\d*\.\d+|\d+(?:\.\d+)?%))?\)$/;
|
|
29
|
+
function clamp(min, max2, int) {
|
|
30
|
+
return Math.min(Math.max(Math.round(int), min), max2);
|
|
31
|
+
}
|
|
32
|
+
function to_rgba(int) {
|
|
33
|
+
return [int >> 24 & 255, int >> 16 & 255, int >> 8 & 255, int & 255];
|
|
34
|
+
}
|
|
35
|
+
function from_rgba(r, g, b, a) {
|
|
36
|
+
return (r & 255) << 24 | (g & 255) << 16 | (b & 255) << 8 | a & 255;
|
|
37
|
+
}
|
|
38
|
+
function parse_alpha(a) {
|
|
39
|
+
return clamp(0, 255, a[a.length - 1] === "%" ? 255 / 100 * parseFloat(a) : +a * 255);
|
|
40
|
+
}
|
|
41
|
+
function hue_from_type(h, t) {
|
|
42
|
+
if (t === "turn")
|
|
43
|
+
return h / 1;
|
|
44
|
+
if (t === "grad")
|
|
45
|
+
return h / 400;
|
|
46
|
+
if (!t || t === "deg")
|
|
47
|
+
return h / 360;
|
|
48
|
+
if (t === "rad")
|
|
49
|
+
return h / (2 * Math.PI);
|
|
50
|
+
}
|
|
51
|
+
function hue2rgb(p, q, t) {
|
|
52
|
+
if (t < 0)
|
|
53
|
+
t += 1;
|
|
54
|
+
else if (t > 1)
|
|
55
|
+
t -= 1;
|
|
56
|
+
if (t < 1 / 2)
|
|
57
|
+
return q;
|
|
58
|
+
if (t < 1 / 6)
|
|
59
|
+
return p + 6 * t * (q - p);
|
|
60
|
+
if (t < 2 / 3)
|
|
61
|
+
return p + 6 * (q - p) * (2 / 3 - t);
|
|
62
|
+
return p;
|
|
63
|
+
}
|
|
64
|
+
function blend(fg, bg) {
|
|
65
|
+
const fa = fg & 255;
|
|
66
|
+
const alpha = fa + 1 | 0;
|
|
67
|
+
const inv_alpha = 256 - fa | 0;
|
|
68
|
+
const r = alpha * (fg >>> 24) + inv_alpha * (bg >>> 24) >> 8;
|
|
69
|
+
const b = alpha * (fg >> 8 & 255) + inv_alpha * (bg >> 8 & 255) >> 8;
|
|
70
|
+
const g = alpha * (fg >> 16 & 255) + inv_alpha * (bg >> 16 & 255) >> 8;
|
|
71
|
+
return (r & 255) << 24 | (g & 255) << 16 | (b & 255) << 8 | Math.max(fa, bg & 255) & 255;
|
|
72
|
+
}
|
|
73
|
+
function parse(any) {
|
|
74
|
+
let x2 = null;
|
|
75
|
+
if ((x2 = colors.get(any)) !== void 0)
|
|
76
|
+
return x2;
|
|
77
|
+
if (x2 = long_hex_regex.exec(any))
|
|
78
|
+
return parseInt(`${x2[1]}${x2[1].length === 8 ? "" : "ff"}`, 16);
|
|
79
|
+
if (x2 = hsl_regex.exec(any))
|
|
80
|
+
return color.hsla(hue_from_type(x2[1], x2[2]), x2[3] / 100, x2[4] / 100, x2[5] ? 1 / 255 * parse_alpha(x2[5]) : 1);
|
|
81
|
+
if (x2 = rgb_regex.exec(any))
|
|
82
|
+
return color.rgba(clamp(0, 255, +x2[1]), clamp(0, 255, +x2[2]), clamp(0, 255, +x2[3]), x2[4] ? parse_alpha(x2[4]) : 255);
|
|
83
|
+
if (x2 = short_hex_regex.exec(any))
|
|
84
|
+
return parseInt(`${x2[1][0]}${x2[1][0]}${x2[1][1]}${x2[1][1]}${x2[1][2]}${x2[1][2]}${x2[1].length === 3 ? "ff" : `${x2[1][3]}${x2[1][3]}`}`, 16);
|
|
85
|
+
if (x2 = rgb_percentage_regex.exec(any))
|
|
86
|
+
return color.rgba(clamp(0, 255, +x2[1] * (255 / 100)), clamp(0, 255, +x2[2] * (255 / 100)), clamp(0, 255, +x2[3] * (255 / 100)), x2[4] ? parse_alpha(x2[4]) : 255);
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
var color = class {
|
|
90
|
+
constructor(any) {
|
|
91
|
+
this.value = parse(String(any).toLowerCase());
|
|
92
|
+
if (this.value === null)
|
|
93
|
+
throw new Error(`invalid css color (${any})`);
|
|
94
|
+
}
|
|
95
|
+
static rgb(r, g, b) {
|
|
96
|
+
return this.rgba(r, g, b, 255);
|
|
97
|
+
}
|
|
98
|
+
static rgba(r, g, b, a) {
|
|
99
|
+
return (r & 255) << 24 | (g & 255) << 16 | (b & 255) << 8 | a & 255;
|
|
100
|
+
}
|
|
101
|
+
static hsla(h, s, l, a) {
|
|
102
|
+
s = Math.min(1, Math.max(0, s));
|
|
103
|
+
a = Math.min(1, Math.max(0, a));
|
|
104
|
+
if (s === 0)
|
|
105
|
+
return this.rgba(255, 255, 255, a * 255);
|
|
106
|
+
h %= 1;
|
|
107
|
+
l = Math.min(1, Math.max(0, l));
|
|
108
|
+
const q = l < 0.5 ? l + s * l : l + s - l * s;
|
|
109
|
+
const p = 2 * l - q;
|
|
110
|
+
const g = hue2rgb(p, q, h);
|
|
111
|
+
const r = hue2rgb(p, q, h + 1 / 3);
|
|
112
|
+
const b = hue2rgb(p, q, h - 1 / 3);
|
|
113
|
+
return this.rgba(r * 255, g * 355, b * 255, a * 255);
|
|
114
|
+
}
|
|
115
|
+
valueOf() {
|
|
116
|
+
return this.value;
|
|
117
|
+
}
|
|
118
|
+
toJSON() {
|
|
119
|
+
return this.value >>> 0;
|
|
120
|
+
}
|
|
121
|
+
get rgb() {
|
|
122
|
+
return [this.value >>> 24, this.value >> 16 & 255, this.value >> 8 & 255];
|
|
123
|
+
}
|
|
124
|
+
get rgba() {
|
|
125
|
+
return [this.value >>> 24, this.value >> 16 & 255, this.value >> 8 & 255, this.value & 255];
|
|
126
|
+
}
|
|
127
|
+
get name() {
|
|
128
|
+
for (const color3 of colors.keys()) {
|
|
129
|
+
if (this.value === colors.get(color3))
|
|
130
|
+
return color3;
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
toString(radix) {
|
|
135
|
+
const type = String(radix).toLowerCase();
|
|
136
|
+
const rgba2 = this.rgba;
|
|
137
|
+
if (type === "rgb" || type === "rgba")
|
|
138
|
+
return `rgb${type[3] ? "a" : ""}(${rgba2[0]}, ${rgba2[1]}, ${rgba2[2]}${type[3] ? `, ${clamp(0, 100, 100 / 255 * rgba2[3])}%` : ""})`;
|
|
139
|
+
if (type === "16" || type === "hex")
|
|
140
|
+
return `#${rgba2[0].toString(16).padStart(2, "0")}${rgba2[1].toString(16).padStart(2, "0")}${rgba2[2].toString(16).padStart(2, "0")}${rgba2[3] === 255 ? "" : rgba2[3].toString(16).padStart(2, "0")}`;
|
|
141
|
+
return this.value.toString();
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
var colors = new Map([
|
|
145
|
+
["aliceblue", 4042850303],
|
|
146
|
+
["antiquewhite", 4209760255],
|
|
147
|
+
["aqua", 16777215],
|
|
148
|
+
["aquamarine", 2147472639],
|
|
149
|
+
["azure", 4043309055],
|
|
150
|
+
["beige", 4126530815],
|
|
151
|
+
["bisque", 4293182719],
|
|
152
|
+
["black", 255],
|
|
153
|
+
["blanchedalmond", 4293643775],
|
|
154
|
+
["blue", 65535],
|
|
155
|
+
["blueviolet", 2318131967],
|
|
156
|
+
["brown", 2771004159],
|
|
157
|
+
["burlywood", 3736635391],
|
|
158
|
+
["cadetblue", 1604231423],
|
|
159
|
+
["chartreuse", 2147418367],
|
|
160
|
+
["chocolate", 3530104575],
|
|
161
|
+
["coral", 4286533887],
|
|
162
|
+
["cornflowerblue", 1687547391],
|
|
163
|
+
["cornsilk", 4294499583],
|
|
164
|
+
["crimson", 3692313855],
|
|
165
|
+
["cyan", 16777215],
|
|
166
|
+
["darkblue", 35839],
|
|
167
|
+
["darkcyan", 9145343],
|
|
168
|
+
["darkgoldenrod", 3095792639],
|
|
169
|
+
["darkgray", 2846468607],
|
|
170
|
+
["darkgreen", 6553855],
|
|
171
|
+
["darkgrey", 2846468607],
|
|
172
|
+
["darkkhaki", 3182914559],
|
|
173
|
+
["darkmagenta", 2332068863],
|
|
174
|
+
["darkolivegreen", 1433087999],
|
|
175
|
+
["darkorange", 4287365375],
|
|
176
|
+
["darkorchid", 2570243327],
|
|
177
|
+
["darkred", 2332033279],
|
|
178
|
+
["darksalmon", 3918953215],
|
|
179
|
+
["darkseagreen", 2411499519],
|
|
180
|
+
["darkslateblue", 1211993087],
|
|
181
|
+
["darkslategray", 793726975],
|
|
182
|
+
["darkslategrey", 793726975],
|
|
183
|
+
["darkturquoise", 13554175],
|
|
184
|
+
["darkviolet", 2483082239],
|
|
185
|
+
["deeppink", 4279538687],
|
|
186
|
+
["deepskyblue", 12582911],
|
|
187
|
+
["dimgray", 1768516095],
|
|
188
|
+
["dimgrey", 1768516095],
|
|
189
|
+
["dodgerblue", 512819199],
|
|
190
|
+
["firebrick", 2988581631],
|
|
191
|
+
["floralwhite", 4294635775],
|
|
192
|
+
["forestgreen", 579543807],
|
|
193
|
+
["fuchsia", 4278255615],
|
|
194
|
+
["gainsboro", 3705462015],
|
|
195
|
+
["ghostwhite", 4177068031],
|
|
196
|
+
["gold", 4292280575],
|
|
197
|
+
["goldenrod", 3668254975],
|
|
198
|
+
["gray", 2155905279],
|
|
199
|
+
["green", 8388863],
|
|
200
|
+
["greenyellow", 2919182335],
|
|
201
|
+
["grey", 2155905279],
|
|
202
|
+
["honeydew", 4043305215],
|
|
203
|
+
["hotpink", 4285117695],
|
|
204
|
+
["indianred", 3445382399],
|
|
205
|
+
["indigo", 1258324735],
|
|
206
|
+
["ivory", 4294963455],
|
|
207
|
+
["khaki", 4041641215],
|
|
208
|
+
["lavender", 3873897215],
|
|
209
|
+
["lavenderblush", 4293981695],
|
|
210
|
+
["lawngreen", 2096890111],
|
|
211
|
+
["lemonchiffon", 4294626815],
|
|
212
|
+
["lightblue", 2916673279],
|
|
213
|
+
["lightcoral", 4034953471],
|
|
214
|
+
["lightcyan", 3774873599],
|
|
215
|
+
["lightgoldenrodyellow", 4210742015],
|
|
216
|
+
["lightgray", 3553874943],
|
|
217
|
+
["lightgreen", 2431553791],
|
|
218
|
+
["lightgrey", 3553874943],
|
|
219
|
+
["lightpink", 4290167295],
|
|
220
|
+
["lightsalmon", 4288707327],
|
|
221
|
+
["lightseagreen", 548580095],
|
|
222
|
+
["lightskyblue", 2278488831],
|
|
223
|
+
["lightslategray", 2005441023],
|
|
224
|
+
["lightslategrey", 2005441023],
|
|
225
|
+
["lightsteelblue", 2965692159],
|
|
226
|
+
["lightyellow", 4294959359],
|
|
227
|
+
["lime", 16711935],
|
|
228
|
+
["limegreen", 852308735],
|
|
229
|
+
["linen", 4210091775],
|
|
230
|
+
["magenta", 4278255615],
|
|
231
|
+
["maroon", 2147483903],
|
|
232
|
+
["mediumaquamarine", 1724754687],
|
|
233
|
+
["mediumblue", 52735],
|
|
234
|
+
["mediumorchid", 3126187007],
|
|
235
|
+
["mediumpurple", 2473647103],
|
|
236
|
+
["mediumseagreen", 1018393087],
|
|
237
|
+
["mediumslateblue", 2070474495],
|
|
238
|
+
["mediumspringgreen", 16423679],
|
|
239
|
+
["mediumturquoise", 1221709055],
|
|
240
|
+
["mediumvioletred", 3340076543],
|
|
241
|
+
["midnightblue", 421097727],
|
|
242
|
+
["mintcream", 4127193855],
|
|
243
|
+
["mistyrose", 4293190143],
|
|
244
|
+
["moccasin", 4293178879],
|
|
245
|
+
["navajowhite", 4292783615],
|
|
246
|
+
["navy", 33023],
|
|
247
|
+
["oldlace", 4260751103],
|
|
248
|
+
["olive", 2155872511],
|
|
249
|
+
["olivedrab", 1804477439],
|
|
250
|
+
["orange", 4289003775],
|
|
251
|
+
["orangered", 4282712319],
|
|
252
|
+
["orchid", 3664828159],
|
|
253
|
+
["palegoldenrod", 4008225535],
|
|
254
|
+
["palegreen", 2566625535],
|
|
255
|
+
["paleturquoise", 2951671551],
|
|
256
|
+
["palevioletred", 3681588223],
|
|
257
|
+
["papayawhip", 4293907967],
|
|
258
|
+
["peachpuff", 4292524543],
|
|
259
|
+
["peru", 3448061951],
|
|
260
|
+
["pink", 4290825215],
|
|
261
|
+
["plum", 3718307327],
|
|
262
|
+
["powderblue", 2967529215],
|
|
263
|
+
["purple", 2147516671],
|
|
264
|
+
["rebeccapurple", 1714657791],
|
|
265
|
+
["red", 4278190335],
|
|
266
|
+
["rosybrown", 3163525119],
|
|
267
|
+
["royalblue", 1097458175],
|
|
268
|
+
["saddlebrown", 2336560127],
|
|
269
|
+
["salmon", 4202722047],
|
|
270
|
+
["sandybrown", 4104413439],
|
|
271
|
+
["seagreen", 780883967],
|
|
272
|
+
["seashell", 4294307583],
|
|
273
|
+
["sienna", 2689740287],
|
|
274
|
+
["silver", 3233857791],
|
|
275
|
+
["skyblue", 2278484991],
|
|
276
|
+
["slateblue", 1784335871],
|
|
277
|
+
["slategray", 1887473919],
|
|
278
|
+
["slategrey", 1887473919],
|
|
279
|
+
["snow", 4294638335],
|
|
280
|
+
["springgreen", 16744447],
|
|
281
|
+
["steelblue", 1182971135],
|
|
282
|
+
["tan", 3535047935],
|
|
283
|
+
["teal", 8421631],
|
|
284
|
+
["thistle", 3636451583],
|
|
285
|
+
["tomato", 4284696575],
|
|
286
|
+
["transparent", 0],
|
|
287
|
+
["turquoise", 1088475391],
|
|
288
|
+
["violet", 4001558271],
|
|
289
|
+
["wheat", 4125012991],
|
|
290
|
+
["white", 4294967295],
|
|
291
|
+
["whitesmoke", 4126537215],
|
|
292
|
+
["yellow", 4294902015],
|
|
293
|
+
["yellowgreen", 2597139199]
|
|
294
|
+
]);
|
|
295
|
+
|
|
296
|
+
// v2/util/mem.js
|
|
297
|
+
function view(buffer, shared = false) {
|
|
298
|
+
if (buffer instanceof ArrayBuffer)
|
|
299
|
+
return new Uint8Array(buffer);
|
|
300
|
+
if (shared && buffer instanceof SharedArrayBuffer)
|
|
301
|
+
return new Uint8Array(buffer);
|
|
302
|
+
if (ArrayBuffer.isView(buffer))
|
|
303
|
+
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
304
|
+
throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// v2/ops/flip.js
|
|
308
|
+
var flip_exports = {};
|
|
309
|
+
__export(flip_exports, {
|
|
310
|
+
horizontal: () => horizontal,
|
|
311
|
+
vertical: () => vertical
|
|
312
|
+
});
|
|
313
|
+
function horizontal(framebuffer2) {
|
|
314
|
+
let offset = 0 | 0;
|
|
315
|
+
const u323 = framebuffer2.u32;
|
|
316
|
+
const width = framebuffer2.width | 0;
|
|
317
|
+
const height = framebuffer2.height | 0;
|
|
318
|
+
for (let y = 0 | 0; y < height; y++) {
|
|
319
|
+
u323.subarray(offset, offset += width).reverse();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function vertical(framebuffer2) {
|
|
323
|
+
const u323 = framebuffer2.u32;
|
|
324
|
+
const width = framebuffer2.width | 0;
|
|
325
|
+
const oheight = framebuffer2.height | 0;
|
|
326
|
+
const height = framebuffer2.height / 2 | 0;
|
|
327
|
+
for (let y = 0 | 0; y < height; y++) {
|
|
328
|
+
const yo = y * width | 0;
|
|
329
|
+
const wo1y = width * (oheight - 1 - y) | 0;
|
|
330
|
+
for (let x2 = 0 | 0; x2 < width; x2++) {
|
|
331
|
+
const offset = x2 + yo;
|
|
332
|
+
const offset2 = x2 + wo1y;
|
|
333
|
+
const top = u323[offset];
|
|
334
|
+
const bottom = u323[offset2];
|
|
335
|
+
u323[offset2] = top;
|
|
336
|
+
u323[offset] = bottom;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// v2/ops/fill.js
|
|
342
|
+
var fill_exports = {};
|
|
343
|
+
__export(fill_exports, {
|
|
344
|
+
color: () => color2,
|
|
345
|
+
fn: () => fn,
|
|
346
|
+
swap: () => swap
|
|
347
|
+
});
|
|
348
|
+
function color2(int, framebuffer2) {
|
|
349
|
+
framebuffer2.view.setUint32(0, int);
|
|
350
|
+
framebuffer2.u32.fill(framebuffer2.u32[0]);
|
|
351
|
+
}
|
|
352
|
+
function fn(cb, framebuffer2) {
|
|
353
|
+
let offset = 0 | 0;
|
|
354
|
+
const view3 = framebuffer2.view;
|
|
355
|
+
const width = framebuffer2.width | 0;
|
|
356
|
+
const height = framebuffer2.height | 0;
|
|
357
|
+
for (let y = 1 | 0; y <= height; y++) {
|
|
358
|
+
for (let x2 = 1 | 0; x2 <= width; x2++) {
|
|
359
|
+
view3.setUint32(offset, cb(x2, y), false);
|
|
360
|
+
offset += 4;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function swap(old, int, framebuffer2) {
|
|
365
|
+
{
|
|
366
|
+
const t = new Uint32Array(2);
|
|
367
|
+
const v = new DataView(t.buffer);
|
|
368
|
+
old = (v.setUint32(0, old), t[0]);
|
|
369
|
+
int = (v.setUint32(4, int), t[1]);
|
|
370
|
+
}
|
|
371
|
+
const u323 = framebuffer2.u32;
|
|
372
|
+
const l = framebuffer2.u32.length | 0;
|
|
373
|
+
for (let o = 0 | 0; o < l; o++) {
|
|
374
|
+
if (old === u323[o])
|
|
375
|
+
u323[o] = int;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// v2/ops/blur.js
|
|
380
|
+
var blur_exports = {};
|
|
381
|
+
__export(blur_exports, {
|
|
382
|
+
box: () => box,
|
|
383
|
+
cubic: () => cubic,
|
|
384
|
+
gaussian: () => gaussian
|
|
385
|
+
});
|
|
386
|
+
function cubic(framebuffer2) {
|
|
387
|
+
const width = framebuffer2.width;
|
|
388
|
+
const height = framebuffer2.height;
|
|
389
|
+
framebuffer2.resize("cubic", Math.max(1, 8e-3 * width), Math.max(1, 8e-3 * height));
|
|
390
|
+
framebuffer2.resize("cubic", width, height);
|
|
391
|
+
}
|
|
392
|
+
function box(radius, framebuffer2) {
|
|
393
|
+
if (!radius)
|
|
394
|
+
return;
|
|
395
|
+
const u82 = framebuffer2.u8;
|
|
396
|
+
const width = framebuffer2.width;
|
|
397
|
+
const height = framebuffer2.height;
|
|
398
|
+
const old = framebuffer2.u8.slice();
|
|
399
|
+
bb(u82, old, width, height, radius);
|
|
400
|
+
}
|
|
401
|
+
function gaussian(radius, framebuffer2) {
|
|
402
|
+
if (0 >= radius)
|
|
403
|
+
return;
|
|
404
|
+
const a = Math.exp(0.726 ** 2) / radius;
|
|
405
|
+
const g1 = Math.exp(-a);
|
|
406
|
+
const g2 = Math.exp(a * -2);
|
|
407
|
+
const old = framebuffer2.u8.slice();
|
|
408
|
+
const k = (1 - g1) ** 2 / (1 - g2 + 2 * a * g1);
|
|
409
|
+
const b2 = -g2;
|
|
410
|
+
const b1 = 2 * g1;
|
|
411
|
+
const a3 = -k * g2;
|
|
412
|
+
const a1 = k * g1 * (a - 1);
|
|
413
|
+
const a2 = k * g1 * (a + 1);
|
|
414
|
+
const lc2 = (k + a1) / (1 - b1 - b2);
|
|
415
|
+
const width = framebuffer2.width | 0;
|
|
416
|
+
const rc = (a2 + a3) / (1 - b1 - b2);
|
|
417
|
+
const height = framebuffer2.height | 0;
|
|
418
|
+
const tmp = new Float32Array(4 * Math.max(width, height));
|
|
419
|
+
gc(old, framebuffer2.u8, tmp, width, height, k, a1, a2, a3, b1, b2, lc2, rc);
|
|
420
|
+
gc(framebuffer2.u8, old, tmp, height, width, k, a1, a2, a3, b1, b2, lc2, rc);
|
|
421
|
+
}
|
|
422
|
+
function bb(u82, old, width, height, radius) {
|
|
423
|
+
const divisor = 1 / (1 + radius + radius);
|
|
424
|
+
bbt(u82, old, width, height, radius, divisor);
|
|
425
|
+
bbh(u82, old, width, height, radius, divisor);
|
|
426
|
+
}
|
|
427
|
+
function bbh(u82, old, width, height, radius, divisor) {
|
|
428
|
+
for (var y = 0; y < height; y++) {
|
|
429
|
+
let y_offset = y * width;
|
|
430
|
+
let li = y_offset;
|
|
431
|
+
let ri = radius + y_offset;
|
|
432
|
+
const fv_offset = 4 * y_offset;
|
|
433
|
+
const lv_offset = 4 * (width - 1 + y_offset);
|
|
434
|
+
const rfv = old[fv_offset];
|
|
435
|
+
const gfv = old[1 + fv_offset];
|
|
436
|
+
const bfv = old[2 + fv_offset];
|
|
437
|
+
const afv = old[3 + fv_offset];
|
|
438
|
+
const rlv = old[lv_offset];
|
|
439
|
+
const glv = old[1 + lv_offset];
|
|
440
|
+
const blv = old[2 + lv_offset];
|
|
441
|
+
const alv = old[3 + lv_offset];
|
|
442
|
+
let r = rfv * (1 + radius);
|
|
443
|
+
let g = gfv * (1 + radius);
|
|
444
|
+
let b = bfv * (1 + radius);
|
|
445
|
+
let a = afv * (1 + radius);
|
|
446
|
+
for (let x2 = 0; x2 < radius; x2++) {
|
|
447
|
+
const offset = 4 * (x2 + y_offset);
|
|
448
|
+
r += old[offset];
|
|
449
|
+
g += old[1 + offset];
|
|
450
|
+
b += old[2 + offset];
|
|
451
|
+
a += old[3 + offset];
|
|
452
|
+
}
|
|
453
|
+
for (let x2 = 0; x2 <= radius; x2++) {
|
|
454
|
+
let offset = 4 * ri++;
|
|
455
|
+
r += old[offset] - rfv;
|
|
456
|
+
g += old[1 + offset] - gfv;
|
|
457
|
+
b += old[2 + offset] - bfv;
|
|
458
|
+
a += old[3 + offset] - afv;
|
|
459
|
+
offset = 4 * y_offset++;
|
|
460
|
+
u82[offset] = Math.round(r * divisor);
|
|
461
|
+
u82[1 + offset] = Math.round(g * divisor);
|
|
462
|
+
u82[2 + offset] = Math.round(b * divisor);
|
|
463
|
+
u82[3 + offset] = Math.round(a * divisor);
|
|
464
|
+
}
|
|
465
|
+
for (let x2 = 1 + radius; x2 < width - radius; x2++) {
|
|
466
|
+
let offset = 4 * ri++;
|
|
467
|
+
const roffset = 4 * li++;
|
|
468
|
+
r += old[offset] - old[roffset];
|
|
469
|
+
g += old[1 + offset] - old[1 + roffset];
|
|
470
|
+
b += old[2 + offset] - old[2 + roffset];
|
|
471
|
+
a += old[3 + offset] - old[3 + roffset];
|
|
472
|
+
offset = 4 * y_offset++;
|
|
473
|
+
u82[offset] = Math.round(r * divisor);
|
|
474
|
+
u82[1 + offset] = Math.round(g * divisor);
|
|
475
|
+
u82[2 + offset] = Math.round(b * divisor);
|
|
476
|
+
u82[3 + offset] = Math.round(a * divisor);
|
|
477
|
+
}
|
|
478
|
+
for (let x2 = width - radius; x2 < width; x2++) {
|
|
479
|
+
let offset = 4 * li++;
|
|
480
|
+
r += rlv - old[offset];
|
|
481
|
+
g += glv - old[1 + offset];
|
|
482
|
+
b += blv - old[2 + offset];
|
|
483
|
+
a += alv - old[3 + offset];
|
|
484
|
+
offset = 4 * y_offset++;
|
|
485
|
+
u82[offset] = Math.round(r * divisor);
|
|
486
|
+
u82[1 + offset] = Math.round(g * divisor);
|
|
487
|
+
u82[2 + offset] = Math.round(b * divisor);
|
|
488
|
+
u82[3 + offset] = Math.round(a * divisor);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
function bbt(u82, old, width, height, radius, divisor) {
|
|
493
|
+
for (var x2 = 0; x2 < width; x2++) {
|
|
494
|
+
let ti = x2;
|
|
495
|
+
let li = ti;
|
|
496
|
+
const fv_offset = 4 * ti;
|
|
497
|
+
let ri = ti + width * radius;
|
|
498
|
+
const lv_offset = 4 * (ti + width * (height - 1));
|
|
499
|
+
const rfv = old[fv_offset];
|
|
500
|
+
const gfv = old[1 + fv_offset];
|
|
501
|
+
const bfv = old[2 + fv_offset];
|
|
502
|
+
const afv = old[3 + fv_offset];
|
|
503
|
+
const rlv = old[lv_offset];
|
|
504
|
+
const glv = old[1 + lv_offset];
|
|
505
|
+
const blv = old[2 + lv_offset];
|
|
506
|
+
const alv = old[3 + lv_offset];
|
|
507
|
+
let r = rfv * (1 + radius);
|
|
508
|
+
let g = gfv * (1 + radius);
|
|
509
|
+
let b = bfv * (1 + radius);
|
|
510
|
+
let a = afv * (1 + radius);
|
|
511
|
+
for (let y = 0; y < radius; y++) {
|
|
512
|
+
const offset = 4 * (ti + y * width);
|
|
513
|
+
r += old[offset];
|
|
514
|
+
g += old[1 + offset];
|
|
515
|
+
b += old[2 + offset];
|
|
516
|
+
a += old[3 + offset];
|
|
517
|
+
}
|
|
518
|
+
for (let y = 0; y <= radius; y++) {
|
|
519
|
+
let offset = 4 * ri;
|
|
520
|
+
r += old[offset] - rfv;
|
|
521
|
+
g += old[1 + offset] - gfv;
|
|
522
|
+
b += old[2 + offset] - bfv;
|
|
523
|
+
a += old[3 + offset] - afv;
|
|
524
|
+
offset = 4 * ti;
|
|
525
|
+
u82[offset] = Math.round(r * divisor);
|
|
526
|
+
u82[1 + offset] = Math.round(g * divisor);
|
|
527
|
+
u82[2 + offset] = Math.round(b * divisor);
|
|
528
|
+
u82[3 + offset] = Math.round(a * divisor);
|
|
529
|
+
ri += width;
|
|
530
|
+
ti += width;
|
|
531
|
+
}
|
|
532
|
+
for (let y = 1 + radius; y < height - radius; y++) {
|
|
533
|
+
let offset = 4 * ri;
|
|
534
|
+
const xoffset = 4 * li;
|
|
535
|
+
r += old[offset] - old[xoffset];
|
|
536
|
+
g += old[1 + offset] - old[1 + xoffset];
|
|
537
|
+
b += old[2 + offset] - old[2 + xoffset];
|
|
538
|
+
a += old[3 + offset] - old[3 + xoffset];
|
|
539
|
+
offset = 4 * ti;
|
|
540
|
+
u82[offset] = Math.round(r * divisor);
|
|
541
|
+
u82[1 + offset] = Math.round(g * divisor);
|
|
542
|
+
u82[2 + offset] = Math.round(b * divisor);
|
|
543
|
+
u82[3 + offset] = Math.round(a * divisor);
|
|
544
|
+
li += width;
|
|
545
|
+
ri += width;
|
|
546
|
+
ti += width;
|
|
547
|
+
}
|
|
548
|
+
for (let y = height - radius; y < height; y++) {
|
|
549
|
+
let offset = 4 * li;
|
|
550
|
+
r += rlv - old[offset];
|
|
551
|
+
g += glv - old[1 + offset];
|
|
552
|
+
b += blv - old[2 + offset];
|
|
553
|
+
a += alv - old[3 + offset];
|
|
554
|
+
offset = 4 * ti;
|
|
555
|
+
u82[offset] = Math.round(r * divisor);
|
|
556
|
+
u82[1 + offset] = Math.round(g * divisor);
|
|
557
|
+
u82[2 + offset] = Math.round(b * divisor);
|
|
558
|
+
u82[3 + offset] = Math.round(a * divisor);
|
|
559
|
+
li += width;
|
|
560
|
+
ti += width;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
function gc(u82, old, tmp, width, height, k, a1, a2, a3, b1, b2, lc2, rc) {
|
|
565
|
+
const width4 = width * 4;
|
|
566
|
+
const height4 = height * 4;
|
|
567
|
+
const hw1 = height * (width - 1);
|
|
568
|
+
for (let y = 0; y < height; y++) {
|
|
569
|
+
let toffset = 0 | 0;
|
|
570
|
+
let ooffset = y * width4 | 0;
|
|
571
|
+
let offset = 4 * (y + hw1) | 0;
|
|
572
|
+
let por = old[ooffset];
|
|
573
|
+
let pog = old[1 + ooffset];
|
|
574
|
+
let pob = old[2 + ooffset];
|
|
575
|
+
let poa = old[3 + ooffset];
|
|
576
|
+
let pur = lc2 * por;
|
|
577
|
+
let pug = lc2 * pog;
|
|
578
|
+
let pub = lc2 * pob;
|
|
579
|
+
let pua = lc2 * poa;
|
|
580
|
+
let ppur = pur;
|
|
581
|
+
let ppug = pug;
|
|
582
|
+
let ppub = pub;
|
|
583
|
+
let ppua = pua;
|
|
584
|
+
for (let x2 = 0; x2 < width; x2++) {
|
|
585
|
+
const cor2 = old[ooffset++];
|
|
586
|
+
const cog2 = old[ooffset++];
|
|
587
|
+
const cob2 = old[ooffset++];
|
|
588
|
+
const coa2 = old[ooffset++];
|
|
589
|
+
const cur = k * cor2 + a1 * por + b1 * pur + b2 * ppur;
|
|
590
|
+
const cug = k * cog2 + a1 * pog + b1 * pug + b2 * ppug;
|
|
591
|
+
const cub = k * cob2 + a1 * pob + b1 * pub + b2 * ppub;
|
|
592
|
+
const cua = k * coa2 + a1 * poa + b1 * pua + b2 * ppua;
|
|
593
|
+
ppur = pur;
|
|
594
|
+
pur = cur;
|
|
595
|
+
por = cor2;
|
|
596
|
+
ppug = pug;
|
|
597
|
+
pug = cug;
|
|
598
|
+
pog = cog2;
|
|
599
|
+
ppub = pub;
|
|
600
|
+
pub = cub;
|
|
601
|
+
pob = cob2;
|
|
602
|
+
ppua = pua;
|
|
603
|
+
pua = cua;
|
|
604
|
+
poa = coa2;
|
|
605
|
+
tmp[toffset++] = pur;
|
|
606
|
+
tmp[toffset++] = pug;
|
|
607
|
+
tmp[toffset++] = pub;
|
|
608
|
+
tmp[toffset++] = pua;
|
|
609
|
+
}
|
|
610
|
+
ooffset -= 4;
|
|
611
|
+
toffset -= 4;
|
|
612
|
+
ppur = rc * (por = old[ooffset]);
|
|
613
|
+
ppug = rc * (pog = old[1 + ooffset]);
|
|
614
|
+
ppub = rc * (pob = old[2 + ooffset]);
|
|
615
|
+
ppua = rc * (poa = old[3 + ooffset]);
|
|
616
|
+
pur = ppur;
|
|
617
|
+
pug = ppug;
|
|
618
|
+
pub = ppub;
|
|
619
|
+
pua = ppua;
|
|
620
|
+
let cor = por;
|
|
621
|
+
let cog = pog;
|
|
622
|
+
let cob = pob;
|
|
623
|
+
let coa = poa;
|
|
624
|
+
for (let x2 = width - 1; 0 <= x2; x2--) {
|
|
625
|
+
const cur = a2 * cor + a3 * por + b1 * pur + b2 * ppur;
|
|
626
|
+
const cug = a2 * cog + a3 * pog + b1 * pug + b2 * ppug;
|
|
627
|
+
const cub = a2 * cob + a3 * pob + b1 * pub + b2 * ppub;
|
|
628
|
+
const cua = a2 * coa + a3 * poa + b1 * pua + b2 * ppua;
|
|
629
|
+
ppur = pur;
|
|
630
|
+
pur = cur;
|
|
631
|
+
por = cor;
|
|
632
|
+
ppug = pug;
|
|
633
|
+
pug = cug;
|
|
634
|
+
pog = cog;
|
|
635
|
+
ppub = pub;
|
|
636
|
+
pub = cub;
|
|
637
|
+
pob = cob;
|
|
638
|
+
ppua = pua;
|
|
639
|
+
pua = cua;
|
|
640
|
+
poa = coa;
|
|
641
|
+
cor = old[ooffset];
|
|
642
|
+
cog = old[1 + ooffset];
|
|
643
|
+
cob = old[2 + ooffset];
|
|
644
|
+
coa = old[3 + ooffset];
|
|
645
|
+
u82[offset] = pur + tmp[toffset];
|
|
646
|
+
u82[1 + offset] = pug + tmp[1 + toffset];
|
|
647
|
+
u82[2 + offset] = pub + tmp[2 + toffset];
|
|
648
|
+
u82[3 + offset] = pua + tmp[3 + toffset];
|
|
649
|
+
ooffset -= 4;
|
|
650
|
+
toffset -= 4;
|
|
651
|
+
offset -= height4;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// v2/ops/crop.js
|
|
657
|
+
var crop_exports = {};
|
|
658
|
+
__export(crop_exports, {
|
|
659
|
+
circle: () => circle,
|
|
660
|
+
crop: () => crop,
|
|
661
|
+
cut: () => cut
|
|
662
|
+
});
|
|
663
|
+
function clamp2(min, int, max2) {
|
|
664
|
+
const t = int < min ? min : int;
|
|
665
|
+
return t > max2 ? max2 : t;
|
|
666
|
+
}
|
|
667
|
+
function cut(x2, y, width, height, framebuffer2) {
|
|
668
|
+
width |= 0;
|
|
669
|
+
height |= 0;
|
|
670
|
+
const frame = new framebuffer2.constructor(width, height);
|
|
671
|
+
const n32 = frame.u32;
|
|
672
|
+
const o32 = framebuffer2.u32;
|
|
673
|
+
const fwidth = framebuffer2.width | 0;
|
|
674
|
+
for (let yy = 0 | 0; yy < height; yy++) {
|
|
675
|
+
const offset = x2 + fwidth * (y + yy);
|
|
676
|
+
n32.set(o32.subarray(offset, width + offset), yy * width);
|
|
677
|
+
}
|
|
678
|
+
return frame;
|
|
679
|
+
}
|
|
680
|
+
function crop(x2, y, width, height, framebuffer2) {
|
|
681
|
+
width |= 0;
|
|
682
|
+
height |= 0;
|
|
683
|
+
const old = framebuffer2.u32;
|
|
684
|
+
const fwidth = framebuffer2.width | 0;
|
|
685
|
+
const u323 = framebuffer2.u32 = new Uint32Array(width * height);
|
|
686
|
+
for (let yy = 0; yy < height; yy++) {
|
|
687
|
+
const offset = x2 + fwidth * (y + yy);
|
|
688
|
+
u323.set(old.subarray(offset, width + offset), yy * width);
|
|
689
|
+
}
|
|
690
|
+
framebuffer2.width = width;
|
|
691
|
+
framebuffer2.height = height;
|
|
692
|
+
framebuffer2.u8 = new Uint8Array(framebuffer2.u32.buffer);
|
|
693
|
+
framebuffer2.view = new DataView(framebuffer2.u32.buffer);
|
|
694
|
+
}
|
|
695
|
+
function circle(feathering, framebuffer2) {
|
|
696
|
+
const u82 = framebuffer2.u8;
|
|
697
|
+
const u323 = framebuffer2.u32;
|
|
698
|
+
const width = framebuffer2.width | 0;
|
|
699
|
+
const height = framebuffer2.height | 0;
|
|
700
|
+
const rad = Math.min(width, height) / 2;
|
|
701
|
+
const cx = width / 2;
|
|
702
|
+
const cy = height / 2;
|
|
703
|
+
const rad_2 = rad ** 2;
|
|
704
|
+
const feathering_12 = feathering ** (1 / 2);
|
|
705
|
+
for (let y = 0 | 0; y < height; y++) {
|
|
706
|
+
const cdy = (y - cy) ** 2;
|
|
707
|
+
const y_offset = y * width;
|
|
708
|
+
for (let x2 = 0 | 0; x2 < width; x2++) {
|
|
709
|
+
const cd = cdy + (x2 - cx) ** 2;
|
|
710
|
+
if (cd > rad_2)
|
|
711
|
+
u323[x2 + y_offset] = 0;
|
|
712
|
+
else if (feathering)
|
|
713
|
+
u82[3 + 4 * (x2 + y_offset)] *= clamp2(0, 1 - cd / rad_2 * feathering_12, 1);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return framebuffer2;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// v2/ops/resize.js
|
|
720
|
+
var resize_exports = {};
|
|
721
|
+
__export(resize_exports, {
|
|
722
|
+
cubic: () => cubic2,
|
|
723
|
+
linear: () => linear,
|
|
724
|
+
nearest: () => nearest
|
|
725
|
+
});
|
|
726
|
+
function lerp(a, b, t) {
|
|
727
|
+
return t * b + a * (1 - t);
|
|
728
|
+
}
|
|
729
|
+
function clamp3(min, int, max2) {
|
|
730
|
+
const t = int < min ? min : int;
|
|
731
|
+
return t > max2 ? max2 : t;
|
|
732
|
+
}
|
|
733
|
+
function clamped(x2, y, width, height) {
|
|
734
|
+
return 4 * (clamp3(0, x2, width - 1) + clamp3(0, y, height - 1) * width);
|
|
735
|
+
}
|
|
736
|
+
function hermite(A, B, C, D, t) {
|
|
737
|
+
const c = C / 2 + A / -2;
|
|
738
|
+
const b = A + C * 2 - D / 2 - B * 2.5;
|
|
739
|
+
const a = D / 2 + A / -2 + B * 1.5 - C * 1.5;
|
|
740
|
+
const t2 = t * t;
|
|
741
|
+
return B + c * t + b * t2 + a * t * t2;
|
|
742
|
+
}
|
|
743
|
+
function nearest(width, height, framebuffer2) {
|
|
744
|
+
width = width | 0;
|
|
745
|
+
height = height | 0;
|
|
746
|
+
const old = framebuffer2.u32;
|
|
747
|
+
const fwidth = framebuffer2.width | 0;
|
|
748
|
+
const fheight = framebuffer2.height | 0;
|
|
749
|
+
const u323 = framebuffer2.u32 = new Uint32Array(width * height);
|
|
750
|
+
const dw = 1 / width;
|
|
751
|
+
const dh = 1 / height;
|
|
752
|
+
const xw = dw * fwidth;
|
|
753
|
+
const yw = dh * fheight;
|
|
754
|
+
for (let y = 0 | 0; y < height; y++) {
|
|
755
|
+
const yoffset = y * width;
|
|
756
|
+
const yyoffset = fwidth * (y * yw | 0);
|
|
757
|
+
for (let x2 = 0 | 0; x2 < width; x2++) {
|
|
758
|
+
u323[x2 + yoffset] = old[yyoffset + (x2 * xw | 0)];
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
framebuffer2.width = width;
|
|
762
|
+
framebuffer2.height = height;
|
|
763
|
+
framebuffer2.u8 = new Uint8Array(u323.buffer);
|
|
764
|
+
framebuffer2.view = new DataView(u323.buffer);
|
|
765
|
+
}
|
|
766
|
+
function linear(width, height, framebuffer2) {
|
|
767
|
+
width = width | 0;
|
|
768
|
+
height = height | 0;
|
|
769
|
+
const old = framebuffer2.u8;
|
|
770
|
+
const old_width = framebuffer2.width | 0;
|
|
771
|
+
const old_height = framebuffer2.height | 0;
|
|
772
|
+
const u82 = new Uint8ClampedArray(4 * width * height);
|
|
773
|
+
let offset = 0 | 0;
|
|
774
|
+
const width1 = 1 / (width - 1);
|
|
775
|
+
const height1 = 1 / (height - 1);
|
|
776
|
+
for (let y = 0 | 0; y < height; y++) {
|
|
777
|
+
const yy = old_height * (y * height1) - 0.5;
|
|
778
|
+
const yyi = yy | 0;
|
|
779
|
+
const ty = yy - yyi;
|
|
780
|
+
for (let x2 = 0 | 0; x2 < width; x2++) {
|
|
781
|
+
const xx = old_width * (x2 * width1) - 0.5;
|
|
782
|
+
const xxi = xx | 0;
|
|
783
|
+
const tx = xx - xxi;
|
|
784
|
+
const s0 = clamped(xxi, yyi, old_width, old_height);
|
|
785
|
+
const s1 = clamped(1 + xxi, yyi, old_width, old_height);
|
|
786
|
+
const s2 = clamped(xxi, 1 + yyi, old_width, old_height);
|
|
787
|
+
const s3 = clamped(1 + xxi, 1 + yyi, old_width, old_height);
|
|
788
|
+
u82[offset++] = lerp(lerp(old[s0], old[s2], tx), lerp(old[s1], old[s3], tx), ty);
|
|
789
|
+
u82[offset++] = lerp(lerp(old[1 + s0], old[1 + s2], tx), lerp(old[1 + s1], old[1 + s3], tx), ty);
|
|
790
|
+
u82[offset++] = lerp(lerp(old[2 + s0], old[2 + s2], tx), lerp(old[2 + s1], old[2 + s3], tx), ty);
|
|
791
|
+
u82[offset++] = lerp(lerp(old[3 + s0], old[3 + s2], tx), lerp(old[3 + s1], old[3 + s3], tx), ty);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
framebuffer2.width = width;
|
|
795
|
+
framebuffer2.height = height;
|
|
796
|
+
framebuffer2.u8 = new Uint8Array(u82.buffer);
|
|
797
|
+
framebuffer2.view = new DataView(u82.buffer);
|
|
798
|
+
framebuffer2.u32 = new Uint32Array(u82.buffer);
|
|
799
|
+
}
|
|
800
|
+
function cubic2(width, height, framebuffer2) {
|
|
801
|
+
width = width | 0;
|
|
802
|
+
height = height | 0;
|
|
803
|
+
const old = framebuffer2.u8;
|
|
804
|
+
const old_width = framebuffer2.width | 0;
|
|
805
|
+
const old_height = framebuffer2.height | 0;
|
|
806
|
+
const u82 = new Uint8ClampedArray(4 * width * height);
|
|
807
|
+
let offset = 0 | 0;
|
|
808
|
+
const width1 = 1 / (width - 1);
|
|
809
|
+
const height1 = 1 / (height - 1);
|
|
810
|
+
for (let y = 0 | 0; y < height; y++) {
|
|
811
|
+
const yy = old_height * (y * height1) - 0.5;
|
|
812
|
+
const yyi = yy | 0;
|
|
813
|
+
const ty = yy - yyi;
|
|
814
|
+
for (let x2 = 0 | 0; x2 < width; x2++) {
|
|
815
|
+
const xx = old_width * (x2 * width1) - 0.5;
|
|
816
|
+
const xxi = xx | 0;
|
|
817
|
+
const tx = xx - xxi;
|
|
818
|
+
const s0 = clamped(xxi - 1, yyi - 1, old_width, old_height);
|
|
819
|
+
const s1 = clamped(0 + xxi, yyi - 1, old_width, old_height);
|
|
820
|
+
const s2 = clamped(1 + xxi, yyi - 1, old_width, old_height);
|
|
821
|
+
const s3 = clamped(2 + xxi, yyi - 1, old_width, old_height);
|
|
822
|
+
const s4 = clamped(xxi - 1, yyi, old_width, old_height);
|
|
823
|
+
const s5 = clamped(0 + xxi, yyi, old_width, old_height);
|
|
824
|
+
const s6 = clamped(1 + xxi, yyi, old_width, old_height);
|
|
825
|
+
const s7 = clamped(2 + xxi, yyi, old_width, old_height);
|
|
826
|
+
const s8 = clamped(xxi - 1, 1 + yyi, old_width, old_height);
|
|
827
|
+
const s9 = clamped(0 + xxi, 1 + yyi, old_width, old_height);
|
|
828
|
+
const s10 = clamped(1 + xxi, 1 + yyi, old_width, old_height);
|
|
829
|
+
const s11 = clamped(2 + xxi, 1 + yyi, old_width, old_height);
|
|
830
|
+
const s12 = clamped(xxi - 1, 2 + yyi, old_width, old_height);
|
|
831
|
+
const s13 = clamped(0 + xxi, 2 + yyi, old_width, old_height);
|
|
832
|
+
const s14 = clamped(1 + xxi, 2 + yyi, old_width, old_height);
|
|
833
|
+
const s15 = clamped(2 + xxi, 2 + yyi, old_width, old_height);
|
|
834
|
+
const c0 = hermite(old[s0], old[s1], old[s2], old[s3], tx);
|
|
835
|
+
const c00 = hermite(old[1 + s0], old[1 + s1], old[1 + s2], old[1 + s3], tx);
|
|
836
|
+
const c000 = hermite(old[2 + s0], old[2 + s1], old[2 + s2], old[2 + s3], tx);
|
|
837
|
+
const c0000 = hermite(old[3 + s0], old[3 + s1], old[3 + s2], old[3 + s3], tx);
|
|
838
|
+
const c1 = hermite(old[s4], old[s5], old[s6], old[s7], tx);
|
|
839
|
+
const c11 = hermite(old[1 + s4], old[1 + s5], old[1 + s6], old[1 + s7], tx);
|
|
840
|
+
const c111 = hermite(old[2 + s4], old[2 + s5], old[2 + s6], old[2 + s7], tx);
|
|
841
|
+
const c1111 = hermite(old[3 + s4], old[3 + s5], old[3 + s6], old[3 + s7], tx);
|
|
842
|
+
const c2 = hermite(old[s8], old[s9], old[s10], old[s11], tx);
|
|
843
|
+
const c22 = hermite(old[1 + s8], old[1 + s9], old[1 + s10], old[1 + s11], tx);
|
|
844
|
+
const c222 = hermite(old[2 + s8], old[2 + s9], old[2 + s10], old[2 + s11], tx);
|
|
845
|
+
const c2222 = hermite(old[3 + s8], old[3 + s9], old[3 + s10], old[3 + s11], tx);
|
|
846
|
+
const c3 = hermite(old[s12], old[s13], old[s14], old[s15], tx);
|
|
847
|
+
const c33 = hermite(old[1 + s12], old[1 + s13], old[1 + s14], old[1 + s15], tx);
|
|
848
|
+
const c333 = hermite(old[2 + s12], old[2 + s13], old[2 + s14], old[2 + s15], tx);
|
|
849
|
+
const c3333 = hermite(old[3 + s12], old[3 + s13], old[3 + s14], old[3 + s15], tx);
|
|
850
|
+
u82[offset++] = hermite(c0, c1, c2, c3, ty);
|
|
851
|
+
u82[offset++] = hermite(c00, c11, c22, c33, ty);
|
|
852
|
+
u82[offset++] = hermite(c000, c111, c222, c333, ty);
|
|
853
|
+
u82[offset++] = hermite(c0000, c1111, c2222, c3333, ty);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
framebuffer2.width = width;
|
|
857
|
+
framebuffer2.height = height;
|
|
858
|
+
framebuffer2.u8 = new Uint8Array(u82.buffer);
|
|
859
|
+
framebuffer2.view = new DataView(u82.buffer);
|
|
860
|
+
framebuffer2.u32 = new Uint32Array(u82.buffer);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
// v2/ops/rotate.js
|
|
864
|
+
var rotate_exports = {};
|
|
865
|
+
__export(rotate_exports, {
|
|
866
|
+
rotate: () => rotate,
|
|
867
|
+
rotate180: () => rotate180,
|
|
868
|
+
rotate270: () => rotate270,
|
|
869
|
+
rotate90: () => rotate90
|
|
870
|
+
});
|
|
871
|
+
function rotate180(framebuffer2) {
|
|
872
|
+
framebuffer2.u32.reverse();
|
|
873
|
+
}
|
|
874
|
+
function rotate90(framebuffer2) {
|
|
875
|
+
const u323 = framebuffer2.u32;
|
|
876
|
+
const old = framebuffer2.u32.slice();
|
|
877
|
+
const width = framebuffer2.width | 0;
|
|
878
|
+
const height = framebuffer2.height | 0;
|
|
879
|
+
framebuffer2.width = height;
|
|
880
|
+
framebuffer2.height = width;
|
|
881
|
+
for (let y = 0 | 0; y < width; y++) {
|
|
882
|
+
const yoffset = y * width;
|
|
883
|
+
const height1y = height - 1 - y;
|
|
884
|
+
for (let x2 = 0 | 0; x2 < height; x2++) {
|
|
885
|
+
u323[height1y + x2 * width] = old[x2 + yoffset];
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
function rotate270(framebuffer2) {
|
|
890
|
+
const u323 = framebuffer2.u32;
|
|
891
|
+
const old = framebuffer2.u32.slice();
|
|
892
|
+
const width = framebuffer2.width | 0;
|
|
893
|
+
const height = framebuffer2.height | 0;
|
|
894
|
+
framebuffer2.width = height;
|
|
895
|
+
framebuffer2.height = width;
|
|
896
|
+
for (let y = 0 | 0; y < width; y++) {
|
|
897
|
+
const yoffset = y * width | 0;
|
|
898
|
+
const soffset = y + width * (width - 1) | 0;
|
|
899
|
+
for (let x2 = 0 | 0; x2 < height; x2++) {
|
|
900
|
+
u323[soffset - x2 * width] = old[x2 + yoffset];
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
function rotate(deg, framebuffer2, resize) {
|
|
905
|
+
const rad = Math.PI * ((360 - deg) / 180);
|
|
906
|
+
const sin = Math.sin(rad);
|
|
907
|
+
const cos = Math.cos(rad);
|
|
908
|
+
const width = (resize ? Math.abs(framebuffer2.width * sin) + Math.abs(framebuffer2.height * cos) : framebuffer2.width) | 0;
|
|
909
|
+
const height = (resize ? Math.abs(framebuffer2.width * cos) + Math.abs(framebuffer2.height * sin) : framebuffer2.height) | 0;
|
|
910
|
+
const same_size = width === framebuffer2.width && height === framebuffer2.height;
|
|
911
|
+
const inn = same_size ? framebuffer2.clone() : framebuffer2;
|
|
912
|
+
const out = { width, height, u8: same_size ? framebuffer2.u8 : new Uint8Array(4 * width * height) };
|
|
913
|
+
const out_cx = width / 2 - 0.5;
|
|
914
|
+
const out_cy = height / 2 - 0.5;
|
|
915
|
+
const src_cx = framebuffer2.width / 2 - 0.5;
|
|
916
|
+
const src_cy = framebuffer2.height / 2 - 0.5;
|
|
917
|
+
let h = 0;
|
|
918
|
+
do {
|
|
919
|
+
let w = 0;
|
|
920
|
+
const ysin = src_cx - sin * (h - out_cy);
|
|
921
|
+
const ycos = src_cy + cos * (h - out_cy);
|
|
922
|
+
do {
|
|
923
|
+
interpolate(inn, out, w, h, ysin + cos * (w - out_cx), ycos + sin * (w - out_cx));
|
|
924
|
+
} while (w++ < width);
|
|
925
|
+
} while (h++ < height);
|
|
926
|
+
framebuffer2.u8 = out.u8;
|
|
927
|
+
framebuffer2.width = width;
|
|
928
|
+
framebuffer2.height = height;
|
|
929
|
+
framebuffer2.view = new DataView(out.u8.buffer, out.u8.byteOffset, out.u8.byteLength);
|
|
930
|
+
framebuffer2.u32 = new Uint32Array(out.u8.buffer, out.u8.byteOffset, out.u8.byteLength / 4);
|
|
931
|
+
}
|
|
932
|
+
function interpolate(inn, out, x0, y0, x1, y1) {
|
|
933
|
+
const x2 = ~~x1;
|
|
934
|
+
const y2 = ~~y1;
|
|
935
|
+
const xq = x1 - x2;
|
|
936
|
+
const yq = y1 - y2;
|
|
937
|
+
const offset = 4 * (x0 + y0 * out.width);
|
|
938
|
+
const ref = { r: 0, g: 0, b: 0, a: 0 };
|
|
939
|
+
pawn(x2, y2, (1 - xq) * (1 - yq), ref, inn);
|
|
940
|
+
pawn(1 + x2, y2, xq * (1 - yq), ref, inn);
|
|
941
|
+
pawn(x2, 1 + y2, (1 - xq) * yq, ref, inn);
|
|
942
|
+
pawn(1 + x2, 1 + y2, xq * yq, ref, inn);
|
|
943
|
+
out.u8[3 + offset] = ref.a;
|
|
944
|
+
out.u8[offset] = ref.r / ref.a;
|
|
945
|
+
out.u8[1 + offset] = ref.g / ref.a;
|
|
946
|
+
out.u8[2 + offset] = ref.b / ref.a;
|
|
947
|
+
}
|
|
948
|
+
function pawn(point0, point1, weight, ref, inn) {
|
|
949
|
+
if (point0 > 0 && point1 > 0 && point0 < inn.width && point1 < inn.height) {
|
|
950
|
+
const offset = 4 * (point0 + point1 * inn.width);
|
|
951
|
+
const wa = weight * inn.u8[3 + offset];
|
|
952
|
+
ref.a += wa;
|
|
953
|
+
ref.r += wa * inn.u8[offset];
|
|
954
|
+
ref.g += wa * inn.u8[1 + offset];
|
|
955
|
+
ref.b += wa * inn.u8[2 + offset];
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
// v2/ops/overlay.js
|
|
960
|
+
var overlay_exports = {};
|
|
961
|
+
__export(overlay_exports, {
|
|
962
|
+
blend: () => blend2,
|
|
963
|
+
replace: () => replace
|
|
964
|
+
});
|
|
965
|
+
function replace(bg, fg, x2, y) {
|
|
966
|
+
const b32 = bg.u32;
|
|
967
|
+
const f32 = fg.u32;
|
|
968
|
+
const fw = fg.width | 0;
|
|
969
|
+
const bw = bg.width | 0;
|
|
970
|
+
const fh = fg.height | 0;
|
|
971
|
+
const bh = bg.height | 0;
|
|
972
|
+
const ox = (x2 > 0 ? 0 : -x2) | 0;
|
|
973
|
+
const oy = (y > 0 ? 0 : -y) | 0;
|
|
974
|
+
const top = (y > 0 ? y : 0) | 0;
|
|
975
|
+
const left = (x2 > 0 ? x2 : 0) | 0;
|
|
976
|
+
const width = Math.min(bw, x2 + fw) - left | 0;
|
|
977
|
+
const height = Math.min(bh, y + fh) - top | 0;
|
|
978
|
+
if (0 >= width || 0 >= height)
|
|
979
|
+
return;
|
|
980
|
+
for (let yy = 0 | 0; yy < height; yy++) {
|
|
981
|
+
const yyoffset = ox + fw * (yy + oy);
|
|
982
|
+
const yoffset = left + bw * (yy + top);
|
|
983
|
+
b32.subarray(yoffset, width + yoffset).set(f32.subarray(yyoffset, width + yyoffset));
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
function blend2(bg, fg, x2, y) {
|
|
987
|
+
const b32 = bg.u32;
|
|
988
|
+
const f32 = fg.u32;
|
|
989
|
+
const fw = fg.width | 0;
|
|
990
|
+
const bw = bg.width | 0;
|
|
991
|
+
const fh = fg.height | 0;
|
|
992
|
+
const bh = bg.height | 0;
|
|
993
|
+
const ox = (x2 > 0 ? 0 : -x2) | 0;
|
|
994
|
+
const oy = (y > 0 ? 0 : -y) | 0;
|
|
995
|
+
const top = (y > 0 ? y : 0) | 0;
|
|
996
|
+
const left = (x2 > 0 ? x2 : 0) | 0;
|
|
997
|
+
const width = Math.min(bw, x2 + fw) - left | 0;
|
|
998
|
+
const height = Math.min(bh, y + fh) - top | 0;
|
|
999
|
+
if (0 >= width || 0 >= height)
|
|
1000
|
+
return;
|
|
1001
|
+
for (let yy = 0 | 0; yy < height; yy++) {
|
|
1002
|
+
const yyoffset = ox + fw * (yy + oy);
|
|
1003
|
+
const yoffset = left + bw * (yy + top);
|
|
1004
|
+
for (let xx = 0 | 0; xx < width; xx++) {
|
|
1005
|
+
const F = f32[xx + yyoffset];
|
|
1006
|
+
const fa = F >> 24 & 255;
|
|
1007
|
+
if (fa === 0)
|
|
1008
|
+
continue;
|
|
1009
|
+
else if (fa === 255)
|
|
1010
|
+
b32[xx + yoffset] = F;
|
|
1011
|
+
else {
|
|
1012
|
+
const alpha = 1 + fa;
|
|
1013
|
+
const inv_alpha = 256 - fa;
|
|
1014
|
+
const B = b32[xx + yoffset];
|
|
1015
|
+
const r = alpha * (F & 255) + inv_alpha * (B & 255) >> 8;
|
|
1016
|
+
const g = alpha * (F >> 8 & 255) + inv_alpha * (B >> 8 & 255) >> 8;
|
|
1017
|
+
const b = alpha * (F >> 16 & 255) + inv_alpha * (B >> 16 & 255) >> 8;
|
|
1018
|
+
b32[xx + yoffset] = Math.max(fa, B >> 24 & 255) << 24 | (b & 255) << 16 | (g & 255) << 8 | r;
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
// v2/ops/iterator.js
|
|
1025
|
+
var iterator_exports = {};
|
|
1026
|
+
__export(iterator_exports, {
|
|
1027
|
+
cords: () => cords,
|
|
1028
|
+
rgba: () => rgba,
|
|
1029
|
+
u32: () => u32
|
|
1030
|
+
});
|
|
1031
|
+
function* cords(framebuffer2) {
|
|
1032
|
+
const width = framebuffer2.width | 0;
|
|
1033
|
+
const height = framebuffer2.height | 0;
|
|
1034
|
+
for (let y = 0 | 0; y < height; y++) {
|
|
1035
|
+
for (let x2 = 0 | 0; x2 < width; x2++)
|
|
1036
|
+
yield [x2, y];
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
function* rgba(framebuffer2) {
|
|
1040
|
+
let offset = 0 | 0;
|
|
1041
|
+
const u82 = framebuffer2.u8;
|
|
1042
|
+
const width = framebuffer2.width | 0;
|
|
1043
|
+
const height = framebuffer2.height | 0;
|
|
1044
|
+
for (let y = 0 | 0; y < height; y++) {
|
|
1045
|
+
for (let x2 = 0 | 0; x2 < width; x2++) {
|
|
1046
|
+
yield [x2, y, u82.subarray(offset, offset += 4)];
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
function* u32(framebuffer2) {
|
|
1051
|
+
let offset = 0 | 0;
|
|
1052
|
+
const view3 = framebuffer2.view;
|
|
1053
|
+
const width = framebuffer2.width | 0;
|
|
1054
|
+
const height = framebuffer2.height | 0;
|
|
1055
|
+
for (let y = 0 | 0; y < height; y++) {
|
|
1056
|
+
for (let x2 = 0 | 0; x2 < width; x2++) {
|
|
1057
|
+
yield [x2, y, view3.getUint32(offset, false)];
|
|
1058
|
+
offset += 4;
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// png/src/crc.js
|
|
1064
|
+
var table = new Uint32Array([
|
|
1065
|
+
0,
|
|
1066
|
+
1996959894,
|
|
1067
|
+
3993919788,
|
|
1068
|
+
2567524794,
|
|
1069
|
+
124634137,
|
|
1070
|
+
1886057615,
|
|
1071
|
+
3915621685,
|
|
1072
|
+
2657392035,
|
|
1073
|
+
249268274,
|
|
1074
|
+
2044508324,
|
|
1075
|
+
3772115230,
|
|
1076
|
+
2547177864,
|
|
1077
|
+
162941995,
|
|
1078
|
+
2125561021,
|
|
1079
|
+
3887607047,
|
|
1080
|
+
2428444049,
|
|
1081
|
+
498536548,
|
|
1082
|
+
1789927666,
|
|
1083
|
+
4089016648,
|
|
1084
|
+
2227061214,
|
|
1085
|
+
450548861,
|
|
1086
|
+
1843258603,
|
|
1087
|
+
4107580753,
|
|
1088
|
+
2211677639,
|
|
1089
|
+
325883990,
|
|
1090
|
+
1684777152,
|
|
1091
|
+
4251122042,
|
|
1092
|
+
2321926636,
|
|
1093
|
+
335633487,
|
|
1094
|
+
1661365465,
|
|
1095
|
+
4195302755,
|
|
1096
|
+
2366115317,
|
|
1097
|
+
997073096,
|
|
1098
|
+
1281953886,
|
|
1099
|
+
3579855332,
|
|
1100
|
+
2724688242,
|
|
1101
|
+
1006888145,
|
|
1102
|
+
1258607687,
|
|
1103
|
+
3524101629,
|
|
1104
|
+
2768942443,
|
|
1105
|
+
901097722,
|
|
1106
|
+
1119000684,
|
|
1107
|
+
3686517206,
|
|
1108
|
+
2898065728,
|
|
1109
|
+
853044451,
|
|
1110
|
+
1172266101,
|
|
1111
|
+
3705015759,
|
|
1112
|
+
2882616665,
|
|
1113
|
+
651767980,
|
|
1114
|
+
1373503546,
|
|
1115
|
+
3369554304,
|
|
1116
|
+
3218104598,
|
|
1117
|
+
565507253,
|
|
1118
|
+
1454621731,
|
|
1119
|
+
3485111705,
|
|
1120
|
+
3099436303,
|
|
1121
|
+
671266974,
|
|
1122
|
+
1594198024,
|
|
1123
|
+
3322730930,
|
|
1124
|
+
2970347812,
|
|
1125
|
+
795835527,
|
|
1126
|
+
1483230225,
|
|
1127
|
+
3244367275,
|
|
1128
|
+
3060149565,
|
|
1129
|
+
1994146192,
|
|
1130
|
+
31158534,
|
|
1131
|
+
2563907772,
|
|
1132
|
+
4023717930,
|
|
1133
|
+
1907459465,
|
|
1134
|
+
112637215,
|
|
1135
|
+
2680153253,
|
|
1136
|
+
3904427059,
|
|
1137
|
+
2013776290,
|
|
1138
|
+
251722036,
|
|
1139
|
+
2517215374,
|
|
1140
|
+
3775830040,
|
|
1141
|
+
2137656763,
|
|
1142
|
+
141376813,
|
|
1143
|
+
2439277719,
|
|
1144
|
+
3865271297,
|
|
1145
|
+
1802195444,
|
|
1146
|
+
476864866,
|
|
1147
|
+
2238001368,
|
|
1148
|
+
4066508878,
|
|
1149
|
+
1812370925,
|
|
1150
|
+
453092731,
|
|
1151
|
+
2181625025,
|
|
1152
|
+
4111451223,
|
|
1153
|
+
1706088902,
|
|
1154
|
+
314042704,
|
|
1155
|
+
2344532202,
|
|
1156
|
+
4240017532,
|
|
1157
|
+
1658658271,
|
|
1158
|
+
366619977,
|
|
1159
|
+
2362670323,
|
|
1160
|
+
4224994405,
|
|
1161
|
+
1303535960,
|
|
1162
|
+
984961486,
|
|
1163
|
+
2747007092,
|
|
1164
|
+
3569037538,
|
|
1165
|
+
1256170817,
|
|
1166
|
+
1037604311,
|
|
1167
|
+
2765210733,
|
|
1168
|
+
3554079995,
|
|
1169
|
+
1131014506,
|
|
1170
|
+
879679996,
|
|
1171
|
+
2909243462,
|
|
1172
|
+
3663771856,
|
|
1173
|
+
1141124467,
|
|
1174
|
+
855842277,
|
|
1175
|
+
2852801631,
|
|
1176
|
+
3708648649,
|
|
1177
|
+
1342533948,
|
|
1178
|
+
654459306,
|
|
1179
|
+
3188396048,
|
|
1180
|
+
3373015174,
|
|
1181
|
+
1466479909,
|
|
1182
|
+
544179635,
|
|
1183
|
+
3110523913,
|
|
1184
|
+
3462522015,
|
|
1185
|
+
1591671054,
|
|
1186
|
+
702138776,
|
|
1187
|
+
2966460450,
|
|
1188
|
+
3352799412,
|
|
1189
|
+
1504918807,
|
|
1190
|
+
783551873,
|
|
1191
|
+
3082640443,
|
|
1192
|
+
3233442989,
|
|
1193
|
+
3988292384,
|
|
1194
|
+
2596254646,
|
|
1195
|
+
62317068,
|
|
1196
|
+
1957810842,
|
|
1197
|
+
3939845945,
|
|
1198
|
+
2647816111,
|
|
1199
|
+
81470997,
|
|
1200
|
+
1943803523,
|
|
1201
|
+
3814918930,
|
|
1202
|
+
2489596804,
|
|
1203
|
+
225274430,
|
|
1204
|
+
2053790376,
|
|
1205
|
+
3826175755,
|
|
1206
|
+
2466906013,
|
|
1207
|
+
167816743,
|
|
1208
|
+
2097651377,
|
|
1209
|
+
4027552580,
|
|
1210
|
+
2265490386,
|
|
1211
|
+
503444072,
|
|
1212
|
+
1762050814,
|
|
1213
|
+
4150417245,
|
|
1214
|
+
2154129355,
|
|
1215
|
+
426522225,
|
|
1216
|
+
1852507879,
|
|
1217
|
+
4275313526,
|
|
1218
|
+
2312317920,
|
|
1219
|
+
282753626,
|
|
1220
|
+
1742555852,
|
|
1221
|
+
4189708143,
|
|
1222
|
+
2394877945,
|
|
1223
|
+
397917763,
|
|
1224
|
+
1622183637,
|
|
1225
|
+
3604390888,
|
|
1226
|
+
2714866558,
|
|
1227
|
+
953729732,
|
|
1228
|
+
1340076626,
|
|
1229
|
+
3518719985,
|
|
1230
|
+
2797360999,
|
|
1231
|
+
1068828381,
|
|
1232
|
+
1219638859,
|
|
1233
|
+
3624741850,
|
|
1234
|
+
2936675148,
|
|
1235
|
+
906185462,
|
|
1236
|
+
1090812512,
|
|
1237
|
+
3747672003,
|
|
1238
|
+
2825379669,
|
|
1239
|
+
829329135,
|
|
1240
|
+
1181335161,
|
|
1241
|
+
3412177804,
|
|
1242
|
+
3160834842,
|
|
1243
|
+
628085408,
|
|
1244
|
+
1382605366,
|
|
1245
|
+
3423369109,
|
|
1246
|
+
3138078467,
|
|
1247
|
+
570562233,
|
|
1248
|
+
1426400815,
|
|
1249
|
+
3317316542,
|
|
1250
|
+
2998733608,
|
|
1251
|
+
733239954,
|
|
1252
|
+
1555261956,
|
|
1253
|
+
3268935591,
|
|
1254
|
+
3050360625,
|
|
1255
|
+
752459403,
|
|
1256
|
+
1541320221,
|
|
1257
|
+
2607071920,
|
|
1258
|
+
3965973030,
|
|
1259
|
+
1969922972,
|
|
1260
|
+
40735498,
|
|
1261
|
+
2617837225,
|
|
1262
|
+
3943577151,
|
|
1263
|
+
1913087877,
|
|
1264
|
+
83908371,
|
|
1265
|
+
2512341634,
|
|
1266
|
+
3803740692,
|
|
1267
|
+
2075208622,
|
|
1268
|
+
213261112,
|
|
1269
|
+
2463272603,
|
|
1270
|
+
3855990285,
|
|
1271
|
+
2094854071,
|
|
1272
|
+
198958881,
|
|
1273
|
+
2262029012,
|
|
1274
|
+
4057260610,
|
|
1275
|
+
1759359992,
|
|
1276
|
+
534414190,
|
|
1277
|
+
2176718541,
|
|
1278
|
+
4139329115,
|
|
1279
|
+
1873836001,
|
|
1280
|
+
414664567,
|
|
1281
|
+
2282248934,
|
|
1282
|
+
4279200368,
|
|
1283
|
+
1711684554,
|
|
1284
|
+
285281116,
|
|
1285
|
+
2405801727,
|
|
1286
|
+
4167216745,
|
|
1287
|
+
1634467795,
|
|
1288
|
+
376229701,
|
|
1289
|
+
2685067896,
|
|
1290
|
+
3608007406,
|
|
1291
|
+
1308918612,
|
|
1292
|
+
956543938,
|
|
1293
|
+
2808555105,
|
|
1294
|
+
3495958263,
|
|
1295
|
+
1231636301,
|
|
1296
|
+
1047427035,
|
|
1297
|
+
2932959818,
|
|
1298
|
+
3654703836,
|
|
1299
|
+
1088359270,
|
|
1300
|
+
936918e3,
|
|
1301
|
+
2847714899,
|
|
1302
|
+
3736837829,
|
|
1303
|
+
1202900863,
|
|
1304
|
+
817233897,
|
|
1305
|
+
3183342108,
|
|
1306
|
+
3401237130,
|
|
1307
|
+
1404277552,
|
|
1308
|
+
615818150,
|
|
1309
|
+
3134207493,
|
|
1310
|
+
3453421203,
|
|
1311
|
+
1423857449,
|
|
1312
|
+
601450431,
|
|
1313
|
+
3009837614,
|
|
1314
|
+
3294710456,
|
|
1315
|
+
1567103746,
|
|
1316
|
+
711928724,
|
|
1317
|
+
3020668471,
|
|
1318
|
+
3272380065,
|
|
1319
|
+
1510334235,
|
|
1320
|
+
755167117
|
|
1321
|
+
]);
|
|
1322
|
+
function crc32(buffer) {
|
|
1323
|
+
let offset = 0 | 0;
|
|
1324
|
+
let crc = 4294967295 | 0;
|
|
1325
|
+
const bl = buffer.length - 4 | 0;
|
|
1326
|
+
while (bl > offset) {
|
|
1327
|
+
crc = table[(crc ^ buffer[offset++]) & 255] ^ crc >>> 8;
|
|
1328
|
+
crc = table[(crc ^ buffer[offset++]) & 255] ^ crc >>> 8;
|
|
1329
|
+
crc = table[(crc ^ buffer[offset++]) & 255] ^ crc >>> 8;
|
|
1330
|
+
crc = table[(crc ^ buffer[offset++]) & 255] ^ crc >>> 8;
|
|
1331
|
+
}
|
|
1332
|
+
while (offset < buffer.length) {
|
|
1333
|
+
crc = table[(crc ^ buffer[offset++]) & 255] ^ crc >>> 8;
|
|
1334
|
+
}
|
|
1335
|
+
return (crc ^ 4294967295) >>> 0;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
// png/src/mem.js
|
|
1339
|
+
function view2(buffer, shared = false) {
|
|
1340
|
+
if (buffer instanceof ArrayBuffer)
|
|
1341
|
+
return new Uint8Array(buffer);
|
|
1342
|
+
if (shared && buffer instanceof SharedArrayBuffer)
|
|
1343
|
+
return new Uint8Array(buffer);
|
|
1344
|
+
if (ArrayBuffer.isView(buffer))
|
|
1345
|
+
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
1346
|
+
throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
|
|
1347
|
+
}
|
|
1348
|
+
function from_parts(buffers, shared = false) {
|
|
1349
|
+
let length = 0;
|
|
1350
|
+
let offset = 0;
|
|
1351
|
+
buffers.forEach((buffer) => length += buffer.byteLength == null ? buffer.length : buffer.byteLength);
|
|
1352
|
+
const u82 = new Uint8Array(shared ? new SharedArrayBuffer(length) : length);
|
|
1353
|
+
buffers.forEach((buffer) => {
|
|
1354
|
+
const ref = Array.isArray(buffer) ? buffer : view2(buffer, true);
|
|
1355
|
+
u82.set(ref, offset);
|
|
1356
|
+
offset += ref.length;
|
|
1357
|
+
});
|
|
1358
|
+
return u82;
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
// png/src/zlib.js
|
|
1362
|
+
var u8 = Uint8Array;
|
|
1363
|
+
var u16 = Uint16Array;
|
|
1364
|
+
var u322 = Uint32Array;
|
|
1365
|
+
var clim = u8.of(16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15);
|
|
1366
|
+
var fleb = u8.of(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, 0, 0, 0);
|
|
1367
|
+
var fdeb = u8.of(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, 0, 0);
|
|
1368
|
+
var freb = function(eb, start) {
|
|
1369
|
+
var b = new u16(31);
|
|
1370
|
+
for (var i = 0; i < 31; ++i) {
|
|
1371
|
+
b[i] = start += 1 << eb[i - 1];
|
|
1372
|
+
}
|
|
1373
|
+
var r = new u322(b[30]);
|
|
1374
|
+
for (var i = 1; i < 30; ++i) {
|
|
1375
|
+
for (var j = b[i]; j < b[i + 1]; ++j) {
|
|
1376
|
+
r[j] = j - b[i] << 5 | i;
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
return [b, r];
|
|
1380
|
+
};
|
|
1381
|
+
var _a = freb(fleb, 2);
|
|
1382
|
+
var fl = _a[0];
|
|
1383
|
+
var revfl = _a[1];
|
|
1384
|
+
fl[28] = 258, revfl[258] = 28;
|
|
1385
|
+
var _b = freb(fdeb, 0);
|
|
1386
|
+
var fd = _b[0];
|
|
1387
|
+
var revfd = _b[1];
|
|
1388
|
+
var rev = new u16(32768);
|
|
1389
|
+
for (i = 0; i < 32768; ++i) {
|
|
1390
|
+
x = (i & 43690) >>> 1 | (i & 21845) << 1;
|
|
1391
|
+
x = (x & 52428) >>> 2 | (x & 13107) << 2;
|
|
1392
|
+
x = (x & 61680) >>> 4 | (x & 3855) << 4;
|
|
1393
|
+
rev[i] = ((x & 65280) >>> 8 | (x & 255) << 8) >>> 1;
|
|
1394
|
+
}
|
|
1395
|
+
var i;
|
|
1396
|
+
var x;
|
|
1397
|
+
var hMap = function(cd, mb, r) {
|
|
1398
|
+
var s = cd.length;
|
|
1399
|
+
var i = 0;
|
|
1400
|
+
var l = new u16(mb);
|
|
1401
|
+
for (; i < s; ++i)
|
|
1402
|
+
++l[cd[i] - 1];
|
|
1403
|
+
var le = new u16(mb);
|
|
1404
|
+
for (i = 0; i < mb; ++i) {
|
|
1405
|
+
le[i] = le[i - 1] + l[i - 1] << 1;
|
|
1406
|
+
}
|
|
1407
|
+
var co;
|
|
1408
|
+
if (r) {
|
|
1409
|
+
co = new u16(1 << mb);
|
|
1410
|
+
var rvb = 15 - mb;
|
|
1411
|
+
for (i = 0; i < s; ++i) {
|
|
1412
|
+
if (cd[i]) {
|
|
1413
|
+
var sv = i << 4 | cd[i];
|
|
1414
|
+
var r_1 = mb - cd[i];
|
|
1415
|
+
var v = le[cd[i] - 1]++ << r_1;
|
|
1416
|
+
for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
|
|
1417
|
+
co[rev[v] >>> rvb] = sv;
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
} else {
|
|
1422
|
+
co = new u16(s);
|
|
1423
|
+
for (i = 0; i < s; ++i) {
|
|
1424
|
+
if (cd[i]) {
|
|
1425
|
+
co[i] = rev[le[cd[i] - 1]++] >>> 15 - cd[i];
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
return co;
|
|
1430
|
+
};
|
|
1431
|
+
var flt = new u8(288);
|
|
1432
|
+
for (i = 0; i < 144; ++i)
|
|
1433
|
+
flt[i] = 8;
|
|
1434
|
+
var i;
|
|
1435
|
+
for (i = 144; i < 256; ++i)
|
|
1436
|
+
flt[i] = 9;
|
|
1437
|
+
var i;
|
|
1438
|
+
for (i = 256; i < 280; ++i)
|
|
1439
|
+
flt[i] = 7;
|
|
1440
|
+
var i;
|
|
1441
|
+
for (i = 280; i < 288; ++i)
|
|
1442
|
+
flt[i] = 8;
|
|
1443
|
+
var i;
|
|
1444
|
+
var fdt = new u8(32);
|
|
1445
|
+
for (i = 0; i < 32; ++i)
|
|
1446
|
+
fdt[i] = 5;
|
|
1447
|
+
var i;
|
|
1448
|
+
var flm = hMap(flt, 9, 0);
|
|
1449
|
+
var flrm = hMap(flt, 9, 1);
|
|
1450
|
+
var fdm = hMap(fdt, 5, 0);
|
|
1451
|
+
var fdrm = hMap(fdt, 5, 1);
|
|
1452
|
+
var max = function(a) {
|
|
1453
|
+
var m = a[0];
|
|
1454
|
+
for (var i = 1; i < a.length; ++i) {
|
|
1455
|
+
if (a[i] > m)
|
|
1456
|
+
m = a[i];
|
|
1457
|
+
}
|
|
1458
|
+
return m;
|
|
1459
|
+
};
|
|
1460
|
+
var bits = function(d, p, m) {
|
|
1461
|
+
var o = p >> 3 | 0;
|
|
1462
|
+
return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
|
|
1463
|
+
};
|
|
1464
|
+
var bits16 = function(d, p) {
|
|
1465
|
+
var o = p >> 3 | 0;
|
|
1466
|
+
return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
|
|
1467
|
+
};
|
|
1468
|
+
var shft = function(p) {
|
|
1469
|
+
return (p >> 3 | 0) + (p & 7 && 1);
|
|
1470
|
+
};
|
|
1471
|
+
var slc = function(v, s, e) {
|
|
1472
|
+
if (s == null || s < 0)
|
|
1473
|
+
s = 0;
|
|
1474
|
+
if (e == null || e > v.length)
|
|
1475
|
+
e = v.length;
|
|
1476
|
+
var n = new (v instanceof u16 ? u16 : v instanceof u322 ? u322 : u8)(e - s);
|
|
1477
|
+
n.set(v.subarray(s, e));
|
|
1478
|
+
return n;
|
|
1479
|
+
};
|
|
1480
|
+
var inflt = function(dat, buf, st) {
|
|
1481
|
+
var sl = dat.length;
|
|
1482
|
+
if (!sl || st && !st.l && sl < 5)
|
|
1483
|
+
return buf || new u8(0);
|
|
1484
|
+
var noBuf = !buf || st;
|
|
1485
|
+
var noSt = !st || st.i;
|
|
1486
|
+
if (!st)
|
|
1487
|
+
st = {};
|
|
1488
|
+
if (!buf)
|
|
1489
|
+
buf = new u8(sl * 3);
|
|
1490
|
+
var cbuf = function(l2) {
|
|
1491
|
+
var bl = buf.length;
|
|
1492
|
+
if (l2 > bl) {
|
|
1493
|
+
var nbuf = new u8(Math.max(bl * 2, l2));
|
|
1494
|
+
nbuf.set(buf);
|
|
1495
|
+
buf = nbuf;
|
|
1496
|
+
}
|
|
1497
|
+
};
|
|
1498
|
+
var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
|
|
1499
|
+
var tbts = sl * 8;
|
|
1500
|
+
do {
|
|
1501
|
+
if (!lm) {
|
|
1502
|
+
st.f = final = bits(dat, pos, 1);
|
|
1503
|
+
var type = bits(dat, pos + 1, 3);
|
|
1504
|
+
pos += 3;
|
|
1505
|
+
if (!type) {
|
|
1506
|
+
var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
|
|
1507
|
+
if (t > sl) {
|
|
1508
|
+
if (noSt)
|
|
1509
|
+
throw "unexpected EOF";
|
|
1510
|
+
break;
|
|
1511
|
+
}
|
|
1512
|
+
if (noBuf)
|
|
1513
|
+
cbuf(bt + l);
|
|
1514
|
+
buf.set(dat.subarray(s, t), bt);
|
|
1515
|
+
st.b = bt += l, st.p = pos = t * 8;
|
|
1516
|
+
continue;
|
|
1517
|
+
} else if (type === 1)
|
|
1518
|
+
lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
|
|
1519
|
+
else if (type === 2) {
|
|
1520
|
+
var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
|
|
1521
|
+
var tl = hLit + bits(dat, pos + 5, 31) + 1;
|
|
1522
|
+
pos += 14;
|
|
1523
|
+
var ldt = new u8(tl);
|
|
1524
|
+
var clt = new u8(19);
|
|
1525
|
+
for (var i = 0; i < hcLen; ++i) {
|
|
1526
|
+
clt[clim[i]] = bits(dat, pos + i * 3, 7);
|
|
1527
|
+
}
|
|
1528
|
+
pos += hcLen * 3;
|
|
1529
|
+
var clb = max(clt), clbmsk = (1 << clb) - 1;
|
|
1530
|
+
var clm = hMap(clt, clb, 1);
|
|
1531
|
+
for (var i = 0; i < tl; ) {
|
|
1532
|
+
var r = clm[bits(dat, pos, clbmsk)];
|
|
1533
|
+
pos += r & 15;
|
|
1534
|
+
var s = r >>> 4;
|
|
1535
|
+
if (s < 16) {
|
|
1536
|
+
ldt[i++] = s;
|
|
1537
|
+
} else {
|
|
1538
|
+
var c = 0, n = 0;
|
|
1539
|
+
if (s === 16)
|
|
1540
|
+
n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
|
|
1541
|
+
else if (s === 17)
|
|
1542
|
+
n = 3 + bits(dat, pos, 7), pos += 3;
|
|
1543
|
+
else if (s === 18)
|
|
1544
|
+
n = 11 + bits(dat, pos, 127), pos += 7;
|
|
1545
|
+
while (n--)
|
|
1546
|
+
ldt[i++] = c;
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
|
|
1550
|
+
lbt = max(lt);
|
|
1551
|
+
dbt = max(dt);
|
|
1552
|
+
lm = hMap(lt, lbt, 1);
|
|
1553
|
+
dm = hMap(dt, dbt, 1);
|
|
1554
|
+
} else
|
|
1555
|
+
throw "invalid block type";
|
|
1556
|
+
if (pos > tbts) {
|
|
1557
|
+
if (noSt)
|
|
1558
|
+
throw "unexpected EOF";
|
|
1559
|
+
break;
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
if (noBuf)
|
|
1563
|
+
cbuf(bt + 131072);
|
|
1564
|
+
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
|
|
1565
|
+
var lpos = pos;
|
|
1566
|
+
for (; ; lpos = pos) {
|
|
1567
|
+
var c = lm[bits16(dat, pos) & lms], sym = c >>> 4;
|
|
1568
|
+
pos += c & 15;
|
|
1569
|
+
if (pos > tbts) {
|
|
1570
|
+
if (noSt)
|
|
1571
|
+
throw "unexpected EOF";
|
|
1572
|
+
break;
|
|
1573
|
+
}
|
|
1574
|
+
if (!c)
|
|
1575
|
+
throw "invalid length/literal";
|
|
1576
|
+
if (sym < 256)
|
|
1577
|
+
buf[bt++] = sym;
|
|
1578
|
+
else if (sym === 256) {
|
|
1579
|
+
lpos = pos, lm = null;
|
|
1580
|
+
break;
|
|
1581
|
+
} else {
|
|
1582
|
+
var add = sym - 254;
|
|
1583
|
+
if (sym > 264) {
|
|
1584
|
+
var i = sym - 257, b = fleb[i];
|
|
1585
|
+
add = bits(dat, pos, (1 << b) - 1) + fl[i];
|
|
1586
|
+
pos += b;
|
|
1587
|
+
}
|
|
1588
|
+
var d = dm[bits16(dat, pos) & dms], dsym = d >>> 4;
|
|
1589
|
+
if (!d)
|
|
1590
|
+
throw "invalid distance";
|
|
1591
|
+
pos += d & 15;
|
|
1592
|
+
var dt = fd[dsym];
|
|
1593
|
+
if (dsym > 3) {
|
|
1594
|
+
var b = fdeb[dsym];
|
|
1595
|
+
dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
|
|
1596
|
+
}
|
|
1597
|
+
if (pos > tbts) {
|
|
1598
|
+
if (noSt)
|
|
1599
|
+
throw "unexpected EOF";
|
|
1600
|
+
break;
|
|
1601
|
+
}
|
|
1602
|
+
if (noBuf)
|
|
1603
|
+
cbuf(bt + 131072);
|
|
1604
|
+
var end = bt + add;
|
|
1605
|
+
for (; bt < end; bt += 4) {
|
|
1606
|
+
buf[bt] = buf[bt - dt];
|
|
1607
|
+
buf[bt + 1] = buf[bt + 1 - dt];
|
|
1608
|
+
buf[bt + 2] = buf[bt + 2 - dt];
|
|
1609
|
+
buf[bt + 3] = buf[bt + 3 - dt];
|
|
1610
|
+
}
|
|
1611
|
+
bt = end;
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
st.l = lm, st.p = lpos, st.b = bt;
|
|
1615
|
+
if (lm)
|
|
1616
|
+
final = 1, st.m = lbt, st.d = dm, st.n = dbt;
|
|
1617
|
+
} while (!final);
|
|
1618
|
+
return bt === buf.length ? buf : slc(buf, 0, bt);
|
|
1619
|
+
};
|
|
1620
|
+
var wbits = function(d, p, v) {
|
|
1621
|
+
v <<= p & 7;
|
|
1622
|
+
var o = p >> 3 | 0;
|
|
1623
|
+
d[o] |= v;
|
|
1624
|
+
d[o + 1] |= v >>> 8;
|
|
1625
|
+
};
|
|
1626
|
+
var wbits16 = function(d, p, v) {
|
|
1627
|
+
v <<= p & 7;
|
|
1628
|
+
var o = p >> 3 | 0;
|
|
1629
|
+
d[o] |= v;
|
|
1630
|
+
d[o + 1] |= v >>> 8;
|
|
1631
|
+
d[o + 2] |= v >>> 16;
|
|
1632
|
+
};
|
|
1633
|
+
var hTree = function(d, mb) {
|
|
1634
|
+
var t = [];
|
|
1635
|
+
for (var i = 0; i < d.length; ++i) {
|
|
1636
|
+
if (d[i])
|
|
1637
|
+
t.push({ s: i, f: d[i] });
|
|
1638
|
+
}
|
|
1639
|
+
var s = t.length;
|
|
1640
|
+
var t2 = t.slice();
|
|
1641
|
+
if (!s)
|
|
1642
|
+
return [et, 0];
|
|
1643
|
+
if (s === 1) {
|
|
1644
|
+
var v = new u8(t[0].s + 1);
|
|
1645
|
+
v[t[0].s] = 1;
|
|
1646
|
+
return [v, 1];
|
|
1647
|
+
}
|
|
1648
|
+
t.sort(function(a, b) {
|
|
1649
|
+
return a.f - b.f;
|
|
1650
|
+
});
|
|
1651
|
+
t.push({ s: -1, f: 25001 });
|
|
1652
|
+
var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;
|
|
1653
|
+
t[0] = { s: -1, f: l.f + r.f, l, r };
|
|
1654
|
+
while (i1 !== s - 1) {
|
|
1655
|
+
l = t[t[i0].f < t[i2].f ? i0++ : i2++];
|
|
1656
|
+
r = t[i0 !== i1 && t[i0].f < t[i2].f ? i0++ : i2++];
|
|
1657
|
+
t[i1++] = { s: -1, f: l.f + r.f, l, r };
|
|
1658
|
+
}
|
|
1659
|
+
var maxSym = t2[0].s;
|
|
1660
|
+
for (var i = 1; i < s; ++i) {
|
|
1661
|
+
if (t2[i].s > maxSym)
|
|
1662
|
+
maxSym = t2[i].s;
|
|
1663
|
+
}
|
|
1664
|
+
var tr = new u16(maxSym + 1);
|
|
1665
|
+
var mbt = ln(t[i1 - 1], tr, 0);
|
|
1666
|
+
if (mbt > mb) {
|
|
1667
|
+
var i = 0, dt = 0;
|
|
1668
|
+
var lft = mbt - mb, cst = 1 << lft;
|
|
1669
|
+
t2.sort(function(a, b) {
|
|
1670
|
+
return tr[b.s] - tr[a.s] || a.f - b.f;
|
|
1671
|
+
});
|
|
1672
|
+
for (; i < s; ++i) {
|
|
1673
|
+
var i2_1 = t2[i].s;
|
|
1674
|
+
if (tr[i2_1] > mb) {
|
|
1675
|
+
dt += cst - (1 << mbt - tr[i2_1]);
|
|
1676
|
+
tr[i2_1] = mb;
|
|
1677
|
+
} else
|
|
1678
|
+
break;
|
|
1679
|
+
}
|
|
1680
|
+
dt >>>= lft;
|
|
1681
|
+
while (dt > 0) {
|
|
1682
|
+
var i2_2 = t2[i].s;
|
|
1683
|
+
if (tr[i2_2] < mb)
|
|
1684
|
+
dt -= 1 << mb - tr[i2_2]++ - 1;
|
|
1685
|
+
else
|
|
1686
|
+
++i;
|
|
1687
|
+
}
|
|
1688
|
+
for (; i >= 0 && dt; --i) {
|
|
1689
|
+
var i2_3 = t2[i].s;
|
|
1690
|
+
if (tr[i2_3] === mb) {
|
|
1691
|
+
--tr[i2_3];
|
|
1692
|
+
++dt;
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
mbt = mb;
|
|
1696
|
+
}
|
|
1697
|
+
return [new u8(tr), mbt];
|
|
1698
|
+
};
|
|
1699
|
+
var ln = function(n, l, d) {
|
|
1700
|
+
return n.s === -1 ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) : l[n.s] = d;
|
|
1701
|
+
};
|
|
1702
|
+
var lc = function(c) {
|
|
1703
|
+
var s = c.length;
|
|
1704
|
+
while (s && !c[--s])
|
|
1705
|
+
;
|
|
1706
|
+
var cl = new u16(++s);
|
|
1707
|
+
var cli = 0, cln = c[0], cls = 1;
|
|
1708
|
+
var w = function(v) {
|
|
1709
|
+
cl[cli++] = v;
|
|
1710
|
+
};
|
|
1711
|
+
for (var i = 1; i <= s; ++i) {
|
|
1712
|
+
if (c[i] === cln && i !== s)
|
|
1713
|
+
++cls;
|
|
1714
|
+
else {
|
|
1715
|
+
if (!cln && cls > 2) {
|
|
1716
|
+
for (; cls > 138; cls -= 138)
|
|
1717
|
+
w(32754);
|
|
1718
|
+
if (cls > 2) {
|
|
1719
|
+
w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
|
|
1720
|
+
cls = 0;
|
|
1721
|
+
}
|
|
1722
|
+
} else if (cls > 3) {
|
|
1723
|
+
w(cln), --cls;
|
|
1724
|
+
for (; cls > 6; cls -= 6)
|
|
1725
|
+
w(8304);
|
|
1726
|
+
if (cls > 2)
|
|
1727
|
+
w(cls - 3 << 5 | 8208), cls = 0;
|
|
1728
|
+
}
|
|
1729
|
+
while (cls--)
|
|
1730
|
+
w(cln);
|
|
1731
|
+
cls = 1;
|
|
1732
|
+
cln = c[i];
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
return [cl.subarray(0, cli), s];
|
|
1736
|
+
};
|
|
1737
|
+
var clen = function(cf, cl) {
|
|
1738
|
+
var l = 0;
|
|
1739
|
+
for (var i = 0; i < cl.length; ++i)
|
|
1740
|
+
l += cf[i] * cl[i];
|
|
1741
|
+
return l;
|
|
1742
|
+
};
|
|
1743
|
+
var wfblk = function(out, pos, dat) {
|
|
1744
|
+
var s = dat.length;
|
|
1745
|
+
var o = shft(pos + 2);
|
|
1746
|
+
out[o] = s & 255;
|
|
1747
|
+
out[o + 1] = s >>> 8;
|
|
1748
|
+
out[o + 2] = out[o] ^ 255;
|
|
1749
|
+
out[o + 3] = out[o + 1] ^ 255;
|
|
1750
|
+
for (var i = 0; i < s; ++i)
|
|
1751
|
+
out[o + i + 4] = dat[i];
|
|
1752
|
+
return (o + 4 + s) * 8;
|
|
1753
|
+
};
|
|
1754
|
+
var wblk = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
|
|
1755
|
+
wbits(out, p++, final);
|
|
1756
|
+
++lf[256];
|
|
1757
|
+
var _a2 = hTree(lf, 15), dlt = _a2[0], mlb = _a2[1];
|
|
1758
|
+
var _b2 = hTree(df, 15), ddt = _b2[0], mdb = _b2[1];
|
|
1759
|
+
var _c = lc(dlt), lclt = _c[0], nlc = _c[1];
|
|
1760
|
+
var _d = lc(ddt), lcdt = _d[0], ndc = _d[1];
|
|
1761
|
+
var lcfreq = new u16(19);
|
|
1762
|
+
for (var i = 0; i < lclt.length; ++i)
|
|
1763
|
+
lcfreq[lclt[i] & 31]++;
|
|
1764
|
+
for (var i = 0; i < lcdt.length; ++i)
|
|
1765
|
+
lcfreq[lcdt[i] & 31]++;
|
|
1766
|
+
var _e = hTree(lcfreq, 7), lct = _e[0], mlcb = _e[1];
|
|
1767
|
+
var nlcc = 19;
|
|
1768
|
+
for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)
|
|
1769
|
+
;
|
|
1770
|
+
var flen = bl + 5 << 3;
|
|
1771
|
+
var ftlen = clen(lf, flt) + clen(df, fdt) + eb;
|
|
1772
|
+
var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + (2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18]);
|
|
1773
|
+
if (flen <= ftlen && flen <= dtlen)
|
|
1774
|
+
return wfblk(out, p, dat.subarray(bs, bs + bl));
|
|
1775
|
+
var lm, ll, dm, dl;
|
|
1776
|
+
wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
|
|
1777
|
+
if (dtlen < ftlen) {
|
|
1778
|
+
lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
|
|
1779
|
+
var llm = hMap(lct, mlcb, 0);
|
|
1780
|
+
wbits(out, p, nlc - 257);
|
|
1781
|
+
wbits(out, p + 5, ndc - 1);
|
|
1782
|
+
wbits(out, p + 10, nlcc - 4);
|
|
1783
|
+
p += 14;
|
|
1784
|
+
for (var i = 0; i < nlcc; ++i)
|
|
1785
|
+
wbits(out, p + 3 * i, lct[clim[i]]);
|
|
1786
|
+
p += 3 * nlcc;
|
|
1787
|
+
var lcts = [lclt, lcdt];
|
|
1788
|
+
for (var it = 0; it < 2; ++it) {
|
|
1789
|
+
var clct = lcts[it];
|
|
1790
|
+
for (var i = 0; i < clct.length; ++i) {
|
|
1791
|
+
var len = clct[i] & 31;
|
|
1792
|
+
wbits(out, p, llm[len]), p += lct[len];
|
|
1793
|
+
if (len > 15)
|
|
1794
|
+
wbits(out, p, clct[i] >>> 5 & 127), p += clct[i] >>> 12;
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
} else {
|
|
1798
|
+
lm = flm, ll = flt, dm = fdm, dl = fdt;
|
|
1799
|
+
}
|
|
1800
|
+
for (var i = 0; i < li; ++i) {
|
|
1801
|
+
if (syms[i] > 255) {
|
|
1802
|
+
var len = syms[i] >>> 18 & 31;
|
|
1803
|
+
wbits16(out, p, lm[len + 257]), p += ll[len + 257];
|
|
1804
|
+
if (len > 7)
|
|
1805
|
+
wbits(out, p, syms[i] >>> 23 & 31), p += fleb[len];
|
|
1806
|
+
var dst = syms[i] & 31;
|
|
1807
|
+
wbits16(out, p, dm[dst]), p += dl[dst];
|
|
1808
|
+
if (dst > 3)
|
|
1809
|
+
wbits16(out, p, syms[i] >>> 5 & 8191), p += fdeb[dst];
|
|
1810
|
+
} else {
|
|
1811
|
+
wbits16(out, p, lm[syms[i]]), p += ll[syms[i]];
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
wbits16(out, p, lm[256]);
|
|
1815
|
+
return p + ll[256];
|
|
1816
|
+
};
|
|
1817
|
+
var deo = u322.of(65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632);
|
|
1818
|
+
var et = new u8(0);
|
|
1819
|
+
var dflt = function(dat, lvl, plvl, pre, post, lst) {
|
|
1820
|
+
var s = dat.length;
|
|
1821
|
+
var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7e3)) + post);
|
|
1822
|
+
var w = o.subarray(pre, o.length - post);
|
|
1823
|
+
var pos = 0;
|
|
1824
|
+
if (!lvl || s < 8) {
|
|
1825
|
+
for (var i = 0; i <= s; i += 65535) {
|
|
1826
|
+
var e = i + 65535;
|
|
1827
|
+
if (e < s) {
|
|
1828
|
+
pos = wfblk(w, pos, dat.subarray(i, e));
|
|
1829
|
+
} else {
|
|
1830
|
+
w[i] = lst;
|
|
1831
|
+
pos = wfblk(w, pos, dat.subarray(i, s));
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
} else {
|
|
1835
|
+
var opt = deo[lvl - 1];
|
|
1836
|
+
var n = opt >>> 13, c = opt & 8191;
|
|
1837
|
+
var msk_1 = (1 << plvl) - 1;
|
|
1838
|
+
var prev = new u16(32768), head = new u16(msk_1 + 1);
|
|
1839
|
+
var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
|
|
1840
|
+
var hsh = function(i2) {
|
|
1841
|
+
return (dat[i2] ^ dat[i2 + 1] << bs1_1 ^ dat[i2 + 2] << bs2_1) & msk_1;
|
|
1842
|
+
};
|
|
1843
|
+
var syms = new u322(25e3);
|
|
1844
|
+
var lf = new u16(288), df = new u16(32);
|
|
1845
|
+
var lc_1 = 0, eb = 0, i = 0, li = 0, wi = 0, bs = 0;
|
|
1846
|
+
for (; i < s; ++i) {
|
|
1847
|
+
var hv = hsh(i);
|
|
1848
|
+
var imod = i & 32767, pimod = head[hv];
|
|
1849
|
+
prev[imod] = pimod;
|
|
1850
|
+
head[hv] = imod;
|
|
1851
|
+
if (wi <= i) {
|
|
1852
|
+
var rem = s - i;
|
|
1853
|
+
if ((lc_1 > 7e3 || li > 24576) && rem > 423) {
|
|
1854
|
+
pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);
|
|
1855
|
+
li = lc_1 = eb = 0, bs = i;
|
|
1856
|
+
for (var j = 0; j < 286; ++j)
|
|
1857
|
+
lf[j] = 0;
|
|
1858
|
+
for (var j = 0; j < 30; ++j)
|
|
1859
|
+
df[j] = 0;
|
|
1860
|
+
}
|
|
1861
|
+
var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;
|
|
1862
|
+
if (rem > 2 && hv === hsh(i - dif)) {
|
|
1863
|
+
var maxn = Math.min(n, rem) - 1;
|
|
1864
|
+
var maxd = Math.min(32767, i);
|
|
1865
|
+
var ml = Math.min(258, rem);
|
|
1866
|
+
while (dif <= maxd && --ch_1 && imod !== pimod) {
|
|
1867
|
+
if (dat[i + l] === dat[i + l - dif]) {
|
|
1868
|
+
var nl = 0;
|
|
1869
|
+
for (; nl < ml && dat[i + nl] === dat[i + nl - dif]; ++nl)
|
|
1870
|
+
;
|
|
1871
|
+
if (nl > l) {
|
|
1872
|
+
l = nl, d = dif;
|
|
1873
|
+
if (nl > maxn)
|
|
1874
|
+
break;
|
|
1875
|
+
var mmd = Math.min(dif, nl - 2);
|
|
1876
|
+
var md = 0;
|
|
1877
|
+
for (var j = 0; j < mmd; ++j) {
|
|
1878
|
+
var ti = i - dif + j + 32768 & 32767;
|
|
1879
|
+
var pti = prev[ti];
|
|
1880
|
+
var cd = ti - pti + 32768 & 32767;
|
|
1881
|
+
if (cd > md)
|
|
1882
|
+
md = cd, pimod = ti;
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
imod = pimod, pimod = prev[imod];
|
|
1887
|
+
dif += imod - pimod + 32768 & 32767;
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
if (d) {
|
|
1891
|
+
syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
|
|
1892
|
+
var lin = revfl[l] & 31, din = revfd[d] & 31;
|
|
1893
|
+
eb += fleb[lin] + fdeb[din];
|
|
1894
|
+
++lf[257 + lin];
|
|
1895
|
+
++df[din];
|
|
1896
|
+
wi = i + l;
|
|
1897
|
+
++lc_1;
|
|
1898
|
+
} else {
|
|
1899
|
+
syms[li++] = dat[i];
|
|
1900
|
+
++lf[dat[i]];
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);
|
|
1905
|
+
if (!lst && pos & 7)
|
|
1906
|
+
pos = wfblk(w, pos + 1, et);
|
|
1907
|
+
}
|
|
1908
|
+
return slc(o, 0, pre + shft(pos) + post);
|
|
1909
|
+
};
|
|
1910
|
+
var adler = function() {
|
|
1911
|
+
var a = 1, b = 0;
|
|
1912
|
+
return {
|
|
1913
|
+
p: function(d) {
|
|
1914
|
+
var n = a, m = b;
|
|
1915
|
+
var l = d.length | 0;
|
|
1916
|
+
for (var i = 0; i !== l; ) {
|
|
1917
|
+
var e = Math.min(i + 2655, l);
|
|
1918
|
+
for (; i < e; ++i)
|
|
1919
|
+
m += n += d[i];
|
|
1920
|
+
n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);
|
|
1921
|
+
}
|
|
1922
|
+
a = n, b = m;
|
|
1923
|
+
},
|
|
1924
|
+
d: function() {
|
|
1925
|
+
a %= 65521, b %= 65521;
|
|
1926
|
+
return (a & 255) << 24 | a >>> 8 << 16 | (b & 255) << 8 | b >>> 8;
|
|
1927
|
+
}
|
|
1928
|
+
};
|
|
1929
|
+
};
|
|
1930
|
+
var dopt = function(dat, opt, pre, post, st) {
|
|
1931
|
+
return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 12 + opt.mem, pre, post, !st);
|
|
1932
|
+
};
|
|
1933
|
+
var wbytes = function(d, b, v) {
|
|
1934
|
+
for (; v; ++b)
|
|
1935
|
+
d[b] = v, v >>>= 8;
|
|
1936
|
+
};
|
|
1937
|
+
var zlh = function(c, o) {
|
|
1938
|
+
var lv = o.level, fl2 = lv === 0 ? 0 : lv < 6 ? 1 : lv === 9 ? 3 : 2;
|
|
1939
|
+
c[0] = 120, c[1] = fl2 << 6 | (fl2 ? 32 - 2 * fl2 : 1);
|
|
1940
|
+
};
|
|
1941
|
+
var zlv = function(d) {
|
|
1942
|
+
if ((d[0] & 15) !== 8 || d[0] >>> 4 > 7 || (d[0] << 8 | d[1]) % 31)
|
|
1943
|
+
throw "invalid zlib data";
|
|
1944
|
+
if (d[1] & 32)
|
|
1945
|
+
throw "invalid zlib data: preset dictionaries not supported";
|
|
1946
|
+
};
|
|
1947
|
+
function zlibSync(data, opts) {
|
|
1948
|
+
if (!opts)
|
|
1949
|
+
opts = {};
|
|
1950
|
+
var a = adler();
|
|
1951
|
+
a.p(data);
|
|
1952
|
+
var d = dopt(data, opts, 2, 4);
|
|
1953
|
+
return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;
|
|
1954
|
+
}
|
|
1955
|
+
function unzlibSync(data, out) {
|
|
1956
|
+
return inflt((zlv(data), data.subarray(2, -4)), out);
|
|
1957
|
+
}
|
|
1958
|
+
function compress(buf, level) {
|
|
1959
|
+
return zlibSync(buf, { level });
|
|
1960
|
+
}
|
|
1961
|
+
function decompress(buf, limit) {
|
|
1962
|
+
try {
|
|
1963
|
+
return unzlibSync(buf, new Uint8Array(limit));
|
|
1964
|
+
} catch (err) {
|
|
1965
|
+
throw err.message ? err : new Error(err);
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
// png/src/png.js
|
|
1970
|
+
var __IHDR__ = new Uint8Array([73, 72, 68, 82]);
|
|
1971
|
+
var __IDAT__ = new Uint8Array([73, 68, 65, 84]);
|
|
1972
|
+
var __IEND__ = new Uint8Array([73, 69, 78, 68]);
|
|
1973
|
+
var __IEND_CRC__ = crc32(new Uint8Array([73, 69, 78, 68]));
|
|
1974
|
+
var HEAD = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
1975
|
+
var color_types = {
|
|
1976
|
+
GREYSCALE: 0,
|
|
1977
|
+
TRUECOLOR: 2,
|
|
1978
|
+
INDEXED_COLOR: 3,
|
|
1979
|
+
GREYSCALE_ALPHA: 4,
|
|
1980
|
+
TRUECOLOR_ALPHA: 6
|
|
1981
|
+
};
|
|
1982
|
+
var channels_to_color_type = {
|
|
1983
|
+
1: color_types.GREYSCALE,
|
|
1984
|
+
2: color_types.GREYSCALE_ALPHA,
|
|
1985
|
+
3: color_types.TRUECOLOR,
|
|
1986
|
+
4: color_types.TRUECOLOR_ALPHA
|
|
1987
|
+
};
|
|
1988
|
+
var utf8encoder = new TextEncoder();
|
|
1989
|
+
function encode(data, { text, width, height, channels, depth = 8, level = 0 }) {
|
|
1990
|
+
let offset = 0;
|
|
1991
|
+
let tmp_offset = 0;
|
|
1992
|
+
const row_length = width * channels;
|
|
1993
|
+
const tmp = new Uint8Array(height + data.length);
|
|
1994
|
+
while (offset < data.length) {
|
|
1995
|
+
tmp[tmp_offset++] = 0;
|
|
1996
|
+
tmp.set(data.subarray(offset, offset += row_length), tmp_offset);
|
|
1997
|
+
tmp_offset += row_length;
|
|
1998
|
+
}
|
|
1999
|
+
if (text) {
|
|
2000
|
+
let chunks = [];
|
|
2001
|
+
for (const key in text) {
|
|
2002
|
+
if (!text[key])
|
|
2003
|
+
continue;
|
|
2004
|
+
const kb = utf8encoder.encode(key);
|
|
2005
|
+
const tb = utf8encoder.encode(text[key]);
|
|
2006
|
+
const chunk = new Uint8Array(1 + 12 + kb.length + tb.length);
|
|
2007
|
+
const view4 = new DataView(chunk.buffer);
|
|
2008
|
+
chunk[4] = 116;
|
|
2009
|
+
chunk[5] = 69;
|
|
2010
|
+
chunk[6] = 88;
|
|
2011
|
+
chunk[7] = 116;
|
|
2012
|
+
chunk.set(kb, 8);
|
|
2013
|
+
chunks.push(chunk);
|
|
2014
|
+
chunk.set(tb, 9 + kb.length);
|
|
2015
|
+
view4.setUint32(0, chunk.length - 12);
|
|
2016
|
+
view4.setUint32(chunk.length - 4, crc32(chunk.subarray(4, chunk.length - 4)));
|
|
2017
|
+
}
|
|
2018
|
+
text = from_parts(chunks);
|
|
2019
|
+
}
|
|
2020
|
+
offset = text ? text.length : 0;
|
|
2021
|
+
const compressed = compress(tmp, level);
|
|
2022
|
+
const array = new Uint8Array(49 + offset + HEAD.length + compressed.length);
|
|
2023
|
+
array[26] = 0;
|
|
2024
|
+
array[27] = 0;
|
|
2025
|
+
array[28] = 0;
|
|
2026
|
+
array[24] = depth;
|
|
2027
|
+
array.set(HEAD, 0);
|
|
2028
|
+
array.set(__IHDR__, 12);
|
|
2029
|
+
array.set(__IDAT__, 37);
|
|
2030
|
+
array.set(compressed, 41);
|
|
2031
|
+
array[25] = channels_to_color_type[channels];
|
|
2032
|
+
if (text)
|
|
2033
|
+
array.set(text, 45 + compressed.length);
|
|
2034
|
+
array.set(__IEND__, 49 + offset + compressed.length);
|
|
2035
|
+
const view3 = new DataView(array.buffer);
|
|
2036
|
+
view3.setUint32(8, 13);
|
|
2037
|
+
view3.setUint32(16, width);
|
|
2038
|
+
view3.setUint32(20, height);
|
|
2039
|
+
view3.setUint32(33, compressed.length);
|
|
2040
|
+
view3.setUint32(45 + offset + compressed.length, 0);
|
|
2041
|
+
view3.setUint32(53 + offset + compressed.length, __IEND_CRC__);
|
|
2042
|
+
view3.setUint32(29, crc32(new Uint8Array(array.buffer, 12, 17)));
|
|
2043
|
+
view3.setUint32(41 + compressed.length, crc32(new Uint8Array(array.buffer, 37, 4 + compressed.length)));
|
|
2044
|
+
return array;
|
|
2045
|
+
}
|
|
2046
|
+
function decode(array) {
|
|
2047
|
+
let view3 = new DataView(array.buffer, array.byteOffset, array.byteLength);
|
|
2048
|
+
const width = view3.getUint32(16);
|
|
2049
|
+
const height = view3.getUint32(20);
|
|
2050
|
+
const bpc = array[24];
|
|
2051
|
+
const pixel_type = array[25];
|
|
2052
|
+
let channels = { 3: 1, 0: 1, 4: 2, 2: 3, 6: 4 }[pixel_type];
|
|
2053
|
+
const bytespp = channels * bpc / 8;
|
|
2054
|
+
const row_length = width * bytespp;
|
|
2055
|
+
let pixels = new Uint8Array(height * row_length);
|
|
2056
|
+
let offset = 0;
|
|
2057
|
+
let p_offset = 0;
|
|
2058
|
+
let c_offset = 33;
|
|
2059
|
+
const chunks = [];
|
|
2060
|
+
let palette, alphaPalette;
|
|
2061
|
+
const maxSearchOffset = array.length - 5;
|
|
2062
|
+
let type;
|
|
2063
|
+
while ((type = view3.getUint32(4 + c_offset)) !== 1229278788) {
|
|
2064
|
+
if (type === 1229209940)
|
|
2065
|
+
chunks.push(array.subarray(8 + c_offset, 8 + c_offset + view3.getUint32(c_offset)));
|
|
2066
|
+
else if (type === 1347179589) {
|
|
2067
|
+
if (palette)
|
|
2068
|
+
throw new Error("PLTE can only occur once in an image");
|
|
2069
|
+
palette = new Uint32Array(view3.getUint32(c_offset));
|
|
2070
|
+
for (let pxlOffset = 0; pxlOffset < palette.length * 8; pxlOffset += 3)
|
|
2071
|
+
palette[pxlOffset / 3] = array[8 + c_offset + pxlOffset] << 24 | array[8 + c_offset + pxlOffset + 1] << 16 | array[8 + c_offset + pxlOffset + 2] << 8 | 255;
|
|
2072
|
+
} else if (type === 1951551059) {
|
|
2073
|
+
if (alphaPalette)
|
|
2074
|
+
throw new Error("tRNS can only occur once in an image");
|
|
2075
|
+
alphaPalette = new Uint8Array(view3.getUint32(c_offset));
|
|
2076
|
+
for (let i = 0; i < alphaPalette.length; i++)
|
|
2077
|
+
alphaPalette[i] = array[8 + c_offset + i];
|
|
2078
|
+
}
|
|
2079
|
+
c_offset += 4 + 4 + 4 + view3.getUint32(c_offset);
|
|
2080
|
+
if (c_offset > maxSearchOffset)
|
|
2081
|
+
break;
|
|
2082
|
+
}
|
|
2083
|
+
array = decompress(chunks.length === 1 ? chunks[0] : from_parts(chunks), height + height * row_length);
|
|
2084
|
+
while (offset < array.byteLength) {
|
|
2085
|
+
const filter = array[offset++];
|
|
2086
|
+
const slice = array.subarray(offset, offset += row_length);
|
|
2087
|
+
if (filter === 0)
|
|
2088
|
+
pixels.set(slice, p_offset);
|
|
2089
|
+
else if (filter === 1)
|
|
2090
|
+
filter_1(slice, pixels, p_offset, bytespp, row_length);
|
|
2091
|
+
else if (filter === 2)
|
|
2092
|
+
filter_2(slice, pixels, p_offset, bytespp, row_length);
|
|
2093
|
+
else if (filter === 3)
|
|
2094
|
+
filter_3(slice, pixels, p_offset, bytespp, row_length);
|
|
2095
|
+
else if (filter === 4)
|
|
2096
|
+
filter_4(slice, pixels, p_offset, bytespp, row_length);
|
|
2097
|
+
p_offset += row_length;
|
|
2098
|
+
}
|
|
2099
|
+
if (pixel_type === 3) {
|
|
2100
|
+
if (!palette)
|
|
2101
|
+
throw new Error("Indexed color PNG has no PLTE");
|
|
2102
|
+
if (alphaPalette)
|
|
2103
|
+
for (let i = 0; i < alphaPalette.length; i++)
|
|
2104
|
+
palette[i] &= 4294967040 | alphaPalette[i];
|
|
2105
|
+
channels = 4;
|
|
2106
|
+
const newPixels = new Uint8Array(width * height * 4);
|
|
2107
|
+
const pixelView = new DataView(newPixels.buffer, newPixels.byteOffset, newPixels.byteLength);
|
|
2108
|
+
for (let i = 0; i < pixels.length; i++)
|
|
2109
|
+
pixelView.setUint32(i * 4, palette[pixels[i]], false);
|
|
2110
|
+
pixels = newPixels;
|
|
2111
|
+
}
|
|
2112
|
+
if (bpc !== 8) {
|
|
2113
|
+
const newPixels = new Uint8Array(pixels.length / bpc * 8);
|
|
2114
|
+
for (let i = 0; i < pixels.length; i += 2)
|
|
2115
|
+
newPixels[i / 2] = pixels[i];
|
|
2116
|
+
pixels = newPixels;
|
|
2117
|
+
}
|
|
2118
|
+
if (channels !== 4) {
|
|
2119
|
+
const newPixels = new Uint8Array(width * height * 4);
|
|
2120
|
+
const view4 = new DataView(newPixels.buffer);
|
|
2121
|
+
if (channels === 1) {
|
|
2122
|
+
for (let i = 0; i < width * height; i++) {
|
|
2123
|
+
const pixel = pixels[i];
|
|
2124
|
+
view4.setUint32(i * 4, pixel << 24 | pixel << 16 | pixel << 8 | 255, false);
|
|
2125
|
+
}
|
|
2126
|
+
} else if (channels === 2) {
|
|
2127
|
+
for (let i = 0; i < width * height * 2; i += 2) {
|
|
2128
|
+
const pixel = pixels[i];
|
|
2129
|
+
view4.setUint32(i * 2, pixel << 24 | pixel << 16 | pixel << 8 | pixels[i + 1], false);
|
|
2130
|
+
}
|
|
2131
|
+
} else if (channels === 3) {
|
|
2132
|
+
newPixels.fill(255);
|
|
2133
|
+
for (let i = 0; i < width * height; i++)
|
|
2134
|
+
newPixels.set(pixels.subarray(i * 3, i * 3 + 3), i * 4);
|
|
2135
|
+
}
|
|
2136
|
+
pixels = newPixels;
|
|
2137
|
+
}
|
|
2138
|
+
return { width, height, buffer: pixels };
|
|
2139
|
+
}
|
|
2140
|
+
function filter_1(slice, pixels, p_offset, bytespp, row_length) {
|
|
2141
|
+
let i = 0;
|
|
2142
|
+
while (i < bytespp)
|
|
2143
|
+
pixels[i + p_offset] = slice[i++];
|
|
2144
|
+
while (i < row_length)
|
|
2145
|
+
pixels[i + p_offset] = slice[i] + pixels[i++ + p_offset - bytespp];
|
|
2146
|
+
}
|
|
2147
|
+
function filter_2(slice, pixels, p_offset, bytespp, row_length) {
|
|
2148
|
+
if (p_offset === 0)
|
|
2149
|
+
pixels.set(slice, p_offset);
|
|
2150
|
+
else {
|
|
2151
|
+
let i = 0;
|
|
2152
|
+
while (i < row_length)
|
|
2153
|
+
pixels[i + p_offset] = slice[i] + pixels[i++ + p_offset - row_length];
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
function filter_3(slice, pixels, p_offset, bytespp, row_length) {
|
|
2157
|
+
let i = 0;
|
|
2158
|
+
if (p_offset === 0) {
|
|
2159
|
+
while (i < bytespp)
|
|
2160
|
+
pixels[i] = slice[i++];
|
|
2161
|
+
while (i < row_length)
|
|
2162
|
+
pixels[i] = slice[i] + (pixels[i++ - bytespp] >> 1);
|
|
2163
|
+
} else {
|
|
2164
|
+
while (i < bytespp)
|
|
2165
|
+
pixels[i + p_offset] = slice[i] + (pixels[i++ + p_offset - row_length] >> 1);
|
|
2166
|
+
while (i < row_length)
|
|
2167
|
+
pixels[i + p_offset] = slice[i] + (pixels[i + p_offset - bytespp] + pixels[i++ + p_offset - row_length] >> 1);
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
function filter_4(slice, pixels, p_offset, bytespp, row_length) {
|
|
2171
|
+
let i = 0;
|
|
2172
|
+
if (p_offset === 0) {
|
|
2173
|
+
while (i < bytespp)
|
|
2174
|
+
pixels[i] = slice[i++];
|
|
2175
|
+
while (i < row_length)
|
|
2176
|
+
pixels[i] = slice[i] + pixels[i++ - bytespp];
|
|
2177
|
+
} else {
|
|
2178
|
+
while (i < bytespp)
|
|
2179
|
+
pixels[i + p_offset] = slice[i] + pixels[i++ + p_offset - row_length];
|
|
2180
|
+
while (i < row_length) {
|
|
2181
|
+
const a = pixels[i + p_offset - bytespp];
|
|
2182
|
+
const b = pixels[i + p_offset - row_length];
|
|
2183
|
+
const c = pixels[i + p_offset - bytespp - row_length];
|
|
2184
|
+
const p = a + b - c;
|
|
2185
|
+
const pa = Math.abs(p - a);
|
|
2186
|
+
const pb = Math.abs(p - b);
|
|
2187
|
+
const pc = Math.abs(p - c);
|
|
2188
|
+
pixels[i + p_offset] = slice[i++] + (pa <= pb && pa <= pc ? a : pb <= pc ? b : c);
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
// v2/framebuffer.mjs
|
|
2194
|
+
var framebuffer = class {
|
|
2195
|
+
constructor(width, height, buffer) {
|
|
2196
|
+
this.width = width | 0;
|
|
2197
|
+
this.height = height | 0;
|
|
2198
|
+
this.u8 = buffer ? view(buffer) : new Uint8Array(4 * this.width * this.height);
|
|
2199
|
+
this.view = new DataView(this.u8.buffer, this.u8.byteOffset, this.u8.byteLength);
|
|
2200
|
+
this.u32 = new Uint32Array(this.u8.buffer, this.u8.byteOffset, this.u8.byteLength / 4);
|
|
2201
|
+
if (this.u8.length !== 4 * this.width * this.height)
|
|
2202
|
+
throw new RangeError("invalid capacity of buffer");
|
|
2203
|
+
}
|
|
2204
|
+
[Symbol.iterator]() {
|
|
2205
|
+
return iterator_exports.cords(this);
|
|
2206
|
+
}
|
|
2207
|
+
toString() {
|
|
2208
|
+
return `framebuffer<${this.width}x${this.height}>`;
|
|
2209
|
+
}
|
|
2210
|
+
get(x2, y) {
|
|
2211
|
+
return this.view.getUint32((x2 | 0) + (y | 0) * this.width, false);
|
|
2212
|
+
}
|
|
2213
|
+
clone() {
|
|
2214
|
+
return new this.constructor(this.width, this.height, this.u8.slice());
|
|
2215
|
+
}
|
|
2216
|
+
set(x2, y, color3) {
|
|
2217
|
+
this.view.setUint32((x2 | 0) + (y | 0) * this.width, color3, false);
|
|
2218
|
+
}
|
|
2219
|
+
toJSON() {
|
|
2220
|
+
return { width: this.width, height: this.height, buffer: Array.from(this.u8) };
|
|
2221
|
+
}
|
|
2222
|
+
scale(type, factor) {
|
|
2223
|
+
return this.resize(type, factor * this.width, factor * this.height);
|
|
2224
|
+
}
|
|
2225
|
+
overlay(frame, x2 = 0, y = 0) {
|
|
2226
|
+
return overlay_exports.blend(this, frame, x2 | 0, y | 0), this;
|
|
2227
|
+
}
|
|
2228
|
+
replace(frame, x2 = 0, y = 0) {
|
|
2229
|
+
return overlay_exports.replace(this, frame, x2 | 0, y | 0), this;
|
|
2230
|
+
}
|
|
2231
|
+
at(x2, y) {
|
|
2232
|
+
const offset = 4 * ((x2 | 0) + (y | 0) * this.width);
|
|
2233
|
+
return this.u8.subarray(offset, 4 + offset);
|
|
2234
|
+
}
|
|
2235
|
+
static from(framebuffer2) {
|
|
2236
|
+
return new this(framebuffer2.width, framebuffer2.height, framebuffer2.u8 || framebuffer2.buffer);
|
|
2237
|
+
}
|
|
2238
|
+
static decode(format, buffer) {
|
|
2239
|
+
if (format !== "png")
|
|
2240
|
+
throw new RangeError("invalid image format");
|
|
2241
|
+
else
|
|
2242
|
+
return framebuffer.from(decode(buffer));
|
|
2243
|
+
}
|
|
2244
|
+
encode(format, options = {}) {
|
|
2245
|
+
var _a2;
|
|
2246
|
+
if (format !== "png")
|
|
2247
|
+
throw new RangeError("invalid image format");
|
|
2248
|
+
else
|
|
2249
|
+
return encode(this.u8, { channels: 4, width: this.width, height: this.height, level: (_a2 = { none: 0, fast: 3, default: 6, best: 9 }[options.compression]) != null ? _a2 : 3 });
|
|
2250
|
+
}
|
|
2251
|
+
pixels(type) {
|
|
2252
|
+
if (type === "rgba")
|
|
2253
|
+
return iterator_exports.rgba(this);
|
|
2254
|
+
if (!type || type === "int")
|
|
2255
|
+
return iterator_exports.u32(this);
|
|
2256
|
+
throw new RangeError("invalid iterator type");
|
|
2257
|
+
}
|
|
2258
|
+
flip(type) {
|
|
2259
|
+
if (type === "vertical")
|
|
2260
|
+
flip_exports.vertical(this);
|
|
2261
|
+
else if (type === "horizontal")
|
|
2262
|
+
flip_exports.horizontal(this);
|
|
2263
|
+
else
|
|
2264
|
+
throw new RangeError("invalid flip type");
|
|
2265
|
+
return this;
|
|
2266
|
+
}
|
|
2267
|
+
crop(type, arg0, arg1, arg2, arg3) {
|
|
2268
|
+
if (type === "circle")
|
|
2269
|
+
crop_exports.circle(arg0 || 0, this);
|
|
2270
|
+
else if (type === "box")
|
|
2271
|
+
crop_exports.crop(arg0 | 0, arg1 | 0, arg2 | 0, arg3 | 0, this);
|
|
2272
|
+
else
|
|
2273
|
+
throw new RangeError("invalid crop type");
|
|
2274
|
+
return this;
|
|
2275
|
+
}
|
|
2276
|
+
cut(type, arg0, arg1, arg2, arg3) {
|
|
2277
|
+
if (type === "circle")
|
|
2278
|
+
return crop_exports.circle(arg0 || 0, this.clone());
|
|
2279
|
+
else if (type === "box")
|
|
2280
|
+
return crop_exports.cut(arg0 | 0, arg1 | 0, arg2 | 0, arg3 | 0, this);
|
|
2281
|
+
else
|
|
2282
|
+
throw new RangeError("invalid cut type");
|
|
2283
|
+
}
|
|
2284
|
+
rotate(deg, resize = true) {
|
|
2285
|
+
if ((deg %= 360) === 0)
|
|
2286
|
+
return this;
|
|
2287
|
+
else if (deg === 90)
|
|
2288
|
+
rotate_exports.rotate90(this);
|
|
2289
|
+
else if (deg === 180)
|
|
2290
|
+
rotate_exports.rotate180(this);
|
|
2291
|
+
else if (deg === 270)
|
|
2292
|
+
rotate_exports.rotate270(this);
|
|
2293
|
+
else
|
|
2294
|
+
rotate_exports.rotate(deg, this, resize);
|
|
2295
|
+
return this;
|
|
2296
|
+
}
|
|
2297
|
+
blur(type, arg0) {
|
|
2298
|
+
if (type === "cubic")
|
|
2299
|
+
blur_exports.cubic(this);
|
|
2300
|
+
else if (type === "box")
|
|
2301
|
+
blur_exports.box(+arg0, this);
|
|
2302
|
+
else if (type === "gaussian")
|
|
2303
|
+
blur_exports.gaussian(+arg0, this);
|
|
2304
|
+
else
|
|
2305
|
+
throw new RangeError("invalid blur type");
|
|
2306
|
+
return this;
|
|
2307
|
+
}
|
|
2308
|
+
fill(color3) {
|
|
2309
|
+
const type = typeof color3;
|
|
2310
|
+
if (type === "function")
|
|
2311
|
+
fill_exports.fn(color3, this);
|
|
2312
|
+
else if (type === "number")
|
|
2313
|
+
fill_exports.color(color3, this);
|
|
2314
|
+
else if (color3 instanceof color)
|
|
2315
|
+
fill_exports.color(color3.valueOf(), this);
|
|
2316
|
+
else if (Array.isArray(color3))
|
|
2317
|
+
fill_exports.color(color_exports.from_rgba(...color3), this);
|
|
2318
|
+
else
|
|
2319
|
+
throw new TypeError("invalid fill color");
|
|
2320
|
+
return this;
|
|
2321
|
+
}
|
|
2322
|
+
swap(old, color3) {
|
|
2323
|
+
const ot = typeof old;
|
|
2324
|
+
const nt = typeof color3;
|
|
2325
|
+
if (ot === nt && ot === "number")
|
|
2326
|
+
fill_exports.swap(old, color3, this);
|
|
2327
|
+
else if (old instanceof color && color3 instanceof color)
|
|
2328
|
+
fill_exports.swap(old.valueOf(), color3.valueOf(), this);
|
|
2329
|
+
else if (Array.isArray(old) && Array.isArray(color3))
|
|
2330
|
+
fill_exports.swap(color_exports.from_rgba(...old), color_exports.from_rgba(...color3), this);
|
|
2331
|
+
else
|
|
2332
|
+
throw new RangeError("invalid swap color");
|
|
2333
|
+
return this;
|
|
2334
|
+
}
|
|
2335
|
+
resize(type, width, height) {
|
|
2336
|
+
if (width === this.width && height === this.height)
|
|
2337
|
+
return this;
|
|
2338
|
+
else if (type === "cubic")
|
|
2339
|
+
resize_exports.cubic(width, height, this);
|
|
2340
|
+
else if (type === "linear")
|
|
2341
|
+
resize_exports.linear(width, height, this);
|
|
2342
|
+
else if (type === "nearest")
|
|
2343
|
+
resize_exports.nearest(width, height, this);
|
|
2344
|
+
else
|
|
2345
|
+
throw new RangeError("invalid resize type");
|
|
2346
|
+
return this;
|
|
2347
|
+
}
|
|
2348
|
+
};
|
|
2349
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2350
|
+
0 && (module.exports = {
|
|
2351
|
+
Color
|
|
2352
|
+
});
|