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
event.set(EventType.Draw, function()
	draw.line(Rect.new(10, 10, 200, 250), Color4.new(1, 0, 0, 1)); -- Dot Operator
	draw["rect_filled"](Rect.new(Vector2.new(20, 30), Vector2.new(150, 215)), Color4.new(0, 0, 1, 1), 2.5); -- Bracket Operator
end);

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

rect

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

rect_filled

Draws a filled rectangle.
rect_filled(Rect: rect, Color4: color, number?: rounding): void
rect
Rect
required
The Rect defining the rectangle’s position and size.
color
Color4
required
The fill color of the rectangle.
rounding
number
The corner rounding radius. Defaults to 0.

rect_gradient

Draws a filled rectangle with a gradient.
rect_gradient(Rect: rect, Color4: top, Color4: bottom, boolean?: inverse): void
rect
Rect
required
The Rect defining the rectangle’s position and size.
top
Color4
required
The color at the top of the gradient.
bottom
Color4
required
The color at the bottom of the gradient.
inverse
boolean
Whether to inverse the gradient direction. Defaults to false.

quad

Draws a quadrilateral outline defined by four points.
quad(Vector2: p1, Vector2: p2, Vector2: p3, Vector2: p4, Color4: color, number?: thickness): void
p1
Vector2
required
The first corner point of the quadrilateral.
p2
Vector2
required
The second corner point of the quadrilateral.
p3
Vector2
required
The third corner point of the quadrilateral.
p4
Vector2
required
The fourth corner point of the quadrilateral.
color
Color4
required
The color of the quadrilateral outline.
thickness
number
The thickness of the outline in pixels. Defaults to 1.

quad_filled

Draws a filled quadrilateral defined by four points.
quad_filled(Vector2: p1, Vector2: p2, Vector2: p3, Vector2: p4, Color4: color): void
p1
Vector2
required
The first corner point of the quadrilateral.
p2
Vector2
required
The second corner point of the quadrilateral.
p3
Vector2
required
The third corner point of the quadrilateral.
p4
Vector2
required
The fourth corner point of the quadrilateral.
color
Color4
required
The fill color of the quadrilateral.

triangle

Draws a triangle outline defined by three points.
triangle(Vector2: p1, Vector2: p2, Vector2: p3, Color4: color, number?: thickness): void
p1
Vector2
required
The first corner point of the triangle.
p2
Vector2
required
The second corner point of the triangle.
p3
Vector2
required
The third corner point of the triangle.
color
Color4
required
The color of the triangle outline.
thickness
number
The thickness of the outline in pixels. Defaults to 1.

triangle_filled

Draws a filled triangle defined by three points.
triangle_filled(Vector2: p1, Vector2: p2, Vector2: p3, Color4: color): void
p1
Vector2
required
The first corner point of the triangle.
p2
Vector2
required
The second corner point of the triangle.
p3
Vector2
required
The third corner point of the triangle.
color
Color4
required
The fill color of the triangle.

circle

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

circle_filled

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

text

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