Skip to main content
Version: 9.0.2

CANVAS:draw_image

CANVAS:draw_image(name, attrs)

Draw an image within the canvas directed by the user specified properties.

Parameters

ParameterTypeDescription
name#stringThe project relative name of the image, same as used in the Image Render Extension.
attrs#tableA table of properties containing information about how to draw the image (see Draw Image Attributes Table).

Draw Image Attributes Table

KeyDescription
xThe x position of the upper left corner of the text (default: 0).
yThe y position of the upper left corner of the text (default: 0).
wThe width to scale the image to (default: natural width).
hThe height to scale the image to (default: natural height).
rotationThe angle of rotation in degrees (default: 0). This rotation point is around the upper left corner of the image.
halignThe horizontal anchor, gre.LEFT, gre.CENTER, or gre.RIGHT (default: gre.LEFT).
valignThe vertical anchor, gre.TOP, gre.CENTER, or gre.BOTTOM (default: gre.TOP).

Example

-- Draw an image scaled to the canvas size
function DrawImage(name)
local canvas = gre.get_canvas(name)
local size = canvas:get_dimensions()
local attrs = {}
attrs.w = size.width
attrs.h = size.height
canvas:draw_image("images/logo.png", attrs)
end