new BitmapData(game, key, width, height)
Creates a new BitmapData object.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
game |
Phaser.Game | A reference to the currently running game. |
||
key |
string | Internal Phaser reference key for the render texture. |
||
width |
number |
<optional> |
100 | The width of the BitmapData in pixels. |
height |
number |
<optional> |
100 | The height of the BitmapData in pixels. |
- Source:
Members
-
baseTexture
-
- Source:
Properties:
Name Type Description baseTexture
PIXI.BaseTexture The PIXI.BaseTexture.
-
canvas
-
- Source:
Properties:
Name Type Description canvas
HTMLCanvasElement The canvas to which this BitmapData draws.
-
context
-
- Source:
Properties:
Name Type Description context
CanvasRenderingContext2D The 2d context of the canvas.
-
ctx
-
- Source:
Properties:
Name Type Description ctx
CanvasRenderingContext2D A reference to BitmapData.context.
-
game
-
- Source:
Properties:
Name Type Description game
Phaser.Game A reference to the currently running game.
-
height
-
- Source:
Properties:
Name Type Description height
number The height of the BitmapData in pixels.
-
imageData
-
- Source:
Properties:
Name Type Description imageData
array The canvas image data.
-
key
-
- Source:
Properties:
Name Type Description key
string The key of the BitmapData in the Cache, if stored there.
-
pixels
-
- Source:
Properties:
Name Type Description pixels
UInt8Clamped A reference to the context imageData buffer.
-
texture
-
- Source:
Properties:
Name Type Description texture
PIXI.Texture The PIXI.Texture.
-
textureFrame
-
- Source:
Properties:
Name Type Description textureFrame
Phaser.Frame The Frame this BitmapData uses for rendering.
-
type
-
- Source:
Properties:
Name Type Description type
number The const type of this object.
-
width
-
- Source:
Properties:
Name Type Description width
number The width of the BitmapData in pixels.
Methods
-
add(object)
-
Updates the given objects so that they use this BitmapData as their texture.
Parameters:
Name Type Description object
Phaser.Sprite | Array.<Phaser.Sprite> | Phaser.Image | Array.<Phaser.Image> Either a single Sprite/Image or an Array of Sprites/Images.
- Source:
-
clear()
-
Clears the BitmapData.
- Source:
-
getPixel(x, y) → {number}
-
Get a color of a specific pixel.
Parameters:
Name Type Description x
number The X coordinate of the pixel to get.
y
number The Y coordinate of the pixel to get.
- Source:
Returns:
A native color value integer (format: 0xRRGGBB)
- Type
- number
-
getPixel32(x, y) → {number}
-
Get a color of a specific pixel (including alpha value).
Parameters:
Name Type Description x
number The X coordinate of the pixel to get.
y
number The Y coordinate of the pixel to get.
- Source:
Returns:
A native color value integer (format: 0xAARRGGBB)
- Type
- number
-
getPixels(rect) → {array}
-
Get pixels in array in a specific Rectangle.
Parameters:
Name Type Description rect
Rectangle The specific Rectangle.
- Source:
Returns:
CanvasPixelArray.
- Type
- array
-
refreshBuffer()
-
- Source:
-
render()
-
If the game is running in WebGL this will push the texture up to the GPU if it's dirty. This is called automatically if the BitmapData is being used by a Sprite, otherwise you need to remember to call it in your render function.
- Source:
-
resize()
-
Resizes the BitmapData.
- Source:
-
setPixel(x, y, red, green, blue)
-
Sets the color of the given pixel to the specified red, green and blue values.
Parameters:
Name Type Description x
number The X coordinate of the pixel to be set.
y
number The Y coordinate of the pixel to be set.
red
number The red color value (between 0 and 255)
green
number The green color value (between 0 and 255)
blue
number The blue color value (between 0 and 255)
- Source:
-
setPixel32(x, y, red, green, blue, alpha)
-
Sets the color of the given pixel to the specified red, green, blue and alpha values.
Parameters:
Name Type Description x
number The X coordinate of the pixel to be set.
y
number The Y coordinate of the pixel to be set.
red
number The red color value, between 0 and 0xFF (255).
green
number The green color value, between 0 and 0xFF (255).
blue
number The blue color value, between 0 and 0xFF (255).
alpha
number The alpha color value, between 0 and 0xFF (255).
- Source: