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

# Render

> Drawing functions. Work only inside the paint and player_esp callbacks.

## Primitives

| Function | Parameters | Description |
| - | - | - |
| `render.rect(x, y, w, h, col [, rounding, thickness, corners])` | | Outlined rectangle |
| `render.rect_filled(x, y, w, h, col [, rounding, corners])` | | Filled rectangle |
| `render.rect_filled_multicolor(x, y, w, h, tl, tr, br, bl)` | | Four-corner gradient rectangle |
| `render.gradient(x, y, w, h, col1, col2 [, horizontal])` | | Two-color gradient |
| `render.line(x1, y1, x2, y2, col [, thickness])` | | Line segment |
| `render.circle(x, y, r, col [, segments, thickness])` | | Outlined circle |
| `render.circle_filled(x, y, r, col [, segments])` | | Filled circle |
| `render.circle_gradient(x, y, r, inner, outer [, segments])` | | Radial gradient circle |
| `render.triangle_filled(x1, y1, x2, y2, x3, y3, col)` | | Filled triangle |
| `render.triangle_multicolor(x1, y1, c1, x2, y2, c2, x3, y3, c3)` | | Per-vertex colored triangle |
| `render.poly(points, col [, thickness, closed])` | | Polyline from `{{x,y}, ...}` |
| `render.poly_filled(points, col)` | | Filled convex polygon |
| `render.shadow(x, y, w, h, col [, size, rounding])` | | Drop shadow |
| `render.pie(x, y, r, fill, col [, segments, start_deg])` | | Pie/arc fill. `fill` is 0..1 |
| `render.arc(x, y, r, from_deg, to_deg, col [, thickness, segments])` | | Arc stroke |
| `render.blur(x, y, w, h [, rounding, tint])` | | Blurred backdrop. Returns `bool` |

## Text

```lua theme={null} theme={null}
render.text(x, y, col, text [, flags, size, font])
```

**Flags** (combine as a string):

| Flag | Effect |
| - | - |
| `c` | Center horizontally |
| `v` | Center vertically |
| `r` | Right-align |
| `s` | Shadow |
| `o` | Outline |
| `p` | Pixel-perfect rounding |

```lua theme={null} theme={null}
local w, h = render.text_size(text [, flags, size, font])
```

### Word wrap

```lua theme={null} theme={null}
local lines = render.wrap_text(text, width [, size, font])
-- returns { "line1", "line2", ... }
```

## Fonts

```lua theme={null} theme={null}
local font = render.font(filename [, size])
```

Load a TTF/OTF from `scripts/fonts`. Default size is 14.

| Method | Returns |
| - | - |
| `font:loaded()` | `bool` |

Pass the font object as the last argument to `render.text` and `render.text_size`.

## Images

```lua theme={null} theme={null}
local tex = render.load_image(filename, w, h)
local tex = render.load_svg(svg_string_or_file, height)
local tex = render.texture(rgba_string, w, h)
```

`load_image` loads from `scripts/images`. `texture` creates from raw RGBA bytes.

```lua theme={null} theme={null}
render.image(tex, x, y [, w, h, tint, rounding])
```

| Method | Returns |
| - | - |
| `tex:size()` | `w, h` |

## Icons

```lua theme={null} theme={null}
local tex, err = render.icon(name [, height])
local names = render.icons()
```

`render.icon` returns a game icon texture. `render.icons()` lists all available names.

## Clipping

```lua theme={null} theme={null}
render.clip_push(x, y, w, h [, intersect])
render.clip_pop()
```

## Projection

```lua theme={null} theme={null}
local x, y = render.world_to_screen(vec)
-- returns nil if off-screen
```

## Screen

```lua theme={null} theme={null}
local w, h = render.screen_size()
local scale = render.scale()         -- widget DPI scale
local ms = render.menu_scale()       -- menu DPI scale
```

## Theme

```lua theme={null} theme={null}
local col = render.theme('accent')   -- single theme color
local all = render.theme()           -- table of all theme colors
```

## Example

```lua theme={null} theme={null}
events.on('paint', function()
    local w, h = render.screen_size()
    render.rect_filled(w / 2 - 50, 10, 100, 4, color('#4af'))
    render.text(w / 2, 20, color(255, 255, 255), 'nlcrack', 'cs')
end)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.