Bitmap Class
The basic object that represents an image.
Constructor
Bitmap ( width , height )
Parameters:
-
width
NumberThe width of the bitmap
-
height
NumberThe height of the bitmap
Item Index
Methods PropertiesMethods
addLoadListener ( listner )
Add a callback function that will be called when the bitmap is loaded.
Parameters:
-
listner
FunctionThe callback function
adjustTone ( r , g , b )
Changes the color tone of the entire bitmap.
Parameters:
-
r
NumberThe red strength in the range (-255, 255)
-
g
NumberThe green strength in the range (-255, 255)
-
b
NumberThe 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
BitmapThe bitmap to draw
-
sx
NumberThe x coordinate in the source
-
sy
NumberThe y coordinate in the source
-
sw
NumberThe width of the source image
-
sh
NumberThe height of the source image
-
dx
NumberThe x coordinate in the destination
-
dy
NumberThe 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
NumberThe x coordinate for the upper-left corner
-
y
NumberThe y coordinate for the upper-left corner
-
width
NumberThe width of the rectangle to clear
-
height
NumberThe height of the rectangle to clear
drawCircle ( x , y , radius , color )
Draw the filled circle.
Parameters:
-
x
NumberThe x coordinate of the center of the circle
-
y
NumberThe y coordinate of the center of the circle
-
radius
NumberThe radius of the circle
-
color
StringThe color of the circle in CSS format
drawText ( text , x , y , maxWidth , lineHeight , align )
Draws the outline text to the bitmap.
Parameters:
-
text
StringThe text that will be drawn
-
x
NumberThe x coordinate for the left of the text
-
y
NumberThe y coordinate for the top of the text
-
maxWidth
NumberThe maximum allowed width of the text
-
lineHeight
The height of the text line
-
align
StringThe alignment of the text
fillAll ( color )
Fills the entire bitmap.
Parameters:
-
color
StringThe color of the rectangle in CSS format
fillRect ( x , y , width , height , color )
Fills the specified rectangle.
Parameters:
-
x
NumberThe x coordinate for the upper-left corner
-
y
NumberThe y coordinate for the upper-left corner
-
width
NumberThe width of the rectangle to clear
-
height
NumberThe height of the rectangle to clear
-
color
StringThe color of the rectangle in CSS format
getAlphaPixel ( x , y ) String
Returns alpha pixel value at the specified point.
Parameters:
-
x
NumberThe x coordinate of the pixel in the bitmap
-
y
NumberThe 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
NumberThe x coordinate of the pixel in the bitmap
-
y
NumberThe 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
NumberThe x coordinate for the upper-left corner
-
y
NumberThe y coordinate for the upper-left corner
-
width
NumberThe width of the rectangle to clear
-
height
NumberThe height of the rectangle to clear
-
color1
StringThe start color of the gradation
-
color2
StringThe end color of the gradation
-
vertical
BooleanWhether 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
StringThe image url of the texture
Returns:
Bitmap
measureTextWidth ( text ) Number
Returns the width of the specified text.
Parameters:
-
text
StringThe text to be measured
Returns:
Number:
The width of the text in pixels
resize ( width , height )
Resizes the bitmap.
Parameters:
-
width
NumberThe new width of the bitmap
-
height
NumberThe new height of the bitmap
rotateHue ( offset )
Rotates the hue of the entire bitmap.
Parameters:
-
offset
NumberThe hue offset in 360 degrees
snap ( stage ) [static]
Takes a snapshot of the game screen and returns a new bitmap object.
Parameters:
-
stage
PIXI.StageThe 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.