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)
rectRectanglereadonly
- The rectangle of the bitmap
- Whether smooth scaling is applied.
- The color of the text in CSS format.
- The url of the image file
- The width of the bitmap
Methods
- Adds a callback function that will be called when the bitmap is done loading
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 to start transfer from sy
number The y coordinate in the source to start transfer from sw
number The width to use from the source image sh
number The height to use from the source image dx
number The x coordinate in the destination dy
number The y coordinate in the destination dw
number sw optionalThe width to draw the image in the destination dh
number sh optionalThe 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 circle on the bitmap
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 given 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 the alpha value of the pixel at the given x/y coordinates
Name Type Description x
number The x coordinate of the pixel y
number The y coordinate of the pixel Returns:
Type Description string The alpha value - Returns the color in hex format of the pixel at the given x/y coordinates
Name Type Description x
number The x coordinate of the pixel y
number The y coordinate of the pixel Returns:
Type Description string The pixel color (hex format) - Draws the rectangle with a gradient color fill
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 height
number The height of the rectangle color1
string The gradient starting color color2
string The gradient ending color vertical
boolean Whether the gradient should be drawn as vertical or not - Initializes the bitmap object
Name Type Description width
number The width of the bitmap height
number The height of the bitmap - 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 (it is done loading)
Returns:
Type Description boolean True if the bitmap is ready to render - Gets the width of the given 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 Bitmap.load(url)Bitmapstatic
- Loads an image file from the given url
Name Type Description url
string The file path of the image file Returns:
Type Description Bitmap The created bitmap object Bitmap.snap(stage)Bitmapstatic
- Takes a snapshot of the game screen
Name Type Description stage
Stage The stage object Returns:
Type Description Bitmap The created bitmap object