CANVAS:draw_image
CANVAS:draw_image(name, attrs)
Draw an image within the canvas directed by the user specified properties.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | #string | The project relative name of the image, same as used in the Image Render Extension. |
attrs | #table | A table of properties containing information about how to draw the image (see Draw Image Attributes Table). |
Draw Image Attributes Table
| Key | Description |
|---|---|
x | The x position of the upper left corner of the text (default: 0). |
y | The y position of the upper left corner of the text (default: 0). |
w | The width to scale the image to (default: natural width). |
h | The height to scale the image to (default: natural height). |
rotation | The angle of rotation in degrees (default: 0). This rotation point is around the upper left corner of the image. |
halign | The horizontal anchor, gre.LEFT, gre.CENTER, or gre.RIGHT (default: gre.LEFT). |
valign | The 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