mwg API
    Preparing search index...

    Function paintGlowPixels

    • Paint a size * size radial glow (the sprite is square, size is odd) into pixels as RGBA bytes. Centre pixels carry the colour at full intensity, rim pixels fade to transparent, and intensity scales every channel linearly, so doubling it doubles the light. Pure, like paintFogPixels.

      Parameters

      • pixels: Uint8Array<ArrayBufferLike> | Uint8ClampedArray<ArrayBufferLike>
      • size: number
      • paint: GlowPaint

      Returns void

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

      const size = 5;
      const pixels = new Uint8ClampedArray(size * size * 4);
      paintGlowPixels(pixels, size, { color: 0xff0000, radius: 2, intensity: 1 });
      console.log(pixels[0] > pixels[pixels.length - 4]); // true - the centre burns redder than the rim