pixel-data-js 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.dev.js CHANGED
@@ -1,106 +1,3 @@
1
- // src/color.ts
2
- function packColor(r, g, b, a) {
3
- return (a << 24 | b << 16 | g << 8 | r) >>> 0;
4
- }
5
- function packRGBA({ r, g, b, a }) {
6
- return (a << 24 | b << 16 | g << 8 | r) >>> 0;
7
- }
8
- var unpackRed = (packed) => packed >>> 0 & 255;
9
- var unpackGreen = (packed) => packed >>> 8 & 255;
10
- var unpackBlue = (packed) => packed >>> 16 & 255;
11
- var unpackAlpha = (packed) => packed >>> 24 & 255;
12
- function unpackColor(packed) {
13
- return {
14
- r: packed >>> 0 & 255,
15
- g: packed >>> 8 & 255,
16
- b: packed >>> 16 & 255,
17
- a: packed >>> 24 & 255
18
- };
19
- }
20
- var SCRATCH_RGBA = { r: 0, g: 0, b: 0, a: 0 };
21
- function unpackColorTo(packed, scratch = SCRATCH_RGBA) {
22
- scratch.r = packed >>> 0 & 255;
23
- scratch.g = packed >>> 8 & 255;
24
- scratch.b = packed >>> 16 & 255;
25
- scratch.a = packed >>> 24 & 255;
26
- return scratch;
27
- }
28
- function colorDistance(a, b) {
29
- const dr = (a & 255) - (b & 255);
30
- const dg = (a >>> 8 & 255) - (b >>> 8 & 255);
31
- const db = (a >>> 16 & 255) - (b >>> 16 & 255);
32
- const da = (a >>> 24 & 255) - (b >>> 24 & 255);
33
- return dr * dr + dg * dg + db * db + da * da;
34
- }
35
- function lerpColor32(a, b, t) {
36
- const r = (a & 255) + t * ((b & 255) - (a & 255));
37
- const g = (a >>> 8 & 255) + t * ((b >>> 8 & 255) - (a >>> 8 & 255));
38
- const b_ = (a >>> 16 & 255) + t * ((b >>> 16 & 255) - (a >>> 16 & 255));
39
- const a_ = (a >>> 24 & 255) + t * ((b >>> 24 & 255) - (a >>> 24 & 255));
40
- return (a_ << 24 | b_ << 16 | g << 8 | r) >>> 0;
41
- }
42
- function lerpColor32Fast(src, dst, w) {
43
- const invA = 255 - w;
44
- const rb = (src & 16711935) * w + (dst & 16711935) * invA >>> 8 & 16711935;
45
- const ga = (src >>> 8 & 16711935) * w + (dst >>> 8 & 16711935) * invA >>> 8 & 16711935;
46
- return (rb | ga << 8) >>> 0;
47
- }
48
- function color32ToHex(color) {
49
- const r = (color & 255).toString(16).padStart(2, "0");
50
- const g = (color >>> 8 & 255).toString(16).padStart(2, "0");
51
- const b = (color >>> 16 & 255).toString(16).padStart(2, "0");
52
- const a = (color >>> 24 & 255).toString(16).padStart(2, "0");
53
- return `#${r}${g}${b}${a}`;
54
- }
55
- function color32ToCssRGBA(color) {
56
- const r = color & 255;
57
- const g = color >>> 8 & 255;
58
- const b = color >>> 16 & 255;
59
- const a = color >>> 24 & 255;
60
- const alpha = Number((a / 255).toFixed(3));
61
- return `rgba(${r},${g},${b},${alpha})`;
62
- }
63
-
64
- // src/ImageData/serialization.ts
65
- function base64EncodeArrayBuffer(buffer) {
66
- const binary = String.fromCharCode(...new Uint8Array(buffer));
67
- return btoa(binary);
68
- }
69
- function base64DecodeArrayBuffer(encoded) {
70
- const binary = atob(encoded);
71
- const bytes = new Uint8ClampedArray(binary.length);
72
- for (let i = 0; i < binary.length; i++) {
73
- bytes[i] = binary.charCodeAt(i);
74
- }
75
- return bytes;
76
- }
77
- function serializeImageData(imageData) {
78
- return {
79
- width: imageData.width,
80
- height: imageData.height,
81
- data: base64EncodeArrayBuffer(imageData.data.buffer)
82
- };
83
- }
84
- function serializeNullableImageData(imageData) {
85
- if (!imageData) return null;
86
- return serializeImageData(imageData);
87
- }
88
- function deserializeRawImageData(serialized) {
89
- return {
90
- width: serialized.width,
91
- height: serialized.height,
92
- data: base64DecodeArrayBuffer(serialized.data)
93
- };
94
- }
95
- function deserializeImageData(serialized) {
96
- const data = base64DecodeArrayBuffer(serialized.data);
97
- return new ImageData(data, serialized.width, serialized.height);
98
- }
99
- function deserializeNullableImageData(serialized) {
100
- if (!serialized) return null;
101
- return deserializeImageData(serialized);
102
- }
103
-
104
1
  // src/ImageData/blend-modes.ts
105
2
  var sourceOverColor32 = (src, dst) => {
106
3
  const a = src >>> 24 & 255;
@@ -237,6 +134,13 @@ var COLOR_32_BLEND_MODES = {
237
134
  colorBurn: colorBurnColor32
238
135
  };
239
136
 
137
+ // src/_types.ts
138
+ var MaskType = /* @__PURE__ */ ((MaskType2) => {
139
+ MaskType2[MaskType2["ALPHA"] = 0] = "ALPHA";
140
+ MaskType2[MaskType2["BINARY"] = 1] = "BINARY";
141
+ return MaskType2;
142
+ })(MaskType || {});
143
+
240
144
  // src/ImageData/blit.ts
241
145
  function blendImageData(dst, src, opts) {
242
146
  let {
@@ -246,7 +150,6 @@ function blendImageData(dst, src, opts) {
246
150
  sy = 0,
247
151
  sw = src.width,
248
152
  sh = src.height,
249
- maskMode = "alpha",
250
153
  opacity = 1,
251
154
  alpha,
252
155
  blendFn = sourceOverColor32,
@@ -282,7 +185,7 @@ function blendImageData(dst, src, opts) {
282
185
  const dw = dst.width;
283
186
  const sw_orig = src.width;
284
187
  const gAlpha = alpha !== void 0 ? alpha | 0 : Math.round(opacity * 255);
285
- const maskIsAlpha = maskMode === "alpha";
188
+ const maskIsAlpha = mask?.type === 0 /* ALPHA */;
286
189
  for (let iy = 0; iy < actualH; iy++) {
287
190
  const dRow = (iy + dy) * dw;
288
191
  const sRow = (iy + sy) * sw_orig;
@@ -294,7 +197,7 @@ function blendImageData(dst, src, opts) {
294
197
  if (sa === 0) continue;
295
198
  let activeWeight = gAlpha;
296
199
  if (mask) {
297
- const m = mask[si];
200
+ const m = mask.data[si];
298
201
  if (m === 0) continue;
299
202
  activeWeight = maskIsAlpha ? m * activeWeight + 128 >> 8 : activeWeight;
300
203
  }
@@ -308,6 +211,76 @@ function blendImageData(dst, src, opts) {
308
211
  }
309
212
  }
310
213
 
214
+ // src/ImageData/mask.ts
215
+ function applyBinaryMask(dst, mask, opts = {}) {
216
+ const { width: maskWidth, height: maskHeight } = mask;
217
+ const { dx = 0, dy = 0, sx = 0, sy = 0, sw = maskWidth, sh = maskHeight } = opts;
218
+ const x0 = Math.max(0, dx, dx + (0 - sx));
219
+ const y0 = Math.max(0, dy, dy + (0 - sy));
220
+ const x1 = Math.min(dst.width, dx + sw, dx + (maskWidth - sx));
221
+ const y1 = Math.min(dst.height, dy + sh, dy + (maskHeight - sy));
222
+ if (x1 <= x0 || y1 <= y0) return;
223
+ const { data: dstData, width: dstW } = dst;
224
+ for (let y = y0; y < y1; y++) {
225
+ const maskY = y - dy + sy;
226
+ const dstRowOffset = y * dstW * 4;
227
+ const maskRowOffset = maskY * maskWidth;
228
+ for (let x = x0; x < x1; x++) {
229
+ const maskX = x - dx + sx;
230
+ const mIdx = maskRowOffset + maskX;
231
+ if (mask.data[mIdx] === 0) {
232
+ const aIdx = dstRowOffset + x * 4 + 3;
233
+ dstData[aIdx] = 0;
234
+ }
235
+ }
236
+ }
237
+ return dst;
238
+ }
239
+ function applyAlphaMask(dst, mask, opts = {}) {
240
+ let { dx = 0, dy = 0, sx = 0, sy = 0, sw = mask.width, sh = mask.height } = opts;
241
+ if (dx < 0) {
242
+ sx -= dx;
243
+ sw += dx;
244
+ dx = 0;
245
+ }
246
+ if (dy < 0) {
247
+ sy -= dy;
248
+ sh += dy;
249
+ dy = 0;
250
+ }
251
+ if (sx < 0) {
252
+ dx -= sx;
253
+ sw += sx;
254
+ sx = 0;
255
+ }
256
+ if (sy < 0) {
257
+ dy -= sy;
258
+ sh += sy;
259
+ sy = 0;
260
+ }
261
+ const actualW = Math.min(sw, dst.width - dx, mask.width - sx);
262
+ const actualH = Math.min(sh, dst.height - dy, mask.height - sy);
263
+ if (actualW <= 0 || actualH <= 0) return;
264
+ const dData = dst.data;
265
+ const mData = mask.data;
266
+ const dW = dst.width;
267
+ const mW = mask.width;
268
+ for (let y = 0; y < actualH; y++) {
269
+ const dOffset = (dy + y) * dW + dx << 2;
270
+ const mOffset = (sy + y) * mW + sx;
271
+ for (let x = 0; x < actualW; x++) {
272
+ const mVal = mData[mOffset + x];
273
+ if (mVal === 255) continue;
274
+ const aIdx = dOffset + (x << 2) + 3;
275
+ if (mVal === 0) {
276
+ dData[aIdx] = 0;
277
+ continue;
278
+ }
279
+ dData[aIdx] = dData[aIdx] * mVal + 257 >> 8;
280
+ }
281
+ }
282
+ }
283
+
311
284
  // src/ImageData/read-write-pixels.ts
312
285
  function makeImageDataColor32Adapter(imageData) {
313
286
  const data32 = new Uint32Array(imageData.data.buffer);
@@ -330,8 +303,145 @@ function makeImageDataColor32Adapter(imageData) {
330
303
  getPixel
331
304
  };
332
305
  }
306
+ function extractPixelData(imageData, _x, _y, _w, _h) {
307
+ const { x, y, w, h } = typeof _x === "object" ? _x : { x: _x, y: _y, w: _w, h: _h };
308
+ const { width: srcW, height: srcH, data: src } = imageData;
309
+ if (w <= 0 || h <= 0) return new Uint8ClampedArray(0);
310
+ const out = new Uint8ClampedArray(w * h * 4);
311
+ const x0 = Math.max(0, x);
312
+ const y0 = Math.max(0, y);
313
+ const x1 = Math.min(srcW, x + w);
314
+ const y1 = Math.min(srcH, y + h);
315
+ if (x1 <= x0 || y1 <= y0) return out;
316
+ for (let row = 0; row < y1 - y0; row++) {
317
+ const srcRow = y0 + row;
318
+ const srcStart = (srcRow * srcW + x0) * 4;
319
+ const rowLen = (x1 - x0) * 4;
320
+ const dstRow = y0 - y + row;
321
+ const dstCol = x0 - x;
322
+ const dstStart = (dstRow * w + dstCol) * 4;
323
+ out.set(src.subarray(srcStart, srcStart + rowLen), dstStart);
324
+ }
325
+ return out;
326
+ }
327
+ function copyImageData({ data, width, height }) {
328
+ return new ImageData(data.slice(), width, height);
329
+ }
330
+ function copyImageDataLike({ data, width, height }) {
331
+ return {
332
+ data: data.slice(),
333
+ width,
334
+ height
335
+ };
336
+ }
337
+
338
+ // src/ImageData/serialization.ts
339
+ function base64EncodeArrayBuffer(buffer) {
340
+ const binary = String.fromCharCode(...new Uint8Array(buffer));
341
+ return btoa(binary);
342
+ }
343
+ function base64DecodeArrayBuffer(encoded) {
344
+ const binary = atob(encoded);
345
+ const bytes = new Uint8ClampedArray(binary.length);
346
+ for (let i = 0; i < binary.length; i++) {
347
+ bytes[i] = binary.charCodeAt(i);
348
+ }
349
+ return bytes;
350
+ }
351
+ function serializeImageData(imageData) {
352
+ return {
353
+ width: imageData.width,
354
+ height: imageData.height,
355
+ data: base64EncodeArrayBuffer(imageData.data.buffer)
356
+ };
357
+ }
358
+ function serializeNullableImageData(imageData) {
359
+ if (!imageData) return null;
360
+ return serializeImageData(imageData);
361
+ }
362
+ function deserializeRawImageData(serialized) {
363
+ return {
364
+ width: serialized.width,
365
+ height: serialized.height,
366
+ data: base64DecodeArrayBuffer(serialized.data)
367
+ };
368
+ }
369
+ function deserializeImageData(serialized) {
370
+ const data = base64DecodeArrayBuffer(serialized.data);
371
+ return new ImageData(data, serialized.width, serialized.height);
372
+ }
373
+ function deserializeNullableImageData(serialized) {
374
+ if (!serialized) return null;
375
+ return deserializeImageData(serialized);
376
+ }
377
+
378
+ // src/color.ts
379
+ function packColor(r, g, b, a) {
380
+ return (a << 24 | b << 16 | g << 8 | r) >>> 0;
381
+ }
382
+ function packRGBA({ r, g, b, a }) {
383
+ return (a << 24 | b << 16 | g << 8 | r) >>> 0;
384
+ }
385
+ var unpackRed = (packed) => packed >>> 0 & 255;
386
+ var unpackGreen = (packed) => packed >>> 8 & 255;
387
+ var unpackBlue = (packed) => packed >>> 16 & 255;
388
+ var unpackAlpha = (packed) => packed >>> 24 & 255;
389
+ function unpackColor(packed) {
390
+ return {
391
+ r: packed >>> 0 & 255,
392
+ g: packed >>> 8 & 255,
393
+ b: packed >>> 16 & 255,
394
+ a: packed >>> 24 & 255
395
+ };
396
+ }
397
+ var SCRATCH_RGBA = { r: 0, g: 0, b: 0, a: 0 };
398
+ function unpackColorTo(packed, scratch = SCRATCH_RGBA) {
399
+ scratch.r = packed >>> 0 & 255;
400
+ scratch.g = packed >>> 8 & 255;
401
+ scratch.b = packed >>> 16 & 255;
402
+ scratch.a = packed >>> 24 & 255;
403
+ return scratch;
404
+ }
405
+ function colorDistance(a, b) {
406
+ const dr = (a & 255) - (b & 255);
407
+ const dg = (a >>> 8 & 255) - (b >>> 8 & 255);
408
+ const db = (a >>> 16 & 255) - (b >>> 16 & 255);
409
+ const da = (a >>> 24 & 255) - (b >>> 24 & 255);
410
+ return dr * dr + dg * dg + db * db + da * da;
411
+ }
412
+ function lerpColor32(a, b, t) {
413
+ const r = (a & 255) + t * ((b & 255) - (a & 255));
414
+ const g = (a >>> 8 & 255) + t * ((b >>> 8 & 255) - (a >>> 8 & 255));
415
+ const b_ = (a >>> 16 & 255) + t * ((b >>> 16 & 255) - (a >>> 16 & 255));
416
+ const a_ = (a >>> 24 & 255) + t * ((b >>> 24 & 255) - (a >>> 24 & 255));
417
+ return (a_ << 24 | b_ << 16 | g << 8 | r) >>> 0;
418
+ }
419
+ function lerpColor32Fast(src, dst, w) {
420
+ const invA = 255 - w;
421
+ const rb = (src & 16711935) * w + (dst & 16711935) * invA >>> 8 & 16711935;
422
+ const ga = (src >>> 8 & 16711935) * w + (dst >>> 8 & 16711935) * invA >>> 8 & 16711935;
423
+ return (rb | ga << 8) >>> 0;
424
+ }
425
+ function color32ToHex(color) {
426
+ const r = (color & 255).toString(16).padStart(2, "0");
427
+ const g = (color >>> 8 & 255).toString(16).padStart(2, "0");
428
+ const b = (color >>> 16 & 255).toString(16).padStart(2, "0");
429
+ const a = (color >>> 24 & 255).toString(16).padStart(2, "0");
430
+ return `#${r}${g}${b}${a}`;
431
+ }
432
+ function color32ToCssRGBA(color) {
433
+ const r = color & 255;
434
+ const g = color >>> 8 & 255;
435
+ const b = color >>> 16 & 255;
436
+ const a = color >>> 24 & 255;
437
+ const alpha = Number((a / 255).toFixed(3));
438
+ return `rgba(${r},${g},${b},${alpha})`;
439
+ }
333
440
  export {
334
441
  COLOR_32_BLEND_MODES,
442
+ MaskType,
443
+ applyAlphaMask,
444
+ applyBinaryMask,
335
445
  base64DecodeArrayBuffer,
336
446
  base64EncodeArrayBuffer,
337
447
  blendImageData,
@@ -339,10 +449,13 @@ export {
339
449
  color32ToHex,
340
450
  colorBurnColor32,
341
451
  colorDistance,
452
+ copyImageData,
453
+ copyImageDataLike,
342
454
  deserializeImageData,
343
455
  deserializeNullableImageData,
344
456
  deserializeRawImageData,
345
457
  differenceColor32,
458
+ extractPixelData,
346
459
  hardLightColor32,
347
460
  lerpColor32,
348
461
  lerpColor32Fast,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/color.ts","../src/ImageData/serialization.ts","../src/ImageData/blend-modes.ts","../src/ImageData/blit.ts","../src/ImageData/read-write-pixels.ts"],"sourcesContent":["import type { Color32, RGBA } from './_types'\n\n/**\n * Packs RGBA into a 32-bit integer compatible with\n * Little-Endian Uint32Array views on ImageData.\n */\nexport function packColor(r: number, g: number, b: number, a: number): Color32 {\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\nexport function packRGBA({ r, g, b, a }: RGBA): Color32 {\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\nexport const unpackRed = (packed: Color32): number => (packed >>> 0) & 0xFF\nexport const unpackGreen = (packed: Color32): number => (packed >>> 8) & 0xFF\nexport const unpackBlue = (packed: Color32): number => (packed >>> 16) & 0xFF\nexport const unpackAlpha = (packed: Color32): number => (packed >>> 24) & 0xFF\n\nexport function unpackColor(packed: Color32): RGBA {\n return {\n r: (packed >>> 0) & 0xFF,\n g: (packed >>> 8) & 0xFF,\n b: (packed >>> 16) & 0xFF,\n a: (packed >>> 24) & 0xFF,\n }\n}\n\nconst SCRATCH_RGBA: RGBA = { r: 0, g: 0, b: 0, a: 0 }\n\n// uses a scratch arg for memory perf. Be careful about re-use.\nexport function unpackColorTo(packed: Color32, scratch = SCRATCH_RGBA): RGBA {\n scratch.r = (packed >>> 0) & 0xFF\n scratch.g = (packed >>> 8) & 0xFF\n scratch.b = (packed >>> 16) & 0xFF\n scratch.a = (packed >>> 24) & 0xFF\n return scratch\n}\n\nexport function colorDistance(a: Color32, b: Color32): number {\n const dr = (a & 0xFF) - (b & 0xFF)\n const dg = ((a >>> 8) & 0xFF) - ((b >>> 8) & 0xFF)\n const db = ((a >>> 16) & 0xFF) - ((b >>> 16) & 0xFF)\n const da = ((a >>> 24) & 0xFF) - ((b >>> 24) & 0xFF)\n return dr * dr + dg * dg + db * db + da * da\n}\n\n/**\n * Linearly interpolates between two 32-bit colors using a floating-point weight.\n * * This is the preferred method for UI animations or scenarios where high\n * precision is required. It uses the standard `a + t * (b - a)` formula\n * for each channel.\n * @param a - The starting color as a 32-bit integer (AABBGGRR).\n * @param b - The target color as a 32-bit integer (AABBGGRR).\n * @param t - The interpolation factor between 0.0 and 1.0.\n * @returns The interpolated 32-bit color.\n */\nexport function lerpColor32(a: Color32, b: Color32, t: number): Color32 {\n const r = (a & 0xFF) + t * ((b & 0xFF) - (a & 0xFF))\n const g = ((a >>> 8) & 0xFF) + t * (((b >>> 8) & 0xFF) - ((a >>> 8) & 0xFF))\n const b_ = ((a >>> 16) & 0xFF) + t * (((b >>> 16) & 0xFF) - ((a >>> 16) & 0xFF))\n const a_ = ((a >>> 24) & 0xFF) + t * (((b >>> 24) & 0xFF) - ((a >>> 24) & 0xFF))\n\n return ((a_ << 24) | (b_ << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\n/**\n * Linearly interpolates between two 32-bit colors using integer fixed-point math.\n * Highly optimized for image processing and real-time blitting. It processes\n * channels in parallel using bitmasks (RB and GA pairs).\n * @note Subject to a 1-bit drift (rounding down) due to fast bit-shift division.\n * @param src - The source (foreground) color as a 32-bit integer.\n * @param dst - The destination (background) color as a 32-bit integer.\n * @param w - The blend weight as a byte value from 0 to 255. Where 0 is 100% dst and 255 is 100% src\n * @returns The blended 32-bit color.\n */export function lerpColor32Fast(src: Color32, dst: Color32, w: number): Color32 {\n const invA = 255 - w;\n\n // Masking Red and Blue: 0x00FF00FF\n // We process R and B in one go, then shift back down\n const rb = (((src & 0x00FF00FF) * w + (dst & 0x00FF00FF) * invA) >>> 8) & 0x00FF00FF;\n\n // Masking Green and Alpha: 0xFF00FF00\n // We shift down first to avoid overflow, then shift back up\n const ga = ((((src >>> 8) & 0x00FF00FF) * w + ((dst >>> 8) & 0x00FF00FF) * invA) >>> 8) & 0x00FF00FF;\n\n return (rb | (ga << 8)) >>> 0 as Color32;\n}\n\n// Convert 0xAABBGGRR to #RRGGBBAA\nexport function color32ToHex(color: Color32): string {\n const r = (color & 0xFF).toString(16).padStart(2, '0')\n const g = ((color >>> 8) & 0xFF).toString(16).padStart(2, '0')\n const b = ((color >>> 16) & 0xFF).toString(16).padStart(2, '0')\n const a = ((color >>> 24) & 0xFF).toString(16).padStart(2, '0')\n return `#${r}${g}${b}${a}`\n}\n\n/**\n * Converts a 32-bit integer (0xAABBGGRR) to a CSS rgba() string.\n * Example: 0xFF0000FF -> \"rgba(255,0,0,1)\"\n */\nexport function color32ToCssRGBA(color: Color32): string {\n const r = color & 0xFF\n const g = (color >>> 8) & 0xFF\n const b = (color >>> 16) & 0xFF\n const a = (color >>> 24) & 0xFF\n\n const alpha = Number((a / 255).toFixed(3))\n\n return `rgba(${r},${g},${b},${alpha})`\n}\n","import type { Base64EncodedUInt8Array, ImageDataLike, SerializedImageData } from '../_types'\n\nexport function base64EncodeArrayBuffer(buffer: ArrayBufferLike): Base64EncodedUInt8Array {\n const binary = String.fromCharCode(...new Uint8Array(buffer))\n return btoa(binary) as Base64EncodedUInt8Array\n}\n\nexport function base64DecodeArrayBuffer(encoded: Base64EncodedUInt8Array): Uint8ClampedArray {\n const binary = atob(encoded)\n const bytes = new Uint8ClampedArray(binary.length)\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i)\n }\n return bytes\n}\n\n/**\n * Serialize for use in JSON. Pixel data is stored as base64 encoded string.\n */\nexport function serializeImageData<T extends ImageDataLike>(imageData: T): SerializedImageData {\n return {\n width: imageData.width,\n height: imageData.height,\n data: base64EncodeArrayBuffer(imageData.data.buffer),\n }\n}\n\nexport function serializeNullableImageData<T extends ImageDataLike | null>(imageData: T): T extends null ? null : SerializedImageData {\n if (!imageData) return null as any\n\n return serializeImageData(imageData) as any\n}\n\nexport function deserializeRawImageData<T extends SerializedImageData>(serialized: T): ImageDataLike {\n return {\n width: serialized.width,\n height: serialized.height,\n data: base64DecodeArrayBuffer(serialized.data as Base64EncodedUInt8Array),\n }\n}\n\nexport function deserializeImageData<T extends SerializedImageData>(serialized: T): ImageData {\n const data = base64DecodeArrayBuffer(serialized.data as Base64EncodedUInt8Array)\n\n return new ImageData(data as ImageDataArray, serialized.width, serialized.height) as any\n}\n\nexport function deserializeNullableImageData<T extends SerializedImageData | null>(serialized: T): T extends null ? null : ImageData {\n if (!serialized) return null as any\n return deserializeImageData(serialized) as any\n}\n","import type { BlendColor32, Color32 } from '../_types'\n\nexport const sourceOverColor32: BlendColor32 = (src, dst) => {\n const a = (src >>> 24) & 0xFF\n if (a === 255) return src\n if (a === 0) return dst\n\n // Pattern: (src * a + dst * (255 - a)) >> 8\n // We process RB and G separately so they don't overflow into each other\n const rbMask = 0xFF00FF\n const gMask = 0x00FF00\n\n const sRB = src & rbMask\n const sG = src & gMask\n const dRB = dst & rbMask\n const dG = dst & gMask\n\n const invA = 255 - a\n\n const outRB = ((sRB * a + dRB * invA) >> 8) & rbMask\n const outG = ((sG * a + dG * invA) >> 8) & gMask\n\n // Re-pack with opaque alpha (or calculate combined alpha if needed)\n const outA = (a + (((dst >>> 24) & 0xFF) * invA >> 8))\n return ((outA << 24) | outRB | outG) >>> 0 as Color32\n}\n\n/**\n * Screen: Lightens the destination (inverse of Multiply).\n * Result = 1 - ((1 - Src) * (1 - Dst))\n */\nexport const screenColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math\n const br = 255 - (((255 - (src & 0xFF)) * (255 - dr)) >> 8)\n const bg = 255 - (((255 - ((src >> 8) & 0xFF)) * (255 - dg)) >> 8)\n const bb = 255 - (((255 - ((src >> 16) & 0xFF)) * (255 - db)) >> 8)\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\n/**\n * Linear Dodge (Additive): Simply adds the source to the destination.\n * Clamps at 255.\n */\nexport const linearDodgeColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math (Additive with clamping)\n const br = Math.min(255, (src & 0xFF) + dr)\n const bg = Math.min(255, ((src >> 8) & 0xFF) + dg)\n const bb = Math.min(255, ((src >> 16) & 0xFF) + db)\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\n/**\n * Multiply: Darkens the destination based on the source color.\n * Result = (Src * Dst) / 255\n */\nexport const multiplyColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math\n const br = ((src & 0xFF) * dr) >> 8\n const bg = (((src >> 8) & 0xFF) * dg) >> 8\n const bb = (((src >> 16) & 0xFF) * db) >> 8\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\n/**\n * Difference: Subtracts the darker color from the lighter color.\n * Result = |Src - Dst|\n */\nexport const differenceColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math\n const br = Math.abs((src & 0xFF) - dr)\n const bg = Math.abs(((src >> 8) & 0xFF) - dg)\n const bb = Math.abs(((src >> 16) & 0xFF) - db)\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\n/**\n * Hard Light: Decides Multiply vs Screen based on SOURCE brightness.\n * Acts like a harsh spotlight.\n */\nexport const hardLightColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const sr = src & 0xFF, sg = (src >> 8) & 0xFF, sb = (src >> 16) & 0xFF\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math\n const br = sr < 128 ? (2 * sr * dr) >> 8 : 255 - (2 * (255 - sr) * (255 - dr) >> 8)\n const bg = sg < 128 ? (2 * sg * dg) >> 8 : 255 - (2 * (255 - sg) * (255 - dg) >> 8)\n const bb = sb < 128 ? (2 * sb * db) >> 8 : 255 - (2 * (255 - sb) * (255 - db) >> 8)\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\n/**\n * Color Burn: Darkens the destination to reflect the source color.\n * Intense saturation in the darks.\n */\nexport const colorBurnColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const sr = src & 0xFF, sg = (src >> 8) & 0xFF, sb = (src >> 16) & 0xFF\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math (Avoid division by zero)\n const br = dr === 255 ? 255 : Math.max(0, 255 - ((255 - dr) << 8) / (sr || 1))\n const bg = dg === 255 ? 255 : Math.max(0, 255 - ((255 - dg) << 8) / (sg || 1))\n const bb = db === 255 ? 255 : Math.max(0, 255 - ((255 - db) << 8) / (sb || 1))\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n/**\n * Overlay: The classic \"Contrast\" mode.\n * Decides Multiply vs Screen based on DESTINATION brightness.\n */\nexport const overlayColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const sr = src & 0xFF, sg = (src >> 8) & 0xFF, sb = (src >> 16) & 0xFF\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math\n const br = dr < 128 ? (2 * sr * dr) >> 8 : 255 - (2 * (255 - sr) * (255 - dr) >> 8)\n const bg = dg < 128 ? (2 * sg * dg) >> 8 : 255 - (2 * (255 - sg) * (255 - dg) >> 8)\n const bb = db < 128 ? (2 * sb * db) >> 8 : 255 - (2 * (255 - sb) * (255 - db) >> 8)\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\nexport const COLOR_32_BLEND_MODES = {\n sourceOver: sourceOverColor32,\n screen: screenColor32,\n linearDodge: linearDodgeColor32,\n multiply: multiplyColor32,\n difference: differenceColor32,\n overlay: overlayColor32,\n hardLight: hardLightColor32,\n colorBurn: colorBurnColor32,\n}\n","import type { BlendColor32, Color32 } from '../_types'\nimport { sourceOverColor32 } from './blend-modes'\n\nexport type BlendImageDataOptions = {\n dx?: number\n dy?: number\n sx?: number\n sy?: number\n sw?: number\n sh?: number\n opacity?: number\n alpha?: number\n mask?: Uint8Array | null\n maskMode?: 'binary' | 'alpha'\n blendFn?: BlendColor32\n}\n\n/**\n * Blits source ImageData into a destination ImageData using 32-bit integer bitwise blending.\n * * This function bypasses standard Canvas API limitations by operating directly on\n * Uint32Array views. It supports various blend modes, binary/alpha masking, and\n * automatic clipping of both source and destination bounds.\n * * @param dst - The destination ImageData to write into.\n * @param src - The source ImageData to read from.\n * @param dst - The destination ImageData to write to.\n * @param opts - Configuration for the blit operation.\n * @param opts.dx - Destination X offset. Defaults to 0.\n * @param opts.dy - Destination Y offset. Defaults to 0.\n * @param opts.sx - Source X offset. Defaults to 0.\n * @param opts.sy - Source Y offset. Defaults to 0.\n * @param opts.sw - Width of the source area to blit. Defaults to src.width.\n * @param opts.sh - Height of the source area to blit. Defaults to src.height.\n * @param opts.opacity - Global strength of the blit (0.0 to 1.0). Defaults to 1.0.\n * @param opts.alpha - Global strength of the blit (0 to 255). Overrides 'opacity' if provided.\n * @param opts.mask - An optional Uint8Array acting as a stencil or alpha mask.\n * Must match source dimensions.\n * @param opts.maskMode - 'binary' ignores pixels where mask is 0.\n * 'alpha' scales source alpha by mask value (0-255).\n * @param opts.blendFn - The math logic used to combine pixels.\n * Defaults to `sourceOverColor32`.\n * * @example\n * blendImageData32(ctx.getImageData(0,0,100,100), sprite, {\n * blendFn: COLOR_32_BLEND_MODES.multiply,\n * mask: brushMask,\n * maskMode: 'alpha'\n * });\n */\nexport function blendImageData(\n dst: ImageData,\n src: ImageData,\n opts: BlendImageDataOptions,\n) {\n let {\n dx = 0,\n dy = 0,\n sx = 0,\n sy = 0,\n sw = src.width,\n sh = src.height,\n maskMode = 'alpha',\n opacity = 1,\n alpha,\n blendFn = sourceOverColor32,\n mask,\n } = opts\n\n // 1. Clip Source Area\n if (sx < 0) {\n dx -= sx\n sw += sx\n sx = 0\n }\n if (sy < 0) {\n dy -= sy\n sh += sy\n sy = 0\n }\n sw = Math.min(sw, src.width - sx)\n sh = Math.min(sh, src.height - sy)\n\n // 2. Clip Destination Area\n if (dx < 0) {\n sx -= dx\n sw += dx\n dx = 0\n }\n if (dy < 0) {\n sy -= dy\n sh += dy\n dy = 0\n }\n const actualW = Math.min(sw, dst.width - dx)\n const actualH = Math.min(sh, dst.height - dy)\n\n if (actualW <= 0 || actualH <= 0) return\n\n // 32-bit views of the same memory\n const dst32 = new Uint32Array(dst.data.buffer)\n const src32 = new Uint32Array(src.data.buffer)\n\n const dw = dst.width\n const sw_orig = src.width\n\n const gAlpha = alpha !== undefined\n ? (alpha | 0)\n : Math.round(opacity * 255)\n\n const maskIsAlpha = maskMode === 'alpha'\n\n for (let iy = 0; iy < actualH; iy++) {\n const dRow = (iy + dy) * dw\n const sRow = (iy + sy) * sw_orig\n\n for (let ix = 0; ix < actualW; ix++) {\n const di = dRow + (ix + dx)\n const si = sRow + (ix + sx)\n\n let s = src32[si] as Color32\n let sa = (s >>> 24) & 0xFF\n\n // skip fully transparent pixel\n if (sa === 0) continue\n\n let activeWeight = gAlpha\n\n if (mask) {\n const m = mask[si]\n if (m === 0) continue\n activeWeight = maskIsAlpha ? (m * activeWeight + 128) >> 8 : activeWeight\n }\n\n if (activeWeight < 255) {\n sa = (sa * activeWeight + 128) >> 8\n }\n\n // If combined alpha is 0 after masking/opacity, skip the blend math\n if (sa === 0) continue\n\n // Re-pack source with final calculated alpha\n s = ((s & 0x00FFFFFF) | (sa << 24)) >>> 0 as Color32\n\n dst32[di] = blendFn(s, dst32[di] as Color32)\n }\n }\n}\n","import type { Color32, ImageDataLike } from '../_types'\n\nexport function makeImageDataColor32Adapter(imageData: ImageDataLike) {\n const data32 = new Uint32Array(imageData.data.buffer)\n\n function inBounds(x: number, y: number) {\n return x < 0 || x >= imageData.width || y < 0 || y >= imageData.height\n }\n\n function setPixel(\n x: number,\n y: number,\n color: Color32,\n ): void {\n if (x < 0 || x >= imageData.width || y < 0 || y >= imageData.height) return\n data32[y * imageData.width + x] = color\n }\n\n function getPixel(\n x: number,\n y: number,\n ): Color32 | undefined {\n if (x < 0 || x >= imageData.width || y < 0 || y >= imageData.height) return\n\n return data32[y * imageData.width + x] as Color32\n }\n\n return {\n inBounds,\n imageData,\n data32,\n setPixel,\n getPixel,\n }\n}\n\n"],"mappings":";AAMO,SAAS,UAAU,GAAW,GAAW,GAAW,GAAoB;AAC7E,UAAS,KAAK,KA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ACA,OACM;AACN,QAAI,IAAI,KAAK,KAAK,UAAU,SAAS,IAAI,KAAK,KAAK,UAAU,OAAQ;AACrE,WAAO,IAAI,UAAU,QAAQ,CAAC,IAAI;AAAA,EACpC;AAEA,WAAS,SACP,GACA,GACqB;AACrB,QAAI,IAAI,KAAK,KAAK,UAAU,SAAS,IAAI,KAAK,KAAK,UAAU,OAAQ;AAErE,WAAO,OAAO,IAAI,UAAU,QAAQ,CAAC;AAAA,EACvC;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/ImageData/blend-modes.ts","../src/_types.ts","../src/ImageData/blit.ts","../src/ImageData/mask.ts","../src/ImageData/read-write-pixels.ts","../src/ImageData/serialization.ts","../src/color.ts"],"sourcesContent":["import type { BlendColor32, Color32 } from '../_types'\n\nexport const sourceOverColor32: BlendColor32 = (src, dst) => {\n const a = (src >>> 24) & 0xFF\n if (a === 255) return src\n if (a === 0) return dst\n\n // Pattern: (src * a + dst * (255 - a)) >> 8\n // We process RB and G separately so they don't overflow into each other\n const rbMask = 0xFF00FF\n const gMask = 0x00FF00\n\n const sRB = src & rbMask\n const sG = src & gMask\n const dRB = dst & rbMask\n const dG = dst & gMask\n\n const invA = 255 - a\n\n const outRB = ((sRB * a + dRB * invA) >> 8) & rbMask\n const outG = ((sG * a + dG * invA) >> 8) & gMask\n\n // Re-pack with opaque alpha (or calculate combined alpha if needed)\n const outA = (a + (((dst >>> 24) & 0xFF) * invA >> 8))\n return ((outA << 24) | outRB | outG) >>> 0 as Color32\n}\n\n/**\n * Screen: Lightens the destination (inverse of Multiply).\n * Result = 1 - ((1 - Src) * (1 - Dst))\n */\nexport const screenColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math\n const br = 255 - (((255 - (src & 0xFF)) * (255 - dr)) >> 8)\n const bg = 255 - (((255 - ((src >> 8) & 0xFF)) * (255 - dg)) >> 8)\n const bb = 255 - (((255 - ((src >> 16) & 0xFF)) * (255 - db)) >> 8)\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\n/**\n * Linear Dodge (Additive): Simply adds the source to the destination.\n * Clamps at 255.\n */\nexport const linearDodgeColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math (Additive with clamping)\n const br = Math.min(255, (src & 0xFF) + dr)\n const bg = Math.min(255, ((src >> 8) & 0xFF) + dg)\n const bb = Math.min(255, ((src >> 16) & 0xFF) + db)\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\n/**\n * Multiply: Darkens the destination based on the source color.\n * Result = (Src * Dst) / 255\n */\nexport const multiplyColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math\n const br = ((src & 0xFF) * dr) >> 8\n const bg = (((src >> 8) & 0xFF) * dg) >> 8\n const bb = (((src >> 16) & 0xFF) * db) >> 8\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\n/**\n * Difference: Subtracts the darker color from the lighter color.\n * Result = |Src - Dst|\n */\nexport const differenceColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math\n const br = Math.abs((src & 0xFF) - dr)\n const bg = Math.abs(((src >> 8) & 0xFF) - dg)\n const bb = Math.abs(((src >> 16) & 0xFF) - db)\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\n/**\n * Hard Light: Decides Multiply vs Screen based on SOURCE brightness.\n * Acts like a harsh spotlight.\n */\nexport const hardLightColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const sr = src & 0xFF, sg = (src >> 8) & 0xFF, sb = (src >> 16) & 0xFF\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math\n const br = sr < 128 ? (2 * sr * dr) >> 8 : 255 - (2 * (255 - sr) * (255 - dr) >> 8)\n const bg = sg < 128 ? (2 * sg * dg) >> 8 : 255 - (2 * (255 - sg) * (255 - dg) >> 8)\n const bb = sb < 128 ? (2 * sb * db) >> 8 : 255 - (2 * (255 - sb) * (255 - db) >> 8)\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\n/**\n * Color Burn: Darkens the destination to reflect the source color.\n * Intense saturation in the darks.\n */\nexport const colorBurnColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const sr = src & 0xFF, sg = (src >> 8) & 0xFF, sb = (src >> 16) & 0xFF\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math (Avoid division by zero)\n const br = dr === 255 ? 255 : Math.max(0, 255 - ((255 - dr) << 8) / (sr || 1))\n const bg = dg === 255 ? 255 : Math.max(0, 255 - ((255 - dg) << 8) / (sg || 1))\n const bb = db === 255 ? 255 : Math.max(0, 255 - ((255 - db) << 8) / (sb || 1))\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n/**\n * Overlay: The classic \"Contrast\" mode.\n * Decides Multiply vs Screen based on DESTINATION brightness.\n */\nexport const overlayColor32: BlendColor32 = (src, dst) => {\n const sa = (src >>> 24) & 0xFF\n if (sa === 0) return dst\n\n const sr = src & 0xFF, sg = (src >> 8) & 0xFF, sb = (src >> 16) & 0xFF\n const dr = dst & 0xFF, dg = (dst >> 8) & 0xFF, db = (dst >> 16) & 0xFF\n\n // 1. Core Math\n const br = dr < 128 ? (2 * sr * dr) >> 8 : 255 - (2 * (255 - sr) * (255 - dr) >> 8)\n const bg = dg < 128 ? (2 * sg * dg) >> 8 : 255 - (2 * (255 - sg) * (255 - dg) >> 8)\n const bb = db < 128 ? (2 * sb * db) >> 8 : 255 - (2 * (255 - sb) * (255 - db) >> 8)\n\n if (sa === 255) return (0xFF000000 | (bb << 16) | (bg << 8) | br) >>> 0 as Color32\n\n // 2. Alpha Lerp inlined\n const invA = 255 - sa\n const r = (br * sa + dr * invA) >> 8\n const g = (bg * sa + dg * invA) >> 8\n const b = (bb * sa + db * invA) >> 8\n const a = (255 * sa + ((dst >>> 24) & 0xFF) * invA) >> 8\n\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\nexport const COLOR_32_BLEND_MODES = {\n sourceOver: sourceOverColor32,\n screen: screenColor32,\n linearDodge: linearDodgeColor32,\n multiply: multiplyColor32,\n difference: differenceColor32,\n overlay: overlayColor32,\n hardLight: hardLightColor32,\n colorBurn: colorBurnColor32,\n}\n","// ALL values are 0-255 (including alpha which in CSS is 0-1)\nexport type RGBA = { r: number, g: number, b: number, a: number }\n\n// A 32-bit integer containing r,g,b,a data\nexport type Color32 = number & { readonly __brandColor32: unique symbol }\n\nexport type BlendColor32 = (src: Color32, dst: Color32) => Color32\n\nexport type ImageDataLike = {\n width: number\n height: number\n data: Uint8ClampedArray<ArrayBuffer>\n}\n\nexport type SerializedImageData = {\n width: number\n height: number\n data: string\n}\n\nexport type Base64EncodedUInt8Array = string & { readonly __brandBase64UInt8Array: unique symbol }\n\nexport type Rect = { x: number; y: number; w: number; h: number }\n\nexport enum MaskType {\n ALPHA,\n BINARY\n}\n\ninterface BaseMaskData {\n readonly width: number\n readonly height: number\n readonly data: Uint8Array\n}\n\nexport interface AlphaMask extends BaseMaskData {\n readonly type: MaskType.ALPHA\n}\n\nexport interface BinaryMask extends BaseMaskData {\n readonly type: MaskType.BINARY\n}\n\nexport type AnyMask = AlphaMask | BinaryMask\n","import { type AnyMask, type BlendColor32, type Color32, type ImageDataLike, MaskType } from '../_types'\nimport { sourceOverColor32 } from './blend-modes'\n\nexport type BlendImageDataOptions = {\n /**\n * The x-coordinate in the destination image where the blend begins.\n * @default 0\n */\n dx?: number\n\n /**\n * The y-coordinate in the destination image where the blend begins.\n * @default 0\n */\n dy?: number\n\n /**\n * The x-coordinate of the top-left corner of the sub-rectangle\n * of the source image to extract.\n * @default 0\n */\n sx?: number\n\n /**\n * The y-coordinate of the top-left corner of the sub-rectangle\n * of the source image to extract.\n * @default 0\n */\n sy?: number\n\n /**\n * The width of the sub-rectangle of the source image to extract.\n * Defaults to the full remaining width of the source.\n */\n sw?: number\n\n /**\n * The height of the sub-rectangle of the source image to extract.\n * Defaults to the full remaining height of the source.\n */\n sh?: number\n\n /**\n * Overall layer opacity, typically ranging from 0.0 (transparent) to 1.0 (opaque).\n * @default 1.0\n */\n opacity?: number\n\n /**\n * Same as opacity but is 0-255 and faster when processing. If Present opacity is ignored.\n * @default undefined\n */\n alpha?: number\n\n /**\n * An optional alpha mask buffer.\n * The values in this array (0-255) determine the intensity of the blend\n * at each corresponding pixel.\n */\n mask?: AnyMask | null\n\n /**\n * The specific blending function/algorithm to use for pixel math\n * (e.g., Multiply, Screen, Overlay).\n */\n blendFn?: BlendColor32\n};\n\n/**\n * Blits source ImageData into a destination ImageData using 32-bit integer bitwise blending.\n * This function bypasses standard Canvas API limitations by operating directly on\n * Uint32Array views. It supports various blend modes, binary/alpha masking, and\n * automatic clipping of both source and destination bounds.\n * @example\n * blendImageData32(ctx.getImageData(0,0,100,100), sprite, {\n * blendFn: COLOR_32_BLEND_MODES.multiply,\n * mask: brushMask,\n * maskMode: MaskMode.ALPHA\n * });\n */\nexport function blendImageData(\n dst: ImageDataLike,\n src: ImageDataLike,\n opts: BlendImageDataOptions,\n) {\n let {\n dx = 0,\n dy = 0,\n sx = 0,\n sy = 0,\n sw = src.width,\n sh = src.height,\n opacity = 1,\n alpha,\n blendFn = sourceOverColor32,\n mask,\n } = opts\n\n // 1. Clip Source Area\n if (sx < 0) {\n dx -= sx\n sw += sx\n sx = 0\n }\n if (sy < 0) {\n dy -= sy\n sh += sy\n sy = 0\n }\n sw = Math.min(sw, src.width - sx)\n sh = Math.min(sh, src.height - sy)\n\n // 2. Clip Destination Area\n if (dx < 0) {\n sx -= dx\n sw += dx\n dx = 0\n }\n if (dy < 0) {\n sy -= dy\n sh += dy\n dy = 0\n }\n const actualW = Math.min(sw, dst.width - dx)\n const actualH = Math.min(sh, dst.height - dy)\n\n if (actualW <= 0 || actualH <= 0) return\n\n // 32-bit views of the same memory\n const dst32 = new Uint32Array(dst.data.buffer)\n const src32 = new Uint32Array(src.data.buffer)\n\n const dw = dst.width\n const sw_orig = src.width\n\n const gAlpha = alpha !== undefined\n ? (alpha | 0)\n : Math.round(opacity * 255)\n\n const maskIsAlpha = mask?.type === MaskType.ALPHA\n\n for (let iy = 0; iy < actualH; iy++) {\n const dRow = (iy + dy) * dw\n const sRow = (iy + sy) * sw_orig\n\n for (let ix = 0; ix < actualW; ix++) {\n const di = dRow + (ix + dx)\n const si = sRow + (ix + sx)\n\n let s = src32[si] as Color32\n let sa = (s >>> 24) & 0xFF\n\n // skip fully transparent pixel\n if (sa === 0) continue\n\n let activeWeight = gAlpha\n\n if (mask) {\n const m = mask.data[si]\n if (m === 0) continue\n activeWeight = maskIsAlpha ? (m * activeWeight + 128) >> 8 : activeWeight\n }\n\n if (activeWeight < 255) {\n sa = (sa * activeWeight + 128) >> 8\n }\n\n // If combined alpha is 0 after masking/opacity, skip the blend math\n if (sa === 0) continue\n\n // Re-pack source with final calculated alpha\n s = ((s & 0x00FFFFFF) | (sa << 24)) >>> 0 as Color32\n\n dst32[di] = blendFn(s, dst32[di] as Color32)\n }\n }\n}\n","import type { AlphaMask, BinaryMask, ImageDataLike } from '../_types'\n\nexport type ApplyMaskOptions = {\n /**\n * The x-coordinate in the destination image where the mask begins.\n * @default 0\n */\n dx?: number\n\n /**\n * The y-coordinate in the destination image where the mask begins.\n * @default 0\n */\n dy?: number\n\n /**\n * The x-coordinate of the top-left corner of the sub-rectangle\n * of the source image to extract.\n * @default 0\n */\n sx?: number\n\n /**\n * The y-coordinate of the top-left corner of the sub-rectangle\n * of the source image to extract.\n * @default 0\n */\n sy?: number\n\n /**\n * The width of the sub-rectangle of the source image to extract.\n * Defaults to the full remaining width of the source.\n */\n sw?: number\n\n /**\n * The height of the sub-rectangle of the source image to extract.\n * Defaults to the full remaining height of the source.\n */\n sh?: number;\n}\n\n/**\n * Applies a binary (on/off) mask to an RGBA buffer.\n * If mask value is 0, pixel becomes transparent.\n */\nexport function applyBinaryMask(\n dst: ImageDataLike,\n mask: BinaryMask,\n opts: ApplyMaskOptions = {},\n) {\n const { width: maskWidth, height: maskHeight } = mask\n\n const { dx = 0, dy = 0, sx = 0, sy = 0, sw = maskWidth, sh = maskHeight } = opts\n\n // 1. Calculate intersection boundaries\n const x0 = Math.max(0, dx, dx + (0 - sx))\n const y0 = Math.max(0, dy, dy + (0 - sy))\n const x1 = Math.min(dst.width, dx + sw, dx + (maskWidth - sx))\n const y1 = Math.min(dst.height, dy + sh, dy + (maskHeight - sy))\n\n if (x1 <= x0 || y1 <= y0) return\n\n const { data: dstData, width: dstW } = dst\n\n for (let y = y0; y < y1; y++) {\n const maskY = y - dy + sy\n const dstRowOffset = y * dstW * 4\n const maskRowOffset = maskY * maskWidth\n\n for (let x = x0; x < x1; x++) {\n const maskX = x - dx + sx\n const mIdx = maskRowOffset + maskX\n\n // Binary check: If mask is 0, kill the alpha\n if (mask.data[mIdx] === 0) {\n const aIdx = dstRowOffset + (x * 4) + 3\n dstData[aIdx] = 0\n }\n }\n }\n\n return dst\n}\n\n/**\n * Applies a smooth alpha mask to an RGBA buffer.\n * Multiplies existing Alpha by (maskValue / 255).\n */\nexport function applyAlphaMask(\n dst: ImageData,\n mask: AlphaMask,\n opts: ApplyMaskOptions = {},\n): void {\n let { dx = 0, dy = 0, sx = 0, sy = 0, sw = mask.width, sh = mask.height } = opts\n\n // 1. Clipping Logic\n if (dx < 0) {\n sx -= dx\n sw += dx\n dx = 0\n }\n if (dy < 0) {\n sy -= dy\n sh += dy\n dy = 0\n }\n if (sx < 0) {\n dx -= sx\n sw += sx\n sx = 0\n }\n if (sy < 0) {\n dy -= sy\n sh += sy\n sy = 0\n }\n const actualW = Math.min(sw, dst.width - dx, mask.width - sx)\n const actualH = Math.min(sh, dst.height - dy, mask.height - sy)\n\n if (actualW <= 0 || actualH <= 0) return\n\n const dData = dst.data\n const mData = mask.data\n const dW = dst.width\n const mW = mask.width\n\n for (let y = 0; y < actualH; y++) {\n const dOffset = ((dy + y) * dW + dx) << 2\n const mOffset = (sy + y) * mW + sx\n\n for (let x = 0; x < actualW; x++) {\n const mVal = mData[mOffset + x]\n\n if (mVal === 255) continue\n\n const aIdx = dOffset + (x << 2) + 3\n\n // --- BRANCH: Zero Alpha ---\n if (mVal === 0) {\n dData[aIdx] = 0\n continue\n }\n\n // To get 101 from 200 * 128, we use the bias (a * m + 257) >> 8\n // 25600 + 257 = 25857. 25857 >> 8 = 101.\n dData[aIdx] = (dData[aIdx] * mVal + 257) >> 8\n }\n }\n}\n","import type { Color32, ImageDataLike, Rect } from '../_types'\n\nexport function makeImageDataColor32Adapter(imageData: ImageDataLike) {\n const data32 = new Uint32Array(imageData.data.buffer)\n\n function inBounds(x: number, y: number) {\n return x < 0 || x >= imageData.width || y < 0 || y >= imageData.height\n }\n\n function setPixel(\n x: number,\n y: number,\n color: Color32,\n ): void {\n if (x < 0 || x >= imageData.width || y < 0 || y >= imageData.height) return\n data32[y * imageData.width + x] = color\n }\n\n function getPixel(\n x: number,\n y: number,\n ): Color32 | undefined {\n if (x < 0 || x >= imageData.width || y < 0 || y >= imageData.height) return\n\n return data32[y * imageData.width + x] as Color32\n }\n\n return {\n inBounds,\n imageData,\n data32,\n setPixel,\n getPixel,\n }\n}\n\nexport function extractPixelData(\n imageData: ImageDataLike,\n rect: Rect,\n): Uint8ClampedArray\n\nexport function extractPixelData(\n imageData: ImageDataLike,\n x: number,\n y: number,\n w: number,\n h: number,\n): Uint8ClampedArray\nexport function extractPixelData(\n imageData: ImageDataLike,\n _x: Rect | number,\n _y?: number,\n _w?: number,\n _h?: number,\n): Uint8ClampedArray {\n const { x, y, w, h } = typeof _x === 'object'\n ? _x\n : { x: _x, y: _y!, w: _w!, h: _h! }\n\n const { width: srcW, height: srcH, data: src } = imageData\n // Safety check for invalid dimensions\n if (w <= 0 || h <= 0) return new Uint8ClampedArray(0)\n const out = new Uint8ClampedArray(w * h * 4)\n\n const x0 = Math.max(0, x)\n const y0 = Math.max(0, y)\n const x1 = Math.min(srcW, x + w)\n const y1 = Math.min(srcH, y + h)\n\n // If no intersection, return the empty\n if (x1 <= x0 || y1 <= y0) return out\n\n for (let row = 0; row < (y1 - y0); row++) {\n // Where to read from the source canvas\n const srcRow = y0 + row\n const srcStart = (srcRow * srcW + x0) * 4\n const rowLen = (x1 - x0) * 4\n\n // Where to write into the 'out' patch\n const dstRow = (y0 - y) + row\n const dstCol = (x0 - x)\n const dstStart = (dstRow * w + dstCol) * 4\n\n // Perform the high-speed bulk copy\n out.set(src.subarray(srcStart, srcStart + rowLen), dstStart)\n }\n\n return out\n}\n\nexport function copyImageData({ data, width, height }: ImageDataLike): ImageData {\n return new ImageData(data.slice(), width, height)\n}\n\nexport function copyImageDataLike({ data, width, height }: ImageDataLike): ImageDataLike {\n return {\n data: data.slice(),\n width,\n height,\n }\n}\n","import type { Base64EncodedUInt8Array, ImageDataLike, SerializedImageData } from '../_types'\n\nexport function base64EncodeArrayBuffer(buffer: ArrayBufferLike): Base64EncodedUInt8Array {\n const binary = String.fromCharCode(...new Uint8Array(buffer))\n return btoa(binary) as Base64EncodedUInt8Array\n}\n\nexport function base64DecodeArrayBuffer(encoded: Base64EncodedUInt8Array): Uint8ClampedArray<ArrayBuffer> {\n const binary = atob(encoded)\n const bytes = new Uint8ClampedArray(binary.length)\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i)\n }\n return bytes\n}\n\n/**\n * Serialize for use in JSON. Pixel data is stored as base64 encoded string.\n */\nexport function serializeImageData<T extends ImageDataLike>(imageData: T): SerializedImageData {\n return {\n width: imageData.width,\n height: imageData.height,\n data: base64EncodeArrayBuffer(imageData.data.buffer),\n }\n}\n\nexport function serializeNullableImageData<T extends ImageDataLike | null>(imageData: T): T extends null ? null : SerializedImageData {\n if (!imageData) return null as any\n\n return serializeImageData(imageData) as any\n}\n\nexport function deserializeRawImageData<T extends SerializedImageData>(serialized: T): ImageDataLike {\n return {\n width: serialized.width,\n height: serialized.height,\n data: base64DecodeArrayBuffer(serialized.data as Base64EncodedUInt8Array),\n }\n}\n\nexport function deserializeImageData<T extends SerializedImageData>(serialized: T): ImageData {\n const data = base64DecodeArrayBuffer(serialized.data as Base64EncodedUInt8Array)\n\n return new ImageData(data as ImageDataArray, serialized.width, serialized.height) as any\n}\n\nexport function deserializeNullableImageData<T extends SerializedImageData | null>(serialized: T): T extends null ? null : ImageData {\n if (!serialized) return null as any\n return deserializeImageData(serialized) as any\n}\n","import type { Color32, RGBA } from './_types'\n\n/**\n * Packs RGBA into a 32-bit integer compatible with\n * Little-Endian Uint32Array views on ImageData.\n */\nexport function packColor(r: number, g: number, b: number, a: number): Color32 {\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\nexport function packRGBA({ r, g, b, a }: RGBA): Color32 {\n return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\nexport const unpackRed = (packed: Color32): number => (packed >>> 0) & 0xFF\nexport const unpackGreen = (packed: Color32): number => (packed >>> 8) & 0xFF\nexport const unpackBlue = (packed: Color32): number => (packed >>> 16) & 0xFF\nexport const unpackAlpha = (packed: Color32): number => (packed >>> 24) & 0xFF\n\nexport function unpackColor(packed: Color32): RGBA {\n return {\n r: (packed >>> 0) & 0xFF,\n g: (packed >>> 8) & 0xFF,\n b: (packed >>> 16) & 0xFF,\n a: (packed >>> 24) & 0xFF,\n }\n}\n\nconst SCRATCH_RGBA: RGBA = { r: 0, g: 0, b: 0, a: 0 }\n\n// uses a scratch arg for memory perf. Be careful about re-use.\nexport function unpackColorTo(packed: Color32, scratch = SCRATCH_RGBA): RGBA {\n scratch.r = (packed >>> 0) & 0xFF\n scratch.g = (packed >>> 8) & 0xFF\n scratch.b = (packed >>> 16) & 0xFF\n scratch.a = (packed >>> 24) & 0xFF\n return scratch\n}\n\nexport function colorDistance(a: Color32, b: Color32): number {\n const dr = (a & 0xFF) - (b & 0xFF)\n const dg = ((a >>> 8) & 0xFF) - ((b >>> 8) & 0xFF)\n const db = ((a >>> 16) & 0xFF) - ((b >>> 16) & 0xFF)\n const da = ((a >>> 24) & 0xFF) - ((b >>> 24) & 0xFF)\n return dr * dr + dg * dg + db * db + da * da\n}\n\n/**\n * Linearly interpolates between two 32-bit colors using a floating-point weight.\n * * This is the preferred method for UI animations or scenarios where high\n * precision is required. It uses the standard `a + t * (b - a)` formula\n * for each channel.\n * @param a - The starting color as a 32-bit integer (AABBGGRR).\n * @param b - The target color as a 32-bit integer (AABBGGRR).\n * @param t - The interpolation factor between 0.0 and 1.0.\n * @returns The interpolated 32-bit color.\n */\nexport function lerpColor32(a: Color32, b: Color32, t: number): Color32 {\n const r = (a & 0xFF) + t * ((b & 0xFF) - (a & 0xFF))\n const g = ((a >>> 8) & 0xFF) + t * (((b >>> 8) & 0xFF) - ((a >>> 8) & 0xFF))\n const b_ = ((a >>> 16) & 0xFF) + t * (((b >>> 16) & 0xFF) - ((a >>> 16) & 0xFF))\n const a_ = ((a >>> 24) & 0xFF) + t * (((b >>> 24) & 0xFF) - ((a >>> 24) & 0xFF))\n\n return ((a_ << 24) | (b_ << 16) | (g << 8) | r) >>> 0 as Color32\n}\n\n/**\n * Linearly interpolates between two 32-bit colors using integer fixed-point math.\n * Highly optimized for image processing and real-time blitting. It processes\n * channels in parallel using bitmasks (RB and GA pairs).\n * @note Subject to a 1-bit drift (rounding down) due to fast bit-shift division.\n * @param src - The source (foreground) color as a 32-bit integer.\n * @param dst - The destination (background) color as a 32-bit integer.\n * @param w - The blend weight as a byte value from 0 to 255. Where 0 is 100% dst and 255 is 100% src\n * @returns The blended 32-bit color.\n */export function lerpColor32Fast(src: Color32, dst: Color32, w: number): Color32 {\n const invA = 255 - w;\n\n // Masking Red and Blue: 0x00FF00FF\n // We process R and B in one go, then shift back down\n const rb = (((src & 0x00FF00FF) * w + (dst & 0x00FF00FF) * invA) >>> 8) & 0x00FF00FF;\n\n // Masking Green and Alpha: 0xFF00FF00\n // We shift down first to avoid overflow, then shift back up\n const ga = ((((src >>> 8) & 0x00FF00FF) * w + ((dst >>> 8) & 0x00FF00FF) * invA) >>> 8) & 0x00FF00FF;\n\n return (rb | (ga << 8)) >>> 0 as Color32;\n}\n\n// Convert 0xAABBGGRR to #RRGGBBAA\nexport function color32ToHex(color: Color32): string {\n const r = (color & 0xFF).toString(16).padStart(2, '0')\n const g = ((color >>> 8) & 0xFF).toString(16).padStart(2, '0')\n const b = ((color >>> 16) & 0xFF).toString(16).padStart(2, '0')\n const a = ((color >>> 24) & 0xFF).toString(16).padStart(2, '0')\n return `#${r}${g}${b}${a}`\n}\n\n/**\n * Converts a 32-bit integer (0xAABBGGRR) to a CSS rgba() string.\n * Example: 0xFF0000FF -> \"rgba(255,0,0,1)\"\n */\nexport function color32ToCssRGBA(color: Color32): string {\n const r = color & 0xFF\n const g = (color >>> 8) & 0xFF\n const b = (color >>> 16) & 0xFF\n const a = (color >>> 24) & 0xFF\n\n const alpha = Number((a / 255).toFixed(3))\n\n return `rgba(${r},${g},${b},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