Bitmap Class

The basic object that represents an image.

Constructor

Bitmap ( width , height )

Parameters:

  • width Number

    The width of the bitmap

  • height Number

    The height of the bitmap

Item Index

Methods Properties

Methods

addLoadListener ( listner )

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

Parameters:

  • listner Function

    The callback function

adjustTone ( r , g , b )

Changes the color tone of the entire bitmap.

Parameters:

  • r Number

    The red strength in the range (-255, 255)

  • g Number

    The green strength in the range (-255, 255)

  • b Number

    The blue strength in the range (-255, 255)

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

Performs a block transfer.

Parameters:

  • 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=sw] Number [optional]

    The width to draw the image in the destination

  • [dh=sh] Number [optional]

    The height to draw the image in the destination

blur ()

Applies a blur effect to the bitmap.

clear ()

Clears the entire bitmap.

clearRect ( x , y , width , height )

Clears the specified rectangle.

Parameters:

  • 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

drawCircle ( x , y , radius , color )

Draw the filled circle.

Parameters:

  • x Number

    The x coordinate of the center of the circle

  • y Number

    The y coordinate of the center of the circle

  • 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.

Parameters:

  • 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

    The height of the text line

  • align String

    The alignment of the text

fillAll ( color )

Fills the entire bitmap.

Parameters:

  • color String

    The color of the rectangle in CSS format

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

Fills the specified rectangle.

Parameters:

  • 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

  • color String

    The color of the rectangle in CSS format

getAlphaPixel ( x , y ) String

Returns alpha pixel value at the specified point.

Parameters:

  • x Number

    The x coordinate of the pixel in the bitmap

  • y Number

    The y coordinate of the pixel in the bitmap

Returns:

String:
The alpha value

getPixel ( x , y ) String

Returns pixel color at the specified point.

Parameters:

  • x Number

    The x coordinate of the pixel in the bitmap

  • y Number

    The y coordinate of the pixel in the bitmap

Returns:

String:
The pixel color (hex format)

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

Draws the rectangle with a gradation.

Parameters:

  • 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

  • color1 String

    The start color of the gradation

  • color2 String

    The end color of the gradation

  • vertical Boolean

    Whether it draws a vertical gradient

isError () Boolean

Checks whether a loading error has occurred.

Returns:

Boolean:
True if a loading error has occurred

isReady () Boolean

Checks whether the bitmap is ready to render.

Returns:

Boolean:
True if the bitmap is ready to render

load ( url ) [static]

Loads a image file and returns a new bitmap object.

Parameters:

  • url String

    The image url of the texture

Returns:

Bitmap

measureTextWidth ( text ) Number

Returns the width of the specified text.

Parameters:

  • text String

    The text to be measured

Returns:

Number:
The width of the text in pixels

resize ( width , height )

Resizes the bitmap.

Parameters:

  • width Number

    The new width of the bitmap

  • height Number

    The new height of the bitmap

rotateHue ( offset )

Rotates the hue of the entire bitmap.

Parameters:

  • offset Number

    The hue offset in 360 degrees

snap ( stage ) [static]

Takes a snapshot of the game screen and returns a new bitmap object.

Parameters:

  • stage PIXI.Stage

    The stage object

Returns:

Bitmap

Properties

baseTexture PIXI.BaseTexture

[read-only] The base texture that holds the image.

canvas HTMLCanvasElement

[read-only] The bitmap canvas.

context CanvasRenderingContext2D

[read-only] The 2d context of the bitmap canvas.

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

[read-only] The height of the bitmap.

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

[read-only] 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

[read-only] The url of the image file.

width Number

[read-only] The width of the bitmap.