> ## Documentation Index
> Fetch the complete documentation index at: https://docs.atlanta.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Draw

> A comprehensive module containing functions for low-level graphical rendering, allowing scripts to draw shapes, text, images, and gradients directly to the screen within the draw event.

***

<Warning>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.</Warning>

***

## 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.

```lua Draw Usage Example theme={null}
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.

```lua theme={null}
line(Rect: rect, Color4: color, number?: thickness): void
```

<ParamField path="rect" type="Rect" required>The Rect defining the line's start (low) and end (high) points.</ParamField>
<ParamField path="color" type="Color4" required>The color of the line.</ParamField>
<ParamField path="thickness" type="number">The thickness of the line in pixels. Defaults to `1`.</ParamField>

### rect

Draws a rectangle outline.

```lua theme={null}
rect(Rect: rect, Color4: color, number?: rounding, number?: thickness): void
```

<ParamField path="rect" type="Rect" required>The Rect defining the rectangle's position and size.</ParamField>
<ParamField path="color" type="Color4" required>The color of the rectangle outline.</ParamField>
<ParamField path="rounding" type="number">The corner rounding radius. Defaults to `0`.</ParamField>
<ParamField path="thickness" type="number">The thickness of the outline in pixels. Defaults to `1`.</ParamField>

### rect\_filled

Draws a filled rectangle.

```lua theme={null}
rect_filled(Rect: rect, Color4: color, number?: rounding): void
```

<ParamField path="rect" type="Rect" required>The Rect defining the rectangle's position and size.</ParamField>
<ParamField path="color" type="Color4" required>The fill color of the rectangle.</ParamField>
<ParamField path="rounding" type="number">The corner rounding radius. Defaults to `0`.</ParamField>

### rect\_gradient

Draws a filled rectangle with a gradient.

```lua theme={null}
rect_gradient(Rect: rect, Color4: top, Color4: bottom, boolean?: inverse): void
```

<ParamField path="rect" type="Rect" required>The Rect defining the rectangle's position and size.</ParamField>
<ParamField path="top" type="Color4" required>The color at the top of the gradient.</ParamField>
<ParamField path="bottom" type="Color4" required>The color at the bottom of the gradient.</ParamField>
<ParamField path="inverse" type="boolean">Whether to inverse the gradient direction. Defaults to `false`.</ParamField>

### quad

Draws a quadrilateral outline defined by four points.

```lua theme={null}
quad(Vector2: p1, Vector2: p2, Vector2: p3, Vector2: p4, Color4: color, number?: thickness): void
```

<ParamField path="p1" type="Vector2" required>The first corner point of the quadrilateral.</ParamField>
<ParamField path="p2" type="Vector2" required>The second corner point of the quadrilateral.</ParamField>
<ParamField path="p3" type="Vector2" required>The third corner point of the quadrilateral.</ParamField>
<ParamField path="p4" type="Vector2" required>The fourth corner point of the quadrilateral.</ParamField>
<ParamField path="color" type="Color4" required>The color of the quadrilateral outline.</ParamField>
<ParamField path="thickness" type="number">The thickness of the outline in pixels. Defaults to `1`.</ParamField>

### quad\_filled

Draws a filled quadrilateral defined by four points.

```lua theme={null}
quad_filled(Vector2: p1, Vector2: p2, Vector2: p3, Vector2: p4, Color4: color): void
```

<ParamField path="p1" type="Vector2" required>The first corner point of the quadrilateral.</ParamField>
<ParamField path="p2" type="Vector2" required>The second corner point of the quadrilateral.</ParamField>
<ParamField path="p3" type="Vector2" required>The third corner point of the quadrilateral.</ParamField>
<ParamField path="p4" type="Vector2" required>The fourth corner point of the quadrilateral.</ParamField>
<ParamField path="color" type="Color4" required>The fill color of the quadrilateral.</ParamField>

### triangle

Draws a triangle outline defined by three points.

```lua theme={null}
triangle(Vector2: p1, Vector2: p2, Vector2: p3, Color4: color, number?: thickness): void
```

<ParamField path="p1" type="Vector2" required>The first corner point of the triangle.</ParamField>
<ParamField path="p2" type="Vector2" required>The second corner point of the triangle.</ParamField>
<ParamField path="p3" type="Vector2" required>The third corner point of the triangle.</ParamField>
<ParamField path="color" type="Color4" required>The color of the triangle outline.</ParamField>
<ParamField path="thickness" type="number">The thickness of the outline in pixels. Defaults to `1`.</ParamField>

### triangle\_filled

Draws a filled triangle defined by three points.

```lua theme={null}
triangle_filled(Vector2: p1, Vector2: p2, Vector2: p3, Color4: color): void
```

<ParamField path="p1" type="Vector2" required>The first corner point of the triangle.</ParamField>
<ParamField path="p2" type="Vector2" required>The second corner point of the triangle.</ParamField>
<ParamField path="p3" type="Vector2" required>The third corner point of the triangle.</ParamField>
<ParamField path="color" type="Color4" required>The fill color of the triangle.</ParamField>

### circle

Draws a circle outline.

```lua theme={null}
circle(Vector2: pos, Color4: color, number: radius, number?: segments, number?: thickness): void
```

<ParamField path="pos" type="Vector2" required>The center position of the circle.</ParamField>
<ParamField path="color" type="Color4" required>The color of the circle outline.</ParamField>
<ParamField path="radius" type="number" required>The radius of the circle.</ParamField>
<ParamField path="segments" type="number">The number of segments used to draw the circle. Defaults to `0` (auto).</ParamField>
<ParamField path="thickness" type="number">The thickness of the outline in pixels. Defaults to `1`.</ParamField>

### circle\_filled

Draws a filled circle.

```lua theme={null}
circle_filled(Vector2: pos, Color4: color, number: radius, number?: segments): void
```

<ParamField path="pos" type="Vector2" required>The center position of the circle.</ParamField>
<ParamField path="color" type="Color4" required>The fill color of the circle.</ParamField>
<ParamField path="radius" type="number" required>The radius of the circle.</ParamField>
<ParamField path="segments" type="number">The number of segments used to draw the circle. Defaults to `0` (auto).</ParamField>

### text

Draws text at the specified position.

```lua theme={null}
text(Vector2: pos, Color4: color, string: text, number?: font, number?: font_size, number?: outline, Color4?: outline_color): void
```

<ParamField path="pos" type="Vector2" required>The position where the text will be drawn.</ParamField>
<ParamField path="color" type="Color4" required>The color of the text.</ParamField>
<ParamField path="text" type="string" required>The text string to draw.</ParamField>
<ParamField path="font" type="number">The font identifier. Defaults to `0` (default font).</ParamField>
<ParamField path="font_size" type="number">The size of the font. Defaults to `0` (default size).</ParamField>
<ParamField path="outline" type="number">The outline thickness. Defaults to `3`.</ParamField>
<ParamField path="outline_color" type="Color4">The color of the text outline. Defaults to black `(0, 0, 0, 1)`.</ParamField>

### 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.

```lua theme={null}
text_size(string: text, number?: font, number?: font_size): Vector2
```

<ParamField path="text" type="string" required>The text string to measure.</ParamField>
<ParamField path="font" type="number">The font identifier. Defaults to `0` (default font).</ParamField>
<ParamField path="font_size" type="number">The size of the font. Defaults to `0` (default size).</ParamField>
