Bitmap Class
The basic object that represents an image.
Constructor
Bitmap ( width , height )
Parameters:
-
widthNumberThe width of the bitmap
-
heightNumberThe height of the bitmap
Item Index
Methods PropertiesMethods
addLoadListener ( listner )
Add a callback function that will be called when the bitmap is loaded.
Parameters:
-
listnerFunctionThe callback function
adjustTone ( r , g , b )
Changes the color tone of the entire bitmap.
Parameters:
-
rNumberThe red strength in the range (-255, 255)
-
gNumberThe green strength in the range (-255, 255)
-
bNumberThe blue strength in the range (-255, 255)
blt ( source , sx , sy , sw , sh , dx , dy , [dw=sw] , [dh=sh] )
Performs a block transfer.
Parameters:
-
sourceBitmapThe bitmap to draw
-
sxNumberThe x coordinate in the source
-
syNumberThe y coordinate in the source
-
swNumberThe width of the source image
-
shNumberThe height of the source image
-
dxNumberThe x coordinate in the destination
-
dyNumberThe 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:
-
xNumberThe x coordinate for the upper-left corner
-
yNumberThe y coordinate for the upper-left corner
-
widthNumberThe width of the rectangle to clear
-
heightNumberThe height of the rectangle to clear
drawCircle ( x , y , radius , color )
Draw the filled circle.
Parameters:
-
xNumberThe x coordinate of the center of the circle
-
yNumberThe y coordinate of the center of the circle
-
radiusNumberThe radius of the circle
-
colorStringThe color of the circle in CSS format
drawText ( text , x , y , maxWidth , lineHeight , align )
Draws the outline text to the bitmap.
Parameters:
-
textStringThe text that will be drawn
-
xNumberThe x coordinate for the left of the text
-
yNumberThe y coordinate for the top of the text
-
maxWidthNumberThe maximum allowed width of the text
-
lineHeightThe height of the text line
-
alignStringThe alignment of the text
fillAll ( color )
Fills the entire bitmap.
Parameters:
-
colorStringThe color of the rectangle in CSS format
fillRect ( x , y , width , height , color )
Fills the specified rectangle.
Parameters:
-
xNumberThe x coordinate for the upper-left corner
-
yNumberThe y coordinate for the upper-left corner
-
widthNumberThe width of the rectangle to clear
-
heightNumberThe height of the rectangle to clear
-
colorStringThe color of the rectangle in CSS format
getAlphaPixel ( x , y ) String
Returns alpha pixel value at the specified point.
Parameters:
-
xNumberThe x coordinate of the pixel in the bitmap
-
yNumberThe 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:
-
xNumberThe x coordinate of the pixel in the bitmap
-
yNumberThe 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:
-
xNumberThe x coordinate for the upper-left corner
-
yNumberThe y coordinate for the upper-left corner
-
widthNumberThe width of the rectangle to clear
-
heightNumberThe height of the rectangle to clear
-
color1StringThe start color of the gradation
-
color2StringThe end color of the gradation
-
verticalBooleanWhether 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:
-
urlStringThe image url of the texture
Returns:
Bitmap
measureTextWidth ( text ) Number
Returns the width of the specified text.
Parameters:
-
textStringThe text to be measured
Returns:
Number:
The width of the text in pixels
resize ( width , height )
Resizes the bitmap.
Parameters:
-
widthNumberThe new width of the bitmap
-
heightNumberThe new height of the bitmap
rotateHue ( offset )
Rotates the hue of the entire bitmap.
Parameters:
-
offsetNumberThe hue offset in 360 degrees
snap ( stage ) [static]
Takes a snapshot of the game screen and returns a new bitmap object.
Parameters:
-
stagePIXI.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.