Paints per-cell fog into an RGBA pixel buffer of width * resolution by height * resolution pixels. Pure: no canvas involved, so the shading rule is checkable anywhere. A state with no palette entry paints transparent.
width * resolution
height * resolution
import { paintFogPixels } from '@datamoc/mwg/two-d/render';const pixels = new Uint8ClampedArray(2 * 1 * 4);paintFogPixels(pixels, 2, 1, 1, (x) => x, [[0, 0, 0, 0], [0, 0, 0, 255]]);console.log(pixels[7]); // 255 - the second cell is fully fogged Copy
import { paintFogPixels } from '@datamoc/mwg/two-d/render';const pixels = new Uint8ClampedArray(2 * 1 * 4);paintFogPixels(pixels, 2, 1, 1, (x) => x, [[0, 0, 0, 0], [0, 0, 0, 255]]);console.log(pixels[7]); // 255 - the second cell is fully fogged
Paints per-cell fog into an RGBA pixel buffer of
width * resolutionbyheight * resolutionpixels. Pure: no canvas involved, so the shading rule is checkable anywhere. A state with no palette entry paints transparent.