BitmapData#processPixel()

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

Scans through the area specified in this BitmapData and sends the color for every pixel to the given callback along with its x and y coordinates.
Whatever value the callback returns is set as the new color for that pixel, unless it returns the same color, in which case it's skipped.
Note that the format of the color received will be different depending on if the system is big or little endian.
It is expected that your callback will deal with endianess. If you'd rather Phaser did it then use processPixelRGB instead.
The callback will also be sent the pixels x and y coordinates respectively.

Parameters
Name Type Argument Default Description
callback function

The callback that will be sent each pixel color 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 700)
doc_phaser
2017-02-14 10:37:09
Comments
Leave a Comment

Please login to continue.