Class: Bitmap

Bitmap

new Bitmap (width, height)

The basic object that represents an image.

Name Type Description
width number

The width of the bitmap.

height number

The height of the bitmap.

Members

baseTexture PIXI.BaseTexture readonly

The base texture that holds the image.

canvas HTMLCanvasElement readonly

The bitmap canvas.

context CanvasRenderingContext2D readonly

The 2d context of the bitmap canvas.

fontBold boolean

Whether the font is bold.

fontFace string

The face name of the font.

fontItalic boolean

Whether the font is italic.

fontSize number

The size of the font in pixels.

height number readonly

The height of the bitmap.

image HTMLImageElement readonly

The bitmap image.

outlineColor string

The color of the outline of the text in CSS format.

outlineWidth number

The width of the outline of the text.

paintOpacity number

The opacity of the drawing object in the range (0, 255).

rect Rectangle readonly

The rectangle of the bitmap.

smooth boolean

Whether the smooth scaling is applied.

textColor string

The color of the text in CSS format.

url string readonly

The url of the image file.

width number readonly

The width of the bitmap.

Methods

Bitmap.load (url)Bitmap static

Loads a image file.

Name Type Description
url string

The image url of the texture.

Returns:
Type Description
Bitmap The new bitmap object.

Bitmap.snap (stage)Bitmap static

Takes a snapshot of the game screen.

Name Type Description
stage Stage

The stage object.

Returns:
Type Description
Bitmap The new bitmap object.

addLoadListener (listner)

Adds a callback function that will be called when the bitmap is loaded.

Name Type Description
listner function

The callback function.

blt (source, sx, sy, sw, sh, dx, dy, dw, dh)

Performs a block transfer.

Name Type Default Description
source Bitmap

The bitmap to draw.

sx number

The x coordinate in the source.

sy number

The y coordinate in the source.

sw number

The width of the source image.

sh number

The height of the source image.

dx number

The x coordinate in the destination.

dy number

The y coordinate in the destination.

dw number sw optional

The width to draw the image in the destination.

dh number sh optional

The height to draw the image in the destination.

clear ()

Clears the entire bitmap.

clearRect (x, y, width, height)

Clears the specified rectangle.

Name Type Description
x number

The x coordinate for the upper-left corner.

y number

The y coordinate for the upper-left corner.

width number

The width of the rectangle to clear.

height number

The height of the rectangle to clear.

destroy ()

Destroys the bitmap.

drawCircle (x, y, radius, color)

Draws a bitmap in the shape of a circle.

Name Type Description
x number

The x coordinate based on the circle center.

y number

The y coordinate based on the circle center.

radius number

The radius of the circle.

color string

The color of the circle in CSS format.

drawText (text, x, y, maxWidth, lineHeight, align)

Draws the outline text to the bitmap.

Name Type Description
text string

The text that will be drawn.

x number

The x coordinate for the left of the text.

y number

The y coordinate for the top of the text.

maxWidth number

The maximum allowed width of the text.

lineHeight number

The height of the text line.

align string

The alignment of the text.

fillAll (color)

Fills the entire bitmap.

Name Type Description
color string

The color of the rectangle in CSS format.

fillRect (x, y, width, height, color)

Fills the specified rectangle.

Name Type Description
x number

The x coordinate for the upper-left corner.

y number

The y coordinate for the upper-left corner.

width number

The width of the rectangle to fill.

height number

The height of the rectangle to fill.

color string

The color of the rectangle in CSS format.

getAlphaPixel (x, y)string

Returns alpha pixel value at the specified point.

Name Type Description
x number

The x coordinate of the pixel in the bitmap.

y number

The y coordinate of the pixel in the bitmap.

Returns:
Type Description
string The alpha value.

getPixel (x, y)string

Returns pixel color at the specified point.

Name Type Description
x number

The x coordinate of the pixel in the bitmap.

y number

The y coordinate of the pixel in the bitmap.

Returns:
Type Description
string The pixel color (hex format).

gradientFillRect (x, y, width, height, color1, color2, vertical)

Draws the rectangle with a gradation.

Name Type Description
x number

The x coordinate for the upper-left corner.

y number

The y coordinate for the upper-left corner.

width number

The width of the rectangle to fill.

height number

The height of the rectangle to fill.

color1 string

The gradient starting color.

color2 string

The gradient ending color.

vertical boolean

Whether the gradient should be draw as vertical or not.

isError ()boolean

Checks whether a loading error has occurred.

Returns:
Type Description
boolean True if a loading error has occurred.

isReady ()boolean

Checks whether the bitmap is ready to render.

Returns:
Type Description
boolean True if the bitmap is ready to render.

measureTextWidth (text)number

Returns the width of the specified text.

Name Type Description
text string

The text to be measured.

Returns:
Type Description
number The width of the text in pixels.

resize (width, height)

Resizes the bitmap.

Name Type Description
width number

The new width of the bitmap.

height number

The new height of the bitmap.

retry ()

Tries to load the image again.

strokeRect (x, y, width, height, color)

Draws the specified rectangular frame.

Name Type Description
x number

The x coordinate for the upper-left corner.

y number

The y coordinate for the upper-left corner.

width number

The width of the rectangle to fill.

height number

The height of the rectangle to fill.

color string

The color of the rectangle in CSS format.