Image
Image Functions
loadImage
loadImage
Async. Loads a graphics image from a disk file. Unless you want to draw a rectangular image, your image's background should be transparent, or you should specify the color of the image's background for the transparentColor
parameter (see below). Images are cached, so if you load the same image with the same options more than once, it will reuse the originally loaded image for efficiency.
file
*
object
-
the file that contains the image
rotate
number
0
the number of degrees to rotate the image counter-clockwise (use a negative number to rotate clockwise)
scale
number
1
the scaling (resizing) factor, where 1 means no scaling, 2 means draw the image at twice its usual size, 0.5 means draw the image at half its usual size, etc.
Returns
object
an image that you can pass to the drawImage
function (see below) to have drawn on the screen
drawImage
drawImage
Draws a graphic image on the screen
image
*
object
-
the image to draw (must have been already loaded by the loadImage
function)
x
*
number
-
the x coordinate of the point on which to center the image
y
*
number
-
the y coordinate of the point on which to center the image
rotate
number
0
the number of degrees to rotate the image counter-clockwise (use a negative number to rotate clockwise)
scale
number
1
the scaling (resizing) factor, where 1 means no scaling, 2 means draw the image at twice its usual size, 0.5 means draw the image at half its usual size, etc.
Returns
nothing
getImageWidth
getImageWidth
Returns the width in pixels of a loaded image
image
*
object
-
the image to get the width of
Returns
number
The width in pixels
getImageHeight
getImageHeight
Returns the height in pixels of a loaded image
image
*
object
-
the image to get the height of
Returns
number
The height in pixels
Last updated