imagescript 1.2.15 → 1.2.17

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.
Files changed (53) hide show
  1. package/ImageScript.d.ts +233 -223
  2. package/ImageScript.js +1658 -1646
  3. package/LICENSE +12 -619
  4. package/LICENSE.AGPL-3.0 +619 -0
  5. package/LICENSE.MIT +19 -0
  6. package/README.md +51 -46
  7. package/bench/_.mjs +165 -165
  8. package/bench/all.mjs +3 -3
  9. package/bench/blur.mjs +58 -58
  10. package/bench/flip.mjs +62 -62
  11. package/bench/overlay.mjs +34 -34
  12. package/bench/package.json +6 -6
  13. package/bench/readme.md +63 -63
  14. package/bench/resize.mjs +51 -51
  15. package/codecs/LICENSE +20 -20
  16. package/codecs/lib.d.ts +49 -49
  17. package/codecs/lib.js +5 -5
  18. package/codecs/node/index.js +2 -2
  19. package/codecs/node/index.mjs +5 -5
  20. package/codecs/package.json +13 -13
  21. package/codecs/readme.md +37 -37
  22. package/package.json +41 -41
  23. package/png/node.js +1137 -1137
  24. package/png/src/crc.mjs +48 -48
  25. package/png/src/mem.mjs +23 -23
  26. package/png/src/png.mjs +254 -254
  27. package/png/src/zlib.mjs +617 -617
  28. package/tsconfig.json +21 -21
  29. package/utils/mem.js +25 -25
  30. package/v2/codecs/magic.js +24 -24
  31. package/v2/framebuffer.d.ts +66 -66
  32. package/v2/framebuffer.js +2352 -2352
  33. package/v2/framebuffer.mjs +125 -125
  34. package/v2/framebuffer.rs +1263 -1263
  35. package/v2/index.d.ts +83 -83
  36. package/v2/index.js +260 -260
  37. package/v2/ops/blur.mjs +302 -302
  38. package/v2/ops/color.mjs +276 -276
  39. package/v2/ops/crop.mjs +63 -63
  40. package/v2/ops/fill.mjs +32 -32
  41. package/v2/ops/flip.mjs +32 -32
  42. package/v2/ops/index.mjs +8 -8
  43. package/v2/ops/iterator.mjs +33 -33
  44. package/v2/ops/overlay.mjs +62 -62
  45. package/v2/ops/resize.mjs +165 -165
  46. package/v2/ops/rotate.mjs +116 -116
  47. package/v2/util/mem.mjs +23 -23
  48. package/wasm/node/font.js +141 -141
  49. package/wasm/node/gif.js +76 -76
  50. package/wasm/node/jpeg.js +91 -91
  51. package/wasm/node/png.js +49 -49
  52. package/wasm/node/svg.js +55 -55
  53. package/wasm/node/tiff.js +46 -46
package/v2/ops/blur.mjs CHANGED
@@ -1,303 +1,303 @@
1
- export function cubic(framebuffer) {
2
- const width = framebuffer.width;
3
- const height = framebuffer.height;
4
- framebuffer.resize('cubic', Math.max(1, .008 * width), Math.max(1, .008 * height));
5
-
6
- framebuffer.resize('cubic', width, height);
7
- }
8
-
9
- export function box(radius, framebuffer) {
10
- if (!radius) return;
11
- const u8 = framebuffer.u8;
12
- const width = framebuffer.width;
13
- const height = framebuffer.height;
14
- const old = framebuffer.u8.slice();
15
- bb(u8, old, width, height, radius);
16
- }
17
-
18
- export function gaussian(radius, framebuffer) {
19
- if (0 >= radius) return;
20
- const a = Math.exp(.726 ** 2) / radius;
21
-
22
- const g1 = Math.exp(-a);
23
- const g2 = Math.exp(a * -2);
24
- const old = framebuffer.u8.slice();
25
- const k = ((1 - g1) ** 2) / (1 - g2 + 2 * a * g1);
26
-
27
- const b2 = -g2;
28
- const b1 = 2 * g1;
29
- const a3 = -k * g2;
30
- const a1 = k * g1 * (a - 1);
31
- const a2 = k * g1 * (a + 1);
32
- const lc = (k + a1) / (1 - b1 - b2);
33
- const width = framebuffer.width | 0;
34
- const rc = (a2 + a3) / (1 - b1 - b2);
35
- const height = framebuffer.height | 0;
36
- const tmp = new Float32Array(4 * Math.max(width, height));
37
- gc(old, framebuffer.u8, tmp, width, height, k, a1, a2, a3, b1, b2, lc, rc);
38
- gc(framebuffer.u8, old, tmp, height, width, k, a1, a2, a3, b1, b2, lc, rc);
39
- }
40
-
41
- function bb(u8, old, width, height, radius) {
42
- const divisor = 1 / (1 + radius + radius);
43
- bbt(u8, old, width, height, radius, divisor);
44
- bbh(u8, old, width, height, radius, divisor);
45
- }
46
-
47
- function bbh(u8, old, width, height, radius, divisor) {
48
- for (var y = 0; y < height; y++) {
49
- let y_offset = y * width;
50
-
51
- let li = y_offset;
52
- let ri = radius + y_offset;
53
- const fv_offset = 4 * y_offset;
54
- const lv_offset = 4 * (width - 1 + y_offset);
55
-
56
- const rfv = old[fv_offset];
57
- const gfv = old[1 + fv_offset];
58
- const bfv = old[2 + fv_offset];
59
- const afv = old[3 + fv_offset];
60
-
61
- const rlv = old[lv_offset];
62
- const glv = old[1 + lv_offset];
63
- const blv = old[2 + lv_offset];
64
- const alv = old[3 + lv_offset];
65
-
66
- let r = rfv * (1 + radius);
67
- let g = gfv * (1 + radius);
68
- let b = bfv * (1 + radius);
69
- let a = afv * (1 + radius);
70
-
71
- for (let x = 0; x < radius; x++) {
72
- const offset = 4 * (x + y_offset);
73
-
74
- r += old[offset];
75
- g += old[1 + offset];
76
- b += old[2 + offset];
77
- a += old[3 + offset];
78
- }
79
-
80
- for (let x = 0; x <= radius; x++) {
81
- let offset = 4 * ri++;
82
- r += old[offset] - rfv;
83
- g += old[1 + offset] - gfv;
84
- b += old[2 + offset] - bfv;
85
- a += old[3 + offset] - afv;
86
-
87
- offset = 4 * y_offset++;
88
- u8[offset] = Math.round(r * divisor);
89
- u8[1 + offset] = Math.round(g * divisor);
90
- u8[2 + offset] = Math.round(b * divisor);
91
- u8[3 + offset] = Math.round(a * divisor);
92
- }
93
-
94
- for (let x = 1 + radius; x < (width - radius); x++) {
95
- let offset = 4 * ri++;
96
- const roffset = 4 * li++;
97
- r += old[offset] - old[roffset];
98
- g += old[1 + offset] - old[1 + roffset];
99
- b += old[2 + offset] - old[2 + roffset];
100
- a += old[3 + offset] - old[3 + roffset];
101
- // todo: how far is roffset
102
-
103
- offset = 4 * y_offset++;
104
- u8[offset] = Math.round(r * divisor);
105
- u8[1 + offset] = Math.round(g * divisor);
106
- u8[2 + offset] = Math.round(b * divisor);
107
- u8[3 + offset] = Math.round(a * divisor);
108
- }
109
-
110
- for (let x = width - radius; x < width; x++) {
111
- let offset = 4 * li++;
112
- r += rlv - old[offset];
113
- g += glv - old[1 + offset];
114
- b += blv - old[2 + offset];
115
- a += alv - old[3 + offset];
116
-
117
- offset = 4 * y_offset++;
118
- u8[offset] = Math.round(r * divisor);
119
- u8[1 + offset] = Math.round(g * divisor);
120
- u8[2 + offset] = Math.round(b * divisor);
121
- u8[3 + offset] = Math.round(a * divisor);
122
- }
123
- }
124
- }
125
-
126
- function bbt(u8, old, width, height, radius, divisor) {
127
- for (var x = 0; x < width; x++) {
128
- let ti = x;
129
- let li = ti;
130
- const fv_offset = 4 * ti;
131
- let ri = ti + width * radius;
132
- const lv_offset = 4 * (ti + width * (height - 1));
133
-
134
- const rfv = old[fv_offset];
135
- const gfv = old[1 + fv_offset];
136
- const bfv = old[2 + fv_offset];
137
- const afv = old[3 + fv_offset];
138
-
139
- const rlv = old[lv_offset];
140
- const glv = old[1 + lv_offset];
141
- const blv = old[2 + lv_offset];
142
- const alv = old[3 + lv_offset];
143
-
144
- let r = rfv * (1 + radius);
145
- let g = gfv * (1 + radius);
146
- let b = bfv * (1 + radius);
147
- let a = afv * (1 + radius);
148
-
149
- for (let y = 0; y < radius; y++) {
150
- const offset = 4 * (ti + y * width);
151
-
152
- r += old[offset];
153
- g += old[1 + offset];
154
- b += old[2 + offset];
155
- a += old[3 + offset];
156
- }
157
-
158
- for (let y = 0; y <= radius; y++) {
159
- let offset = 4 * ri;
160
- r += old[offset] - rfv;
161
- g += old[1 + offset] - gfv;
162
- b += old[2 + offset] - bfv;
163
- a += old[3 + offset] - afv;
164
-
165
- offset = 4 * ti;
166
- u8[offset] = Math.round(r * divisor);
167
- u8[1 + offset] = Math.round(g * divisor);
168
- u8[2 + offset] = Math.round(b * divisor);
169
- u8[3 + offset] = Math.round(a * divisor);
170
-
171
- ri += width;
172
- ti += width;
173
- }
174
-
175
- for (let y = 1 + radius; y < (height - radius); y++) {
176
- let offset = 4 * ri;
177
- const xoffset = 4 * li;
178
- r += old[offset] - old[xoffset];
179
- g += old[1 + offset] - old[1 + xoffset];
180
- b += old[2 + offset] - old[2 + xoffset];
181
- a += old[3 + offset] - old[3 + xoffset];
182
- // todo: how far is xoffset
183
-
184
- offset = 4 * ti;
185
- u8[offset] = Math.round(r * divisor);
186
- u8[1 + offset] = Math.round(g * divisor);
187
- u8[2 + offset] = Math.round(b * divisor);
188
- u8[3 + offset] = Math.round(a * divisor);
189
-
190
- li += width;
191
- ri += width;
192
- ti += width;
193
- }
194
-
195
- for (let y = height - radius; y < height; y++) {
196
- let offset = 4 * li;
197
- r += rlv - old[offset];
198
- g += glv - old[1 + offset];
199
- b += blv - old[2 + offset];
200
- a += alv - old[3 + offset];
201
-
202
- offset = 4 * ti;
203
- u8[offset] = Math.round(r * divisor);
204
- u8[1 + offset] = Math.round(g * divisor);
205
- u8[2 + offset] = Math.round(b * divisor);
206
- u8[3 + offset] = Math.round(a * divisor);
207
-
208
- li += width;
209
- ti += width;
210
- }
211
- }
212
- }
213
-
214
- function gc(u8, old, tmp, width, height, k, a1, a2, a3, b1, b2, lc, rc) {
215
- const width4 = width * 4;
216
- const height4 = height * 4;
217
- const hw1 = height * (width - 1);
218
-
219
- for (let y = 0; y < height; y++) {
220
- let toffset = 0 | 0;
221
- let ooffset = (y * width4) | 0;
222
- let offset = (4 * (y + hw1)) | 0;
223
-
224
- let por = old[ooffset];
225
- let pog = old[1 + ooffset];
226
- let pob = old[2 + ooffset];
227
- let poa = old[3 + ooffset];
228
-
229
- let pur = lc * por;
230
- let pug = lc * pog;
231
- let pub = lc * pob;
232
- let pua = lc * poa;
233
-
234
- let ppur = pur;
235
- let ppug = pug;
236
- let ppub = pub;
237
- let ppua = pua;
238
-
239
- for (let x = 0; x < width; x++) {
240
- const cor = old[ooffset++];
241
- const cog = old[ooffset++];
242
- const cob = old[ooffset++];
243
- const coa = old[ooffset++];
244
-
245
- const cur = k * cor + a1 * por + b1 * pur + b2 * ppur;
246
- const cug = k * cog + a1 * pog + b1 * pug + b2 * ppug;
247
- const cub = k * cob + a1 * pob + b1 * pub + b2 * ppub;
248
- const cua = k * coa + a1 * poa + b1 * pua + b2 * ppua;
249
-
250
- ppur = pur; pur = cur; por = cor;
251
- ppug = pug; pug = cug; pog = cog;
252
- ppub = pub; pub = cub; pob = cob;
253
- ppua = pua; pua = cua; poa = coa;
254
-
255
- tmp[toffset++] = pur;
256
- tmp[toffset++] = pug;
257
- tmp[toffset++] = pub;
258
- tmp[toffset++] = pua;
259
- }
260
-
261
- ooffset -= 4;
262
- toffset -= 4;
263
- ppur = rc * (por = old[ooffset]);
264
- ppug = rc * (pog = old[1 + ooffset]);
265
- ppub = rc * (pob = old[2 + ooffset]);
266
- ppua = rc * (poa = old[3 + ooffset]);
267
-
268
- pur = ppur;
269
- pug = ppug;
270
- pub = ppub;
271
- pua = ppua;
272
- let cor = por;
273
- let cog = pog;
274
- let cob = pob;
275
- let coa = poa;
276
-
277
- for (let x = width - 1; 0 <= x; x--) {
278
- const cur = a2 * cor + a3 * por + b1 * pur + b2 * ppur;
279
- const cug = a2 * cog + a3 * pog + b1 * pug + b2 * ppug;
280
- const cub = a2 * cob + a3 * pob + b1 * pub + b2 * ppub;
281
- const cua = a2 * coa + a3 * poa + b1 * pua + b2 * ppua;
282
-
283
- ppur = pur; pur = cur; por = cor;
284
- ppug = pug; pug = cug; pog = cog;
285
- ppub = pub; pub = cub; pob = cob;
286
- ppua = pua; pua = cua; poa = coa;
287
-
288
- cor = old[ooffset];
289
- cog = old[1 + ooffset];
290
- cob = old[2 + ooffset];
291
- coa = old[3 + ooffset];
292
-
293
- u8[offset] = pur + tmp[toffset];
294
- u8[1 + offset] = pug + tmp[1 + toffset];
295
- u8[2 + offset] = pub + tmp[2 + toffset];
296
- u8[3 + offset] = pua + tmp[3 + toffset];
297
-
298
- ooffset -= 4;
299
- toffset -= 4;
300
- offset -= height4;
301
- }
302
- }
1
+ export function cubic(framebuffer) {
2
+ const width = framebuffer.width;
3
+ const height = framebuffer.height;
4
+ framebuffer.resize('cubic', Math.max(1, .008 * width), Math.max(1, .008 * height));
5
+
6
+ framebuffer.resize('cubic', width, height);
7
+ }
8
+
9
+ export function box(radius, framebuffer) {
10
+ if (!radius) return;
11
+ const u8 = framebuffer.u8;
12
+ const width = framebuffer.width;
13
+ const height = framebuffer.height;
14
+ const old = framebuffer.u8.slice();
15
+ bb(u8, old, width, height, radius);
16
+ }
17
+
18
+ export function gaussian(radius, framebuffer) {
19
+ if (0 >= radius) return;
20
+ const a = Math.exp(.726 ** 2) / radius;
21
+
22
+ const g1 = Math.exp(-a);
23
+ const g2 = Math.exp(a * -2);
24
+ const old = framebuffer.u8.slice();
25
+ const k = ((1 - g1) ** 2) / (1 - g2 + 2 * a * g1);
26
+
27
+ const b2 = -g2;
28
+ const b1 = 2 * g1;
29
+ const a3 = -k * g2;
30
+ const a1 = k * g1 * (a - 1);
31
+ const a2 = k * g1 * (a + 1);
32
+ const lc = (k + a1) / (1 - b1 - b2);
33
+ const width = framebuffer.width | 0;
34
+ const rc = (a2 + a3) / (1 - b1 - b2);
35
+ const height = framebuffer.height | 0;
36
+ const tmp = new Float32Array(4 * Math.max(width, height));
37
+ gc(old, framebuffer.u8, tmp, width, height, k, a1, a2, a3, b1, b2, lc, rc);
38
+ gc(framebuffer.u8, old, tmp, height, width, k, a1, a2, a3, b1, b2, lc, rc);
39
+ }
40
+
41
+ function bb(u8, old, width, height, radius) {
42
+ const divisor = 1 / (1 + radius + radius);
43
+ bbt(u8, old, width, height, radius, divisor);
44
+ bbh(u8, old, width, height, radius, divisor);
45
+ }
46
+
47
+ function bbh(u8, old, width, height, radius, divisor) {
48
+ for (var y = 0; y < height; y++) {
49
+ let y_offset = y * width;
50
+
51
+ let li = y_offset;
52
+ let ri = radius + y_offset;
53
+ const fv_offset = 4 * y_offset;
54
+ const lv_offset = 4 * (width - 1 + y_offset);
55
+
56
+ const rfv = old[fv_offset];
57
+ const gfv = old[1 + fv_offset];
58
+ const bfv = old[2 + fv_offset];
59
+ const afv = old[3 + fv_offset];
60
+
61
+ const rlv = old[lv_offset];
62
+ const glv = old[1 + lv_offset];
63
+ const blv = old[2 + lv_offset];
64
+ const alv = old[3 + lv_offset];
65
+
66
+ let r = rfv * (1 + radius);
67
+ let g = gfv * (1 + radius);
68
+ let b = bfv * (1 + radius);
69
+ let a = afv * (1 + radius);
70
+
71
+ for (let x = 0; x < radius; x++) {
72
+ const offset = 4 * (x + y_offset);
73
+
74
+ r += old[offset];
75
+ g += old[1 + offset];
76
+ b += old[2 + offset];
77
+ a += old[3 + offset];
78
+ }
79
+
80
+ for (let x = 0; x <= radius; x++) {
81
+ let offset = 4 * ri++;
82
+ r += old[offset] - rfv;
83
+ g += old[1 + offset] - gfv;
84
+ b += old[2 + offset] - bfv;
85
+ a += old[3 + offset] - afv;
86
+
87
+ offset = 4 * y_offset++;
88
+ u8[offset] = Math.round(r * divisor);
89
+ u8[1 + offset] = Math.round(g * divisor);
90
+ u8[2 + offset] = Math.round(b * divisor);
91
+ u8[3 + offset] = Math.round(a * divisor);
92
+ }
93
+
94
+ for (let x = 1 + radius; x < (width - radius); x++) {
95
+ let offset = 4 * ri++;
96
+ const roffset = 4 * li++;
97
+ r += old[offset] - old[roffset];
98
+ g += old[1 + offset] - old[1 + roffset];
99
+ b += old[2 + offset] - old[2 + roffset];
100
+ a += old[3 + offset] - old[3 + roffset];
101
+ // todo: how far is roffset
102
+
103
+ offset = 4 * y_offset++;
104
+ u8[offset] = Math.round(r * divisor);
105
+ u8[1 + offset] = Math.round(g * divisor);
106
+ u8[2 + offset] = Math.round(b * divisor);
107
+ u8[3 + offset] = Math.round(a * divisor);
108
+ }
109
+
110
+ for (let x = width - radius; x < width; x++) {
111
+ let offset = 4 * li++;
112
+ r += rlv - old[offset];
113
+ g += glv - old[1 + offset];
114
+ b += blv - old[2 + offset];
115
+ a += alv - old[3 + offset];
116
+
117
+ offset = 4 * y_offset++;
118
+ u8[offset] = Math.round(r * divisor);
119
+ u8[1 + offset] = Math.round(g * divisor);
120
+ u8[2 + offset] = Math.round(b * divisor);
121
+ u8[3 + offset] = Math.round(a * divisor);
122
+ }
123
+ }
124
+ }
125
+
126
+ function bbt(u8, old, width, height, radius, divisor) {
127
+ for (var x = 0; x < width; x++) {
128
+ let ti = x;
129
+ let li = ti;
130
+ const fv_offset = 4 * ti;
131
+ let ri = ti + width * radius;
132
+ const lv_offset = 4 * (ti + width * (height - 1));
133
+
134
+ const rfv = old[fv_offset];
135
+ const gfv = old[1 + fv_offset];
136
+ const bfv = old[2 + fv_offset];
137
+ const afv = old[3 + fv_offset];
138
+
139
+ const rlv = old[lv_offset];
140
+ const glv = old[1 + lv_offset];
141
+ const blv = old[2 + lv_offset];
142
+ const alv = old[3 + lv_offset];
143
+
144
+ let r = rfv * (1 + radius);
145
+ let g = gfv * (1 + radius);
146
+ let b = bfv * (1 + radius);
147
+ let a = afv * (1 + radius);
148
+
149
+ for (let y = 0; y < radius; y++) {
150
+ const offset = 4 * (ti + y * width);
151
+
152
+ r += old[offset];
153
+ g += old[1 + offset];
154
+ b += old[2 + offset];
155
+ a += old[3 + offset];
156
+ }
157
+
158
+ for (let y = 0; y <= radius; y++) {
159
+ let offset = 4 * ri;
160
+ r += old[offset] - rfv;
161
+ g += old[1 + offset] - gfv;
162
+ b += old[2 + offset] - bfv;
163
+ a += old[3 + offset] - afv;
164
+
165
+ offset = 4 * ti;
166
+ u8[offset] = Math.round(r * divisor);
167
+ u8[1 + offset] = Math.round(g * divisor);
168
+ u8[2 + offset] = Math.round(b * divisor);
169
+ u8[3 + offset] = Math.round(a * divisor);
170
+
171
+ ri += width;
172
+ ti += width;
173
+ }
174
+
175
+ for (let y = 1 + radius; y < (height - radius); y++) {
176
+ let offset = 4 * ri;
177
+ const xoffset = 4 * li;
178
+ r += old[offset] - old[xoffset];
179
+ g += old[1 + offset] - old[1 + xoffset];
180
+ b += old[2 + offset] - old[2 + xoffset];
181
+ a += old[3 + offset] - old[3 + xoffset];
182
+ // todo: how far is xoffset
183
+
184
+ offset = 4 * ti;
185
+ u8[offset] = Math.round(r * divisor);
186
+ u8[1 + offset] = Math.round(g * divisor);
187
+ u8[2 + offset] = Math.round(b * divisor);
188
+ u8[3 + offset] = Math.round(a * divisor);
189
+
190
+ li += width;
191
+ ri += width;
192
+ ti += width;
193
+ }
194
+
195
+ for (let y = height - radius; y < height; y++) {
196
+ let offset = 4 * li;
197
+ r += rlv - old[offset];
198
+ g += glv - old[1 + offset];
199
+ b += blv - old[2 + offset];
200
+ a += alv - old[3 + offset];
201
+
202
+ offset = 4 * ti;
203
+ u8[offset] = Math.round(r * divisor);
204
+ u8[1 + offset] = Math.round(g * divisor);
205
+ u8[2 + offset] = Math.round(b * divisor);
206
+ u8[3 + offset] = Math.round(a * divisor);
207
+
208
+ li += width;
209
+ ti += width;
210
+ }
211
+ }
212
+ }
213
+
214
+ function gc(u8, old, tmp, width, height, k, a1, a2, a3, b1, b2, lc, rc) {
215
+ const width4 = width * 4;
216
+ const height4 = height * 4;
217
+ const hw1 = height * (width - 1);
218
+
219
+ for (let y = 0; y < height; y++) {
220
+ let toffset = 0 | 0;
221
+ let ooffset = (y * width4) | 0;
222
+ let offset = (4 * (y + hw1)) | 0;
223
+
224
+ let por = old[ooffset];
225
+ let pog = old[1 + ooffset];
226
+ let pob = old[2 + ooffset];
227
+ let poa = old[3 + ooffset];
228
+
229
+ let pur = lc * por;
230
+ let pug = lc * pog;
231
+ let pub = lc * pob;
232
+ let pua = lc * poa;
233
+
234
+ let ppur = pur;
235
+ let ppug = pug;
236
+ let ppub = pub;
237
+ let ppua = pua;
238
+
239
+ for (let x = 0; x < width; x++) {
240
+ const cor = old[ooffset++];
241
+ const cog = old[ooffset++];
242
+ const cob = old[ooffset++];
243
+ const coa = old[ooffset++];
244
+
245
+ const cur = k * cor + a1 * por + b1 * pur + b2 * ppur;
246
+ const cug = k * cog + a1 * pog + b1 * pug + b2 * ppug;
247
+ const cub = k * cob + a1 * pob + b1 * pub + b2 * ppub;
248
+ const cua = k * coa + a1 * poa + b1 * pua + b2 * ppua;
249
+
250
+ ppur = pur; pur = cur; por = cor;
251
+ ppug = pug; pug = cug; pog = cog;
252
+ ppub = pub; pub = cub; pob = cob;
253
+ ppua = pua; pua = cua; poa = coa;
254
+
255
+ tmp[toffset++] = pur;
256
+ tmp[toffset++] = pug;
257
+ tmp[toffset++] = pub;
258
+ tmp[toffset++] = pua;
259
+ }
260
+
261
+ ooffset -= 4;
262
+ toffset -= 4;
263
+ ppur = rc * (por = old[ooffset]);
264
+ ppug = rc * (pog = old[1 + ooffset]);
265
+ ppub = rc * (pob = old[2 + ooffset]);
266
+ ppua = rc * (poa = old[3 + ooffset]);
267
+
268
+ pur = ppur;
269
+ pug = ppug;
270
+ pub = ppub;
271
+ pua = ppua;
272
+ let cor = por;
273
+ let cog = pog;
274
+ let cob = pob;
275
+ let coa = poa;
276
+
277
+ for (let x = width - 1; 0 <= x; x--) {
278
+ const cur = a2 * cor + a3 * por + b1 * pur + b2 * ppur;
279
+ const cug = a2 * cog + a3 * pog + b1 * pug + b2 * ppug;
280
+ const cub = a2 * cob + a3 * pob + b1 * pub + b2 * ppub;
281
+ const cua = a2 * coa + a3 * poa + b1 * pua + b2 * ppua;
282
+
283
+ ppur = pur; pur = cur; por = cor;
284
+ ppug = pug; pug = cug; pog = cog;
285
+ ppub = pub; pub = cub; pob = cob;
286
+ ppua = pua; pua = cua; poa = coa;
287
+
288
+ cor = old[ooffset];
289
+ cog = old[1 + ooffset];
290
+ cob = old[2 + ooffset];
291
+ coa = old[3 + ooffset];
292
+
293
+ u8[offset] = pur + tmp[toffset];
294
+ u8[1 + offset] = pug + tmp[1 + toffset];
295
+ u8[2 + offset] = pub + tmp[2 + toffset];
296
+ u8[3 + offset] = pua + tmp[3 + toffset];
297
+
298
+ ooffset -= 4;
299
+ toffset -= 4;
300
+ offset -= height4;
301
+ }
302
+ }
303
303
  }