Something went wrong. Try again.
doll.systems community website
Something went wrong. Try again.
1234567891011121314export type Plane = { pixels: Uint8Array; width: number; height: number };
// Gamma-adjusted, single-channel pixels in WebGL's bottom-to-top row order.export function luminancePlane(rgba: Uint8ClampedArray, width: number, height: number): Plane { const pixels = new Uint8Array(width * height); for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) { const i = (y * width + x) * 4; const light = (0.2126 * rgba[i] + 0.7152 * rgba[i + 1] + 0.0722 * rgba[i + 2]) / 255; pixels[(height - 1 - y) * width + x] = Math.round(light ** 0.92 * 255); } return { pixels, width, height };}