CANVAS:draw_text(text, attrs)
Draw a string within the canvas directed by the user specified properties.
Parameters:
text |
The text string to display |
||||||||||||
attrs |
A table of properties containing information about how to draw the text. This table can contain the following keys:
|
Example:
-- Draw a hello world string centered on the canvas function DrawCenteredText(name) local msg = "Hello World" local canvas = gre.get_canvas(name) local size = canvas:get_dimensions() local attrs = {} attrs.font = "fonts/RobotoBold.ttf" attrs.size = 24 local strSize = gre.get_string_size(attrs.font, attrs.size, msg, 0) attrs.x = (size.width - strSize.width) / 2 attrs.y = (size.height - strSize.height) / 2 canvas:draw_text("Hello World", attrs) end