Skip to main content

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 named draw. 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 global draw 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.
Rect
required
The Rect defining the line’s start (low) and end (high) points.
Color4
required
The color of the line.
number
The thickness of the line in pixels. Defaults to 1.

rect

Draws a rectangle outline.
Rect
required
The Rect defining the rectangle’s position and size.
Color4
required
The color of the rectangle outline.
number
The corner rounding radius. Defaults to 0.
number
The thickness of the outline in pixels. Defaults to 1.

rect_filled

Draws a filled rectangle.
Rect
required
The Rect defining the rectangle’s position and size.
Color4
required
The fill color of the rectangle.
number
The corner rounding radius. Defaults to 0.

rect_gradient

Draws a filled rectangle with a gradient.
Rect
required
The Rect defining the rectangle’s position and size.
Color4
required
The color at the top of the gradient.
Color4
required
The color at the bottom of the gradient.
boolean
Whether to inverse the gradient direction. Defaults to false.

quad

Draws a quadrilateral outline defined by four points.
Vector2
required
The first corner point of the quadrilateral.
Vector2
required
The second corner point of the quadrilateral.
Vector2
required
The third corner point of the quadrilateral.
Vector2
required
The fourth corner point of the quadrilateral.
Color4
required
The color of the quadrilateral outline.
number
The thickness of the outline in pixels. Defaults to 1.

quad_filled

Draws a filled quadrilateral defined by four points.
Vector2
required
The first corner point of the quadrilateral.
Vector2
required
The second corner point of the quadrilateral.
Vector2
required
The third corner point of the quadrilateral.
Vector2
required
The fourth corner point of the quadrilateral.
Color4
required
The fill color of the quadrilateral.

triangle

Draws a triangle outline defined by three points.
Vector2
required
The first corner point of the triangle.
Vector2
required
The second corner point of the triangle.
Vector2
required
The third corner point of the triangle.
Color4
required
The color of the triangle outline.
number
The thickness of the outline in pixels. Defaults to 1.

triangle_filled

Draws a filled triangle defined by three points.
Vector2
required
The first corner point of the triangle.
Vector2
required
The second corner point of the triangle.
Vector2
required
The third corner point of the triangle.
Color4
required
The fill color of the triangle.

circle

Draws a circle outline.
Vector2
required
The center position of the circle.
Color4
required
The color of the circle outline.
number
required
The radius of the circle.
number
The number of segments used to draw the circle. Defaults to 0 (auto).
number
The thickness of the outline in pixels. Defaults to 1.

circle_filled

Draws a filled circle.
Vector2
required
The center position of the circle.
Color4
required
The fill color of the circle.
number
required
The radius of the circle.
number
The number of segments used to draw the circle. Defaults to 0 (auto).

text

Draws text at the specified position.
Vector2
required
The position where the text will be drawn.
Color4
required
The color of the text.
string
required
The text string to draw.
number
The font identifier. Defaults to 0 (default font).
number
The size of the font. Defaults to 0 (default size).
number
The outline thickness. Defaults to 3.
Color4
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.
string
required
The text string to measure.
number
The font identifier. Defaults to 0 (default font).
number
The size of the font. Defaults to 0 (default size).