mwg API
    Preparing search index...

    Function paintFogPixels

    • 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.

      Parameters

      • pixels: Uint8Array<ArrayBufferLike> | Uint8ClampedArray<ArrayBufferLike>
      • width: number
      • height: number
      • resolution: number
      • state: (x: number, y: number) => FogCell
      • palette: readonly FogColor[]

      Returns void

      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