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.
@@ -21,6 +21,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
23
  COLOR_32_BLEND_MODES: () => COLOR_32_BLEND_MODES,
24
+ MaskType: () => MaskType,
25
+ applyAlphaMask: () => applyAlphaMask,
26
+ applyBinaryMask: () => applyBinaryMask,
24
27
  base64DecodeArrayBuffer: () => base64DecodeArrayBuffer,
25
28
  base64EncodeArrayBuffer: () => base64EncodeArrayBuffer,
26
29
  blendImageData: () => blendImageData,
@@ -28,10 +31,13 @@ __export(src_exports, {
28
31
  color32ToHex: () => color32ToHex,
29
32
  colorBurnColor32: () => colorBurnColor32,
30
33
  colorDistance: () => colorDistance,
34
+ copyImageData: () => copyImageData,
35
+ copyImageDataLike: () => copyImageDataLike,
31
36
  deserializeImageData: () => deserializeImageData,
32
37
  deserializeNullableImageData: () => deserializeNullableImageData,
33
38
  deserializeRawImageData: () => deserializeRawImageData,
34
39
  differenceColor32: () => differenceColor32,
40
+ extractPixelData: () => extractPixelData,
35
41
  hardLightColor32: () => hardLightColor32,
36
42
  lerpColor32: () => lerpColor32,
37
43
  lerpColor32Fast: () => lerpColor32Fast,
@@ -54,109 +60,6 @@ __export(src_exports, {
54
60
  });
55
61
  module.exports = __toCommonJS(src_exports);
56
62
 
57
- // src/color.ts
58
- function packColor(r, g, b, a) {
59
- return (a << 24 | b << 16 | g << 8 | r) >>> 0;
60
- }
61
- function packRGBA({ r, g, b, a }) {
62
- return (a << 24 | b << 16 | g << 8 | r) >>> 0;
63
- }
64
- var unpackRed = (packed) => packed >>> 0 & 255;
65
- var unpackGreen = (packed) => packed >>> 8 & 255;
66
- var unpackBlue = (packed) => packed >>> 16 & 255;
67
- var unpackAlpha = (packed) => packed >>> 24 & 255;
68
- function unpackColor(packed) {
69
- return {
70
- r: packed >>> 0 & 255,
71
- g: packed >>> 8 & 255,
72
- b: packed >>> 16 & 255,
73
- a: packed >>> 24 & 255
74
- };
75
- }
76
- var SCRATCH_RGBA = { r: 0, g: 0, b: 0, a: 0 };
77
- function unpackColorTo(packed, scratch = SCRATCH_RGBA) {
78
- scratch.r = packed >>> 0 & 255;
79
- scratch.g = packed >>> 8 & 255;
80
- scratch.b = packed >>> 16 & 255;
81
- scratch.a = packed >>> 24 & 255;
82
- return scratch;
83
- }
84
- function colorDistance(a, b) {
85
- const dr = (a & 255) - (b & 255);
86
- const dg = (a >>> 8 & 255) - (b >>> 8 & 255);
87
- const db = (a >>> 16 & 255) - (b >>> 16 & 255);
88
- const da = (a >>> 24 & 255) - (b >>> 24 & 255);
89
- return dr * dr + dg * dg + db * db + da * da;
90
- }
91
- function lerpColor32(a, b, t) {
92
- const r = (a & 255) + t * ((b & 255) - (a & 255));
93
- const g = (a >>> 8 & 255) + t * ((b >>> 8 & 255) - (a >>> 8 & 255));
94
- const b_ = (a >>> 16 & 255) + t * ((b >>> 16 & 255) - (a >>> 16 & 255));
95
- const a_ = (a >>> 24 & 255) + t * ((b >>> 24 & 255) - (a >>> 24 & 255));
96
- return (a_ << 24 | b_ << 16 | g << 8 | r) >>> 0;
97
- }
98
- function lerpColor32Fast(src, dst, w) {
99
- const invA = 255 - w;
100
- const rb = (src & 16711935) * w + (dst & 16711935) * invA >>> 8 & 16711935;
101
- const ga = (src >>> 8 & 16711935) * w + (dst >>> 8 & 16711935) * invA >>> 8 & 16711935;
102
- return (rb | ga << 8) >>> 0;
103
- }
104
- function color32ToHex(color) {
105
- const r = (color & 255).toString(16).padStart(2, "0");
106
- const g = (color >>> 8 & 255).toString(16).padStart(2, "0");
107
- const b = (color >>> 16 & 255).toString(16).padStart(2, "0");
108
- const a = (color >>> 24 & 255).toString(16).padStart(2, "0");
109
- return `#${r}${g}${b}${a}`;
110
- }
111
- function color32ToCssRGBA(color) {
112
- const r = color & 255;
113
- const g = color >>> 8 & 255;
114
- const b = color >>> 16 & 255;
115
- const a = color >>> 24 & 255;
116
- const alpha = Number((a / 255).toFixed(3));
117
- return `rgba(${r},${g},${b},${alpha})`;
118
- }
119
-
120
- // src/ImageData/serialization.ts
121
- function base64EncodeArrayBuffer(buffer) {
122
- const binary = String.fromCharCode(...new Uint8Array(buffer));
123
- return btoa(binary);
124
- }
125
- function base64DecodeArrayBuffer(encoded) {
126
- const binary = atob(encoded);
127
- const bytes = new Uint8ClampedArray(binary.length);
128
- for (let i = 0; i < binary.length; i++) {
129
- bytes[i] = binary.charCodeAt(i);
130
- }
131
- return bytes;
132
- }
133
- function serializeImageData(imageData) {
134
- return {
135
- width: imageData.width,
136
- height: imageData.height,
137
- data: base64EncodeArrayBuffer(imageData.data.buffer)
138
- };
139
- }
140
- function serializeNullableImageData(imageData) {
141
- if (!imageData) return null;
142
- return serializeImageData(imageData);
143
- }
144
- function deserializeRawImageData(serialized) {
145
- return {
146
- width: serialized.width,
147
- height: serialized.height,
148
- data: base64DecodeArrayBuffer(serialized.data)
149
- };
150
- }
151
- function deserializeImageData(serialized) {
152
- const data = base64DecodeArrayBuffer(serialized.data);
153
- return new ImageData(data, serialized.width, serialized.height);
154
- }
155
- function deserializeNullableImageData(serialized) {
156
- if (!serialized) return null;
157
- return deserializeImageData(serialized);
158
- }
159
-
160
63
  // src/ImageData/blend-modes.ts
161
64
  var sourceOverColor32 = (src, dst) => {
162
65
  const a = src >>> 24 & 255;
@@ -293,6 +196,13 @@ var COLOR_32_BLEND_MODES = {
293
196
  colorBurn: colorBurnColor32
294
197
  };
295
198
 
199
+ // src/_types.ts
200
+ var MaskType = /* @__PURE__ */ ((MaskType2) => {
201
+ MaskType2[MaskType2["ALPHA"] = 0] = "ALPHA";
202
+ MaskType2[MaskType2["BINARY"] = 1] = "BINARY";
203
+ return MaskType2;
204
+ })(MaskType || {});
205
+
296
206
  // src/ImageData/blit.ts
297
207
  function blendImageData(dst, src, opts) {
298
208
  let {
@@ -302,7 +212,6 @@ function blendImageData(dst, src, opts) {
302
212
  sy = 0,
303
213
  sw = src.width,
304
214
  sh = src.height,
305
- maskMode = "alpha",
306
215
  opacity = 1,
307
216
  alpha,
308
217
  blendFn = sourceOverColor32,
@@ -338,7 +247,7 @@ function blendImageData(dst, src, opts) {
338
247
  const dw = dst.width;
339
248
  const sw_orig = src.width;
340
249
  const gAlpha = alpha !== void 0 ? alpha | 0 : Math.round(opacity * 255);
341
- const maskIsAlpha = maskMode === "alpha";
250
+ const maskIsAlpha = mask?.type === 0 /* ALPHA */;
342
251
  for (let iy = 0; iy < actualH; iy++) {
343
252
  const dRow = (iy + dy) * dw;
344
253
  const sRow = (iy + sy) * sw_orig;
@@ -350,7 +259,7 @@ function blendImageData(dst, src, opts) {
350
259
  if (sa === 0) continue;
351
260
  let activeWeight = gAlpha;
352
261
  if (mask) {
353
- const m = mask[si];
262
+ const m = mask.data[si];
354
263
  if (m === 0) continue;
355
264
  activeWeight = maskIsAlpha ? m * activeWeight + 128 >> 8 : activeWeight;
356
265
  }
@@ -364,6 +273,76 @@ function blendImageData(dst, src, opts) {
364
273
  }
365
274
  }
366
275
 
276
+ // src/ImageData/mask.ts
277
+ function applyBinaryMask(dst, mask, opts = {}) {
278
+ const { width: maskWidth, height: maskHeight } = mask;
279
+ const { dx = 0, dy = 0, sx = 0, sy = 0, sw = maskWidth, sh = maskHeight } = opts;
280
+ const x0 = Math.max(0, dx, dx + (0 - sx));
281
+ const y0 = Math.max(0, dy, dy + (0 - sy));
282
+ const x1 = Math.min(dst.width, dx + sw, dx + (maskWidth - sx));
283
+ const y1 = Math.min(dst.height, dy + sh, dy + (maskHeight - sy));
284
+ if (x1 <= x0 || y1 <= y0) return;
285
+ const { data: dstData, width: dstW } = dst;
286
+ for (let y = y0; y < y1; y++) {
287
+ const maskY = y - dy + sy;
288
+ const dstRowOffset = y * dstW * 4;
289
+ const maskRowOffset = maskY * maskWidth;
290
+ for (let x = x0; x < x1; x++) {
291
+ const maskX = x - dx + sx;
292
+ const mIdx = maskRowOffset + maskX;
293
+ if (mask.data[mIdx] === 0) {
294
+ const aIdx = dstRowOffset + x * 4 + 3;
295
+ dstData[aIdx] = 0;
296
+ }
297
+ }
298
+ }
299
+ return dst;
300
+ }
301
+ function applyAlphaMask(dst, mask, opts = {}) {
302
+ let { dx = 0, dy = 0, sx = 0, sy = 0, sw = mask.width, sh = mask.height } = opts;
303
+ if (dx < 0) {
304
+ sx -= dx;
305
+ sw += dx;
306
+ dx = 0;
307
+ }
308
+ if (dy < 0) {
309
+ sy -= dy;
310
+ sh += dy;
311
+ dy = 0;
312
+ }
313
+ if (sx < 0) {
314
+ dx -= sx;
315
+ sw += sx;
316
+ sx = 0;
317
+ }
318
+ if (sy < 0) {
319
+ dy -= sy;
320
+ sh += sy;
321
+ sy = 0;
322
+ }
323
+ const actualW = Math.min(sw, dst.width - dx, mask.width - sx);
324
+ const actualH = Math.min(sh, dst.height - dy, mask.height - sy);
325
+ if (actualW <= 0 || actualH <= 0) return;
326
+ const dData = dst.data;
327
+ const mData = mask.data;
328
+ const dW = dst.width;
329
+ const mW = mask.width;
330
+ for (let y = 0; y < actualH; y++) {
331
+ const dOffset = (dy + y) * dW + dx << 2;
332
+ const mOffset = (sy + y) * mW + sx;
333
+ for (let x = 0; x < actualW; x++) {
334
+ const mVal = mData[mOffset + x];
335
+ if (mVal === 255) continue;
336
+ const aIdx = dOffset + (x << 2) + 3;
337
+ if (mVal === 0) {
338
+ dData[aIdx] = 0;
339
+ continue;
340
+ }
341
+ dData[aIdx] = dData[aIdx] * mVal + 257 >> 8;
342
+ }
343
+ }
344
+ }
345
+
367
346
  // src/ImageData/read-write-pixels.ts
368
347
  function makeImageDataColor32Adapter(imageData) {
369
348
  const data32 = new Uint32Array(imageData.data.buffer);
@@ -386,9 +365,146 @@ function makeImageDataColor32Adapter(imageData) {
386
365
  getPixel
387
366
  };
388
367
  }
368
+ function extractPixelData(imageData, _x, _y, _w, _h) {
369
+ const { x, y, w, h } = typeof _x === "object" ? _x : { x: _x, y: _y, w: _w, h: _h };
370
+ const { width: srcW, height: srcH, data: src } = imageData;
371
+ if (w <= 0 || h <= 0) return new Uint8ClampedArray(0);
372
+ const out = new Uint8ClampedArray(w * h * 4);
373
+ const x0 = Math.max(0, x);
374
+ const y0 = Math.max(0, y);
375
+ const x1 = Math.min(srcW, x + w);
376
+ const y1 = Math.min(srcH, y + h);
377
+ if (x1 <= x0 || y1 <= y0) return out;
378
+ for (let row = 0; row < y1 - y0; row++) {
379
+ const srcRow = y0 + row;
380
+ const srcStart = (srcRow * srcW + x0) * 4;
381
+ const rowLen = (x1 - x0) * 4;
382
+ const dstRow = y0 - y + row;
383
+ const dstCol = x0 - x;
384
+ const dstStart = (dstRow * w + dstCol) * 4;
385
+ out.set(src.subarray(srcStart, srcStart + rowLen), dstStart);
386
+ }
387
+ return out;
388
+ }
389
+ function copyImageData({ data, width, height }) {
390
+ return new ImageData(data.slice(), width, height);
391
+ }
392
+ function copyImageDataLike({ data, width, height }) {
393
+ return {
394
+ data: data.slice(),
395
+ width,
396
+ height
397
+ };
398
+ }
399
+
400
+ // src/ImageData/serialization.ts
401
+ function base64EncodeArrayBuffer(buffer) {
402
+ const binary = String.fromCharCode(...new Uint8Array(buffer));
403
+ return btoa(binary);
404
+ }
405
+ function base64DecodeArrayBuffer(encoded) {
406
+ const binary = atob(encoded);
407
+ const bytes = new Uint8ClampedArray(binary.length);
408
+ for (let i = 0; i < binary.length; i++) {
409
+ bytes[i] = binary.charCodeAt(i);
410
+ }
411
+ return bytes;
412
+ }
413
+ function serializeImageData(imageData) {
414
+ return {
415
+ width: imageData.width,
416
+ height: imageData.height,
417
+ data: base64EncodeArrayBuffer(imageData.data.buffer)
418
+ };
419
+ }
420
+ function serializeNullableImageData(imageData) {
421
+ if (!imageData) return null;
422
+ return serializeImageData(imageData);
423
+ }
424
+ function deserializeRawImageData(serialized) {
425
+ return {
426
+ width: serialized.width,
427
+ height: serialized.height,
428
+ data: base64DecodeArrayBuffer(serialized.data)
429
+ };
430
+ }
431
+ function deserializeImageData(serialized) {
432
+ const data = base64DecodeArrayBuffer(serialized.data);
433
+ return new ImageData(data, serialized.width, serialized.height);
434
+ }
435
+ function deserializeNullableImageData(serialized) {
436
+ if (!serialized) return null;
437
+ return deserializeImageData(serialized);
438
+ }
439
+
440
+ // src/color.ts
441
+ function packColor(r, g, b, a) {
442
+ return (a << 24 | b << 16 | g << 8 | r) >>> 0;
443
+ }
444
+ function packRGBA({ r, g, b, a }) {
445
+ return (a << 24 | b << 16 | g << 8 | r) >>> 0;
446
+ }
447
+ var unpackRed = (packed) => packed >>> 0 & 255;
448
+ var unpackGreen = (packed) => packed >>> 8 & 255;
449
+ var unpackBlue = (packed) => packed >>> 16 & 255;
450
+ var unpackAlpha = (packed) => packed >>> 24 & 255;
451
+ function unpackColor(packed) {
452
+ return {
453
+ r: packed >>> 0 & 255,
454
+ g: packed >>> 8 & 255,
455
+ b: packed >>> 16 & 255,
456
+ a: packed >>> 24 & 255
457
+ };
458
+ }
459
+ var SCRATCH_RGBA = { r: 0, g: 0, b: 0, a: 0 };
460
+ function unpackColorTo(packed, scratch = SCRATCH_RGBA) {
461
+ scratch.r = packed >>> 0 & 255;
462
+ scratch.g = packed >>> 8 & 255;
463
+ scratch.b = packed >>> 16 & 255;
464
+ scratch.a = packed >>> 24 & 255;
465
+ return scratch;
466
+ }
467
+ function colorDistance(a, b) {
468
+ const dr = (a & 255) - (b & 255);
469
+ const dg = (a >>> 8 & 255) - (b >>> 8 & 255);
470
+ const db = (a >>> 16 & 255) - (b >>> 16 & 255);
471
+ const da = (a >>> 24 & 255) - (b >>> 24 & 255);
472
+ return dr * dr + dg * dg + db * db + da * da;
473
+ }
474
+ function lerpColor32(a, b, t) {
475
+ const r = (a & 255) + t * ((b & 255) - (a & 255));
476
+ const g = (a >>> 8 & 255) + t * ((b >>> 8 & 255) - (a >>> 8 & 255));
477
+ const b_ = (a >>> 16 & 255) + t * ((b >>> 16 & 255) - (a >>> 16 & 255));
478
+ const a_ = (a >>> 24 & 255) + t * ((b >>> 24 & 255) - (a >>> 24 & 255));
479
+ return (a_ << 24 | b_ << 16 | g << 8 | r) >>> 0;
480
+ }
481
+ function lerpColor32Fast(src, dst, w) {
482
+ const invA = 255 - w;
483
+ const rb = (src & 16711935) * w + (dst & 16711935) * invA >>> 8 & 16711935;
484
+ const ga = (src >>> 8 & 16711935) * w + (dst >>> 8 & 16711935) * invA >>> 8 & 16711935;
485
+ return (rb | ga << 8) >>> 0;
486
+ }
487
+ function color32ToHex(color) {
488
+ const r = (color & 255).toString(16).padStart(2, "0");
489
+ const g = (color >>> 8 & 255).toString(16).padStart(2, "0");
490
+ const b = (color >>> 16 & 255).toString(16).padStart(2, "0");
491
+ const a = (color >>> 24 & 255).toString(16).padStart(2, "0");
492
+ return `#${r}${g}${b}${a}`;
493
+ }
494
+ function color32ToCssRGBA(color) {
495
+ const r = color & 255;
496
+ const g = color >>> 8 & 255;
497
+ const b = color >>> 16 & 255;
498
+ const a = color >>> 24 & 255;
499
+ const alpha = Number((a / 255).toFixed(3));
500
+ return `rgba(${r},${g},${b},${alpha})`;
501
+ }
389
502
  // Annotate the CommonJS export names for ESM import in node:
390
503
  0 && (module.exports = {
391
504
  COLOR_32_BLEND_MODES,
505
+ MaskType,
506
+ applyAlphaMask,
507
+ applyBinaryMask,
392
508
  base64DecodeArrayBuffer,
393
509
  base64EncodeArrayBuffer,
394
510
  blendImageData,
@@ -396,10 +512,13 @@ function makeImageDataColor32Adapter(imageData) {
396
512
  color32ToHex,
397
513
  colorBurnColor32,
398
514
  colorDistance,
515
+ copyImageData,
516
+ copyImageDataLike,
399
517
  deserializeImageData,
400
518
  deserializeNullableImageData,
401
519
  deserializeRawImageData,
402
520
  differenceColor32,
521
+ extractPixelData,
403
522
  hardLightColor32,
404
523
  lerpColor32,
405
524
  lerpColor32Fast,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/color.ts","../src/ImageData/serialization.ts","../src/ImageData/blend-modes.ts","../src/ImageData/blit.ts","../src/ImageData/read-write-pixels.ts"],"sourcesContent":["export * from './color'\nexport * from './ImageData/serialization'\nexport * from './ImageData/blit'\nexport * from './ImageData/blend-modes'\nexport * from './ImageData/read-write-pixels'\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},${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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,SAAS,UAAU,GAAW,GAAW,GAAW,GAAoB;AAC7E,UAAS,KAAK,KAAO,KAAK,KAAO,KAAK,IAAK,OAAO;AACpD;AAEO,S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S,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/index.ts","../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":["export * from './ImageData/blend-modes'\nexport * from './ImageData/blit'\nexport * from './ImageData/mask'\nexport * from './ImageData/read-write-pixels'\nexport * from './ImageData/serialization'\nexport * from './_types'\nexport * from './color'\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","// 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 >>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