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
-
The base texture that holds the image.
-
The bitmap canvas.
-
The 2d context of the bitmap canvas.
-
Whether the font is bold.
-
The face name of the font.
-
Whether the font is italic.
-
The size of the font in pixels.
-
The height of the bitmap.
-
The bitmap image.
-
The color of the outline of the text in CSS format.
-
The width of the outline of the text.
-
The opacity of the drawing object in the range (0, 255).
-
rect Rectangle readonly
-
The rectangle of the bitmap.
-
Whether the smooth scaling is applied.
-
The color of the text in CSS format.
-
The url of the image file.
-
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. -
Adds a callback function that will be called when the bitmap is loaded.
Name Type Description listner
function The callback function.
-
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.
-
Clears the entire bitmap.
-
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.
-
Destroys the bitmap.
-
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.
-
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.
-
Fills the entire bitmap.
Name Type Description color
string The color of the rectangle in CSS format.
-
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.
-
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. -
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). -
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.
-
Checks whether a loading error has occurred.
Returns:
Type Description boolean True if a loading error has occurred. -
Checks whether the bitmap is ready to render.
Returns:
Type Description boolean True if the bitmap is ready to render. -
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. -
Resizes the bitmap.
Name Type Description width
number The new width of the bitmap.
height
number The new height of the bitmap.
-
Tries to load the image again.
-
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.