Additively blends a new pixel with an existing color value in a canvas.

As this method is often called many times in render loops, only bounds checking is applied to the given coordinates.

The coordinates are expected to already be integers. Supplying numbers with fractions has performance implications. Ensure you're working with integers, or truncate the coordinates before passing them in.

The alpha value is expected to be an integer in the range from 0 to 255. 0 meaning fully transparent, 255 meaning fully opaque.

  • Parameters

    • canvas: Canvas2D | Canvas2DHeadless

      The canvas to interact with.

    • x: number

      The X coordinate at which to place the pixel.

    • y: number

      The Y coordinate at which to place the pixel.

    • color: number

      The color of the pixel.

    • alpha: number

      The alpha value to use to blend the pixel with existing color at the location.

    Returns void