Phaser API Documentation

  Version: 
getPixel(x, y, [out])

Description:

Get the color of a specific pixel from this texture and store it in a Color object.

If you have drawn anything to this CanvasTexture since it was created you must call CanvasTexture.update to refresh the array buffer, otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist.

Parameters:

name type arguments description
x number

The x coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer.

y number

The y coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer.

out Phaser.Display.Color <optional>

A Color object to store the pixel values in. If not provided a new Color object will be created.

Returns:
Description:

An object with the red, green, blue and alpha values set in the r, g, b and a properties.

Since: 3.13.0