Class: Bitmap

Bitmap(width, height)

new Bitmap(width, height)

The basic object that represents an image. Bitmap states(Bitmap._loadingState): none: Empty Bitmap pending: Url requested, but pending to load until startRequest called purged: Url request completed and purged. requesting: Requesting supplied URI now. requestCompleted: Request completed decrypting: requesting encrypted data from supplied URI or decrypting it. decryptCompleted: Decrypt completed loaded: loaded. isReady() === true, so It's usable. error: error occurred
Parameters:
Name Type Description
width Number The width of the bitmap
height Number The height of the bitmap
Properties:
Name Type Description
cacheEntry CacheEntry Cache entry, for images. In all cases _url is the same as cacheEntry.key
fontFaceThe String face name of the font.
fontSize Number The size of the font in pixels.
fontItalic Boolean Whether the font is italic.
textColor String The color of the text in CSS format.
outlineColor String The color of the outline of the text in CSS format.
outlineWidth Number The width of the outline of the text.
url String [read-only] The url of the image file.
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.
width Number [read-only] The width of the bitmap.
height Number [read-only] The height of the bitmap.
rect Rectangle [read-only] The rectangle of the bitmap.
smooth Boolean Whether the smooth scaling is applied.
paintOpacity Number The opacity of the drawing object in the range (0, 255).

Methods

(static) load(url) → {Bitmap}

Loads a image file and returns a new bitmap object.
Parameters:
Name Type Description
url String The image url of the texture
Returns:
Type
Bitmap

(static) snap(stage) → {Bitmap}

Takes a snapshot of the game screen and returns a new bitmap object.
Parameters:
Name Type Description
stage Stage The stage object
Returns:
Type
Bitmap

addLoadListener(listner)

Add a callback function that will be called when the bitmap is loaded.
Parameters:
Name Type Description
listner function The callback function

adjustTone(r, g, b)

Changes the color tone of the entire bitmap.
Parameters:
Name Type Description
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, dwopt, dhopt)

Performs a block transfer.
Parameters:
Name Type Attributes 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 <optional>
sw The width to draw the image in the destination
dh Number <optional>
sh The height to draw the image in the destination

bltImage(source, sx, sy, sw, sh, dx, dy, dwopt, dhopt)

Performs a block transfer, using assumption that original image was not modified (no hue)
Parameters:
Name Type Attributes 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 <optional>
sw The width to draw the image in the destination
dh Number <optional>
sh The height to draw the image in the destination

blur()

Applies a blur effect to the bitmap.

checkDirty()

updates texture is bitmap was dirty

clear()

Clears the entire bitmap.

clearRect(x, y, width, height)

Clears the specified rectangle.
Parameters:
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

decode()

drawCircle(x, y, radius, color)

Draw a bitmap in the shape of a circle
Parameters:
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.
Parameters:
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.
Parameters:
Name Type Description
color String The color of the rectangle in CSS format

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

Fills the specified rectangle.
Parameters:
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.
Parameters:
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:
The alpha value
Type
String

getPixel(x, y) → {String}

Returns pixel color at the specified point.
Parameters:
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:
The pixel color (hex format)
Type
String

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

Draws the rectangle with a gradation.
Parameters:
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 Wether the gradient should be draw as vertical or not

initialize(width, height)

Parameters:
Name Type Description
width Number
height Number

isError() → {Boolean}

Checks whether a loading error has occurred.
Returns:
True if a loading error has occurred
Type
Boolean

isReady() → {Boolean}

Checks whether the bitmap is ready to render.
Returns:
True if the bitmap is ready to render
Type
Boolean

isRequestOnly() → {Boolean}

Returns:
Type
Boolean

isRequestReady() → {Boolean}

Returns:
Type
Boolean

measureTextWidth(text) → {Number}

Returns the width of the specified text.
Parameters:
Name Type Description
text String The text to be measured
Returns:
The width of the text in pixels
Type
Number

request(url) → {Bitmap}

Parameters:
Name Type Description
url String
Returns:
Type
Bitmap

resize(width, height)

Resizes the bitmap.
Parameters:
Name Type Description
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:
Name Type Description
offset Number The hue offset in 360 degrees

startRequest()

touch()

touch the resource