BitmapData#processPixelRGB()

processPixelRGB(callback, callbackContext, x, y, width, height) → {Phaser.BitmapData}

Scans through the area specified in this BitmapData and sends a color object for every pixel to the given callback.
The callback will be sent a color object with 6 properties: { r: number, g: number, b: number, a: number, color: number, rgba: string }.
Where r, g, b and a are integers between 0 and 255 representing the color component values for red, green, blue and alpha.
The color property is an Int32 of the full color. Note the endianess of this will change per system.
The rgba property is a CSS style rgba() string which can be used with context.fillStyle calls, among others.
The callback will also be sent the pixels x and y coordinates respectively.
The callback must return either false, in which case no change will be made to the pixel, or a new color object.
If a new color object is returned the pixel will be set to the r, g, b and a color values given within it.

Parameters
Name Type Argument Default Description
callback function

The callback that will be sent each pixel color object to be processed.

callbackContext object

The context under which the callback will be called.

x number <optional>
0

The x coordinate of the top-left of the region to process from.

y number <optional>
0

The y coordinate of the top-left of the region to process from.

width number <optional>

The width of the region to process.

height number <optional>

The height of the region to process.

Returns

This BitmapData object for method chaining.

Source code: gameobjects/BitmapData.js (Line 642)
doc_phaser
2017-02-14 10:37:10
Comments
Leave a Comment

Please login to continue.