import { maskPixels } from '@datamoc/mw_games/two-d/render';
const base = new Uint8ClampedArray([10, 20, 30, 255]); // one opaque pixel
const mask = new Uint8ClampedArray([0, 0, 0, 128]); // half-alpha mask, same 1x1 size
const out = maskPixels(base, 1, 1, mask, 1, 1, 0, 0);
console.log([...out]); // [10, 20, 30, 128]
The renderer-free core of
~MASK:base's alpha channel is multiplied bymask's alpha at the given offset (a pixel the mask does not cover keeps zero alpha),base's own colour left untouched. Exported so the masking logic is testable without a canvas.