mwg API
    Preparing search index...

    Class HazeLayer

    An atmospheric haze sheet: translucent weather and mood with soft edges, drift and density, on the GPU path (roadmap 425). Distinct from FogLayer, which is fog of war: this never hides gameplay, it only colours the air. The canvas stays small and scales up with linear filtering, so one refresh costs O(cells) and edges stay soft at any size. Stack several planes with different densities, drifts, tints and scales for depth. Needs a DOM canvas; paintHazePixels is the same shading without one.

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

    const far = new HazeLayer({ width: 400, height: 225, density: 0.3, tint: 0x9db8d6, drift: { x: 0.1, y: 0 } });
    const near = new HazeLayer({ width: 400, height: 225, density: 0.5, tint: 0xcfd8e6, drift: { x: 0.4, y: 0.05 } });
    far.update(1 / 60); // each plane drifts at its own pace, which reads as depth
    near.update(1 / 60);

    Hierarchy

    • Sprite
      • HazeLayer
    Index
    • the texture is generated for this sheet alone, so it goes with it

      Returns void

    • swap the coverage; takes effect on the next update

      Parameters

      • density: number

      Returns void

    • advance the drift and repaint; under reduced motion a decorative sheet holds still

      Parameters

      • dt: number

      Returns void