You must call all functions within the
draw
table (e.g., draw.rect_filled()
, draw.text()
) exclusively inside an EventType.Draw
callback function registered with the event
module. Calling draw functions from any other event or context will result in an immediate error.Access
All draw C++ functions are exposed to your Lua script via a single global table nameddraw
. You access individual values by using the dot (.
) or bracket ([]
) operator on this table.
Draw Usage Example
Functions
This section lists all available C++ functions exposed within the globaldraw
table. These functions provide low-level access to the graphics engine, enabling direct rendering of various elements like shapes, lines, text, and images to the screen.
line
Draws a line between two points defined by a Rect.The Rect defining the line’s start (low) and end (high) points.
The color of the line.
The thickness of the line in pixels. Defaults to
1
.rect
Draws a rectangle outline.The Rect defining the rectangle’s position and size.
The color of the rectangle outline.
The corner rounding radius. Defaults to
0
.The thickness of the outline in pixels. Defaults to
1
.rect_filled
Draws a filled rectangle.The Rect defining the rectangle’s position and size.
The fill color of the rectangle.
The corner rounding radius. Defaults to
0
.rect_gradient
Draws a filled rectangle with a gradient.The Rect defining the rectangle’s position and size.
The color at the top of the gradient.
The color at the bottom of the gradient.
Whether to inverse the gradient direction. Defaults to
false
.quad
Draws a quadrilateral outline defined by four points.The first corner point of the quadrilateral.
The second corner point of the quadrilateral.
The third corner point of the quadrilateral.
The fourth corner point of the quadrilateral.
The color of the quadrilateral outline.
The thickness of the outline in pixels. Defaults to
1
.quad_filled
Draws a filled quadrilateral defined by four points.The first corner point of the quadrilateral.
The second corner point of the quadrilateral.
The third corner point of the quadrilateral.
The fourth corner point of the quadrilateral.
The fill color of the quadrilateral.
triangle
Draws a triangle outline defined by three points.The first corner point of the triangle.
The second corner point of the triangle.
The third corner point of the triangle.
The color of the triangle outline.
The thickness of the outline in pixels. Defaults to
1
.triangle_filled
Draws a filled triangle defined by three points.The first corner point of the triangle.
The second corner point of the triangle.
The third corner point of the triangle.
The fill color of the triangle.
circle
Draws a circle outline.The center position of the circle.
The color of the circle outline.
The radius of the circle.
The number of segments used to draw the circle. Defaults to
0
(auto).The thickness of the outline in pixels. Defaults to
1
.circle_filled
Draws a filled circle.The center position of the circle.
The fill color of the circle.
The radius of the circle.
The number of segments used to draw the circle. Defaults to
0
(auto).text
Draws text at the specified position.The position where the text will be drawn.
The color of the text.
The text string to draw.
The font identifier. Defaults to
0
(default font).The size of the font. Defaults to
0
(default size).The outline thickness. Defaults to
3
.The color of the text outline. Defaults to black
(0, 0, 0, 1)
.text_size
Calculates and returns the size of text as it would be rendered. Returns a Vector2 containing the width and height of the text.The text string to measure.
The font identifier. Defaults to
0
(default font).The size of the font. Defaults to
0
(default size).