mwg API
    Preparing search index...

    Function blendPixels

    • The renderer-free core of ~BLEND: every pixel's RGB is lerped ratio of the way towards color (0xRRGGBB), an exact per-pixel blend rather than blendMatrix's runtime approximation - this is what applyTextureModifiers bakes into the texture once. Alpha is untouched; a fully transparent pixel is skipped entirely, matching remapPixels.

      Parameters

      • pixels: Uint8ClampedArray
      • color: number
      • ratio: number

      Returns Uint8ClampedArray

      import { blendPixels } from '@datamoc/mw_games/two-d/render';

      const pixels = new Uint8ClampedArray([0, 0, 0, 255]); // one opaque black pixel
      const out = blendPixels(pixels, 0xff0000, 0.5);
      console.log([...out]); // [128, 0, 0, 255] - half-way to red