scripts/build-brand-assets.mjs
JavaScript
/** Un-mattes ink-over-white into straight RGBA. */
function unmat(data, width, height, channels) {
const out = Buffer.alloc(width * height * 4);
for (let p = 0, q = 0; p < data.length; p += channels, q += 4) {
const r = data[p], g = data[p + 1], b = data[p + 2];
const a = 255 - Math.min(r, g, b);
if (a <= ALPHA_FLOOR) continue; // clear; buffer is already zeroed
const k = 255 - a;
const f = 255 / a;
out[q] = Math.max(0, Math.min(255, Math.round((r - k) * f)));
out[q + 1] = Math.max(0, Math.min(255, Math.round((g - k) * f)));
out[q + 2] = Math.max(0, Math.min(255, Math.round((b - k) * f)));
out[q + 3] = a;
}Scroll the block sideways to read the full line
What a reviewer looks for
The source art is ink printed on solid white, so every pixel is P = a·C + (1−a)·255. Both brand inks bottom out at red 0, which is what makes the darkest channel a faithful coverage read.
What matters is that the code says so. A routine that only works because of a property of its input has to name that property, or the next person changes the artwork and quietly breaks the edges. That is the standard here.