mwg API
    Preparing search index...

    Class FogLayer

    A smooth fog-of-war overlay: a small canvas with resolution pixels per tile, scaled up with linear filtering, so fog edges blur into the next cell instead of stepping by whole tiles. Draw it above terrain and characters, and call refresh when visibility changes. Needs a DOM canvas; paintFogPixels is the same shading without one.

    import { FogLayer } from '@datamoc/mwg/two-d/render';

    const fog = new FogLayer({
    width: 20,
    height: 20,
    palette: [[0, 0, 0, 0], [0, 0, 0, 150], [0, 0, 0, 255]], // seen, remembered, unknown
    });
    fog.refresh((x, y) => (x < 5 ? 0 : 2));

    Hierarchy

    • Sprite
      • FogLayer
    Index
    • the texture is generated for this layer alone, so it goes with it

      Returns void