> For the complete documentation index, see [llms.txt](https://rawetrip.gitbook.io/rawetrip-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rawetrip.gitbook.io/rawetrip-api/documentation/variables/render.md).

# render

## Functions:

### world\_to\_screen

`render.world_to_screen(position: vector):` <mark style="color:purple;">`vector`</mark>

| Name         | Type         | Description             |
| ------------ | ------------ | ----------------------- |
| **position** | **`vector`** | Position in world space |

Returns the screen position vector. This can only be called from the on\_paint callback.

### setup\_font

`render.setup_font(name: string, size: number, flags: number):` <mark style="color:purple;">`FontObject`</mark>

<table><thead><tr><th width="152">Name</th><th width="167">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>name</strong></td><td><strong><code>string</code></strong></td><td>Font that will be initialized</td></tr><tr><td><strong>size</strong></td><td><strong><code>number</code></strong></td><td>Size of the font</td></tr><tr><td><strong>flags</strong></td><td><strong><code>number</code></strong></td><td><mark style="color:purple;"><code>fontflags.noantialiasing</code></mark> for anti-aliasing, <mark style="color:purple;"><code>fontflags.italic</code></mark> for cursive text, <mark style="color:purple;"><code>fontflags.bold</code></mark> bold text</td></tr></tbody></table>

```lua
local font = render.setup_font("Verdana", 12, fontflags.noantialiasing | fontflags.bold)
```

Returns the <mark style="color:purple;">`FontObject`</mark> struct or nil on failure.

### setup\_weapon\_font

`render.setup_weapon_font(size: number):` <mark style="color:purple;">`FontObject`</mark>

| Name     | Type         | Description      |
| -------- | ------------ | ---------------- |
| **size** | **`number`** | Size of the font |

Returns the <mark style="color:purple;">`FontObject`</mark> struct or nil on failure.

### setup\_texture

`render.setup_texture(path: string):` <mark style="color:purple;">`texture`</mark>

| Name                                        | Type     | Description       |
| ------------------------------------------- | -------- | ----------------- |
| <mark style="color:purple;">**path**</mark> | `string` | Path to the image |

Returns the <mark style="color:purple;">`texture`</mark> or nil on failure.

### get\_text\_size

`render.get_text_size(font: FontObject, text: string):` <mark style="color:purple;">`vector`</mark>

| Name     | Type             | Description                |
| -------- | ---------------- | -------------------------- |
| **font** | **`FontObject`** | Font                       |
| **text** | **`string`**     | Text that will be measured |

Returns the size of the text.

## Structs

### 🔗 <mark style="color:blue;">`FontObject`</mark>

#### size

`font.size:` <mark style="color:purple;">`number`</mark>

## Draw functions

### blur

`render.blur(x: number, y: number: width: number, height: number, alpha: number)`

<table><thead><tr><th width="190">Name</th><th width="182">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>x</strong></td><td><strong><code>number</code></strong></td><td>X position</td></tr><tr><td><strong>y</strong></td><td><strong><code>number</code></strong></td><td>Y position</td></tr><tr><td><strong>width</strong></td><td><strong><code>number</code></strong></td><td>Width</td></tr><tr><td><strong>height</strong></td><td><strong><code>number</code></strong></td><td>Height</td></tr><tr><td><strong>alpha</strong></td><td><strong><code>number</code></strong></td><td>Alpha percentage in the range [0, 255]</td></tr></tbody></table>

### line

`render.line(x: number, y: number, x2: number, y2: number, color: color, thickness: number)`

<table><thead><tr><th width="190">Name</th><th width="182">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>x</strong></td><td><strong><code>number</code></strong></td><td>X position</td></tr><tr><td><strong>y</strong></td><td><strong><code>number</code></strong></td><td>Y position</td></tr><tr><td><strong>x2</strong></td><td><strong><code>number</code></strong></td><td>X2 position</td></tr><tr><td><strong>y2</strong></td><td><strong><code>number</code></strong></td><td>Y2 position</td></tr><tr><td><strong>color</strong></td><td><strong><code>color</code></strong></td><td>Color of the line</td></tr><tr><td><strong>thickness</strong></td><td><strong><code>number</code></strong></td><td>Thickness of the line</td></tr></tbody></table>

### polygon

`render.polygon(color: color, positions: {, ...})`

|               |              |                      |
| ------------- | ------------ | -------------------- |
| **color**     | **`color`**  | Color of the polygon |
| **positions** | **`vector`** | Screen positions     |

### polyline

`render.polyline(color: color, closed: boolean, thickness: number, positions: {, ...})`

|               |               |                           |
| ------------- | ------------- | ------------------------- |
| **color**     | **`color`**   | Color of the polyline     |
| **closed**    | **`boolean`** | -                         |
| **thickness** | **`number`**  | Thickness of the polyline |
| **positions** | **`vector`**  | Screen positions          |

### rect

`render.rect(x: number, y: number, width: number, height: number, color: color[, rounding: number])`

<table><thead><tr><th width="190">Name</th><th width="178.9106529209622">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>x</strong></td><td><strong><code>number</code></strong></td><td>X position</td></tr><tr><td><strong>y</strong></td><td><strong><code>number</code></strong></td><td>Y position</td></tr><tr><td><strong>width</strong></td><td><strong><code>number</code></strong></td><td>Width</td></tr><tr><td><strong>height</strong></td><td><strong><code>number</code></strong></td><td>Height</td></tr><tr><td><strong>color</strong></td><td><strong><code>color</code></strong></td><td>Color of the rectangle</td></tr><tr><td><strong>rounding</strong></td><td><strong><code>number</code></strong></td><td>Optional. Rounding of the rectangle in pixels</td></tr></tbody></table>

### rect\_filled

`render.rect_filled(x: number, y: number, width: number, height: number, color: color[, rounding: number])`

<table><thead><tr><th width="190">Name</th><th width="178.9106529209622">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>x</strong></td><td><strong><code>number</code></strong></td><td>X position</td></tr><tr><td><strong>y</strong></td><td><strong><code>number</code></strong></td><td>Y position</td></tr><tr><td><strong>width</strong></td><td><strong><code>number</code></strong></td><td>Width</td></tr><tr><td><strong>height</strong></td><td><strong><code>number</code></strong></td><td>Height</td></tr><tr><td><strong>color</strong></td><td><strong><code>color</code></strong></td><td>Color of the rectangle</td></tr><tr><td><strong>rounding</strong></td><td><strong><code>number</code></strong></td><td>Optional. Rounding of the rectangle in pixels</td></tr></tbody></table>

### gradient

`render.gradient(x: number, y: number, width: number, height: number, first_color: color, second_color[, type: number])`

<table><thead><tr><th width="190">Name</th><th width="178.9106529209622">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>x</strong></td><td><strong><code>number</code></strong></td><td>X position</td></tr><tr><td><strong>y</strong></td><td><strong><code>number</code></strong></td><td>Y position</td></tr><tr><td><strong>width</strong></td><td><strong><code>number</code></strong></td><td>Width</td></tr><tr><td><strong>height</strong></td><td><strong><code>number</code></strong></td><td>Height</td></tr><tr><td><strong>first_color</strong></td><td><strong><code>color</code></strong></td><td>First color</td></tr><tr><td><strong>second_color</strong></td><td><strong><code>color</code></strong></td><td>Second color</td></tr><tr><td><strong>type</strong></td><td><strong><code>number</code></strong></td><td>Optional. <mark style="color:purple;"><code>0</code></mark> - horizontal, <mark style="color:purple;"><code>1</code></mark> - vertical</td></tr></tbody></table>

### circle

`render.circle(x: number, y: number, points: number, radius: number, color: color)`

<table><thead><tr><th width="190">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>x</strong></td><td><strong><code>number</code></strong></td><td>X position</td></tr><tr><td><strong>y</strong></td><td><strong><code>number</code></strong></td><td>Y position</td></tr><tr><td><strong>points</strong></td><td><strong><code>number</code></strong></td><td>Points of the circle</td></tr><tr><td><strong>radius</strong></td><td><strong><code>number</code></strong></td><td>Radius of the circle</td></tr><tr><td><strong>color</strong></td><td><strong><code>color</code></strong></td><td>Color of the circle</td></tr></tbody></table>

### circle\_filled

`render.circle_filled(x: number, y: number, points: number, radius: number, color: color)`

<table><thead><tr><th width="190">Name</th><th width="178.9106529209622">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>x</strong></td><td><strong><code>number</code></strong></td><td>X position</td></tr><tr><td><strong>y</strong></td><td><strong><code>number</code></strong></td><td>Y position</td></tr><tr><td><strong>points</strong></td><td><strong><code>number</code></strong></td><td>Points of the circle</td></tr><tr><td><strong>radius</strong></td><td><strong><code>number</code></strong></td><td>Radius of the circle</td></tr><tr><td><strong>color</strong></td><td><strong><code>color</code></strong></td><td>Color of the circle</td></tr></tbody></table>

### glow\_circle

`render.glow_circle(x: number, y: number, radius: number, color: color)`

<table><thead><tr><th width="190">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>x</strong></td><td><strong><code>number</code></strong></td><td>X position</td></tr><tr><td><strong>y</strong></td><td><strong><code>number</code></strong></td><td>Y position</td></tr><tr><td><strong>radius</strong></td><td><strong><code>number</code></strong></td><td>Radius of the circle</td></tr><tr><td><strong>color</strong></td><td><strong><code>color</code></strong></td><td>Color of the circle</td></tr></tbody></table>

### arc

`render.arc(x: number, y: number: radius: number, second_radius: number, min: number, max: number, color: color)`

<table><thead><tr><th width="190">Name</th><th width="178.9106529209622">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>x</strong></td><td><strong><code>number</code></strong></td><td>X position</td></tr><tr><td><strong>y</strong></td><td><strong><code>number</code></strong></td><td>Y position</td></tr><tr><td><strong>radius</strong></td><td><strong><code>number</code></strong></td><td>Radiusof the circle</td></tr><tr><td><strong>second_radius</strong></td><td><strong><code>number</code></strong></td><td>Second radius of the circle</td></tr><tr><td><strong>min</strong></td><td><strong><code>number</code></strong></td><td>Minimum value</td></tr><tr><td><strong>max</strong></td><td><strong><code>number</code></strong></td><td>Maximum value</td></tr><tr><td><strong>color</strong></td><td><strong><code>color</code></strong></td><td>Color of the circle</td></tr></tbody></table>

### circle\_3d

`render.circle_3d(position: vector, radius: number, color: color)`

<table><thead><tr><th width="190">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>position</strong></td><td><strong><code>vector</code></strong></td><td>Screen position</td></tr><tr><td><strong>radius</strong></td><td><strong><code>number</code></strong></td><td>Radius of the circle</td></tr><tr><td><strong>color</strong></td><td><strong><code>color</code></strong></td><td>Color of the circle</td></tr></tbody></table>

### circle\_filled\_3d

`render.circle_filled_3d(position: vector, radius: number, color: color)`

<table><thead><tr><th width="190">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>position</strong></td><td><strong><code>vector</code></strong></td><td>Screen position</td></tr><tr><td><strong>radius</strong></td><td><strong><code>number</code></strong></td><td>Radius of the circle</td></tr><tr><td><strong>color</strong></td><td><strong><code>color</code></strong></td><td>Color of the circle</td></tr></tbody></table>

### text

📌 Render any text via the [`:setup_font`](#setup_font) or [`:setup_weapon_font`](#setup_weapon_font) function.

`render.text(font: FontObject, x: number, y: number, color: color, text: string[, shadow: boolean, outline: boolean])`

| Name        | Type             | Description             |
| ----------- | ---------------- | ----------------------- |
| **font**    | **`FontObject`** | Font                    |
| **x**       | **`number`**     | X position              |
| **y**       | **`number`**     | Y position              |
| **color**   | **`color`**      | Color of the text       |
| **text**    | **`string`**     | Text that will be drawn |
| **shadow**  | **`boolean`**    | Optional. Text shadow   |
| **outline** | **`boolean`**    | Optional. Text outline  |

### text\_gradient

📌 Render any text via the [`:setup_font`](#setup_font) or [`:setup_weapon_font`](#setup_weapon_font) function.

`render.text_gradient(font: FontObject, x: number, y: number, color: color, second_color: color, text: string, smooth: number[, shadow: boolean, outline: boolean])`

| Name              | Type             | Description                |
| ----------------- | ---------------- | -------------------------- |
| **font**          | **`FontObject`** | Font                       |
| **x**             | **`number`**     | X position                 |
| **y**             | **`number`**     | Y position                 |
| **color**         | **`color`**      | Color of the text          |
| **second\_color** | **`color`**      | Second color of the text   |
| **text**          | **`string`**     | Text that will be drawn    |
| **smooth**        | **`number`**     | Smoothness of the gradient |
| **shadow**        | **`boolean`**    | Optional. Text shadow      |
| **outline**       | **`boolean`**    | Optional. Text outline     |

### image

`render.image(texture: texture, x: number, y: number, width: number, height: number, color: color[, rounding: number])`

| Name         | Type          | Description              |
| ------------ | ------------- | ------------------------ |
| **texture**  | **`texture`** | Texture                  |
| **x**        | **`number`**  | X position               |
| **y**        | **`number`**  | Y position               |
| **width**    | **`number`**  | Width                    |
| **height**   | **`number`**  | Height                   |
| **color**    | **`color`**   | Color of the image       |
| **rounding** | **`number`**  | Optional. Image rounding |

### rect\_shadow

`render.rect_shadow(x: number, y: number, width: number, height: number, length: number, color: color[, x_offset: number, y_offset: number])`

| Name          | Type         | Description        |
| ------------- | ------------ | ------------------ |
| **x**         | **`number`** | X position         |
| **y**         | **`number`** | Y position         |
| **width**     | **`number`** | Width              |
| **height**    | **`number`** | Height             |
| **length**    | **`number`** | Shadow length      |
| **color**     | **`color`**  | Shadow color       |
| **x\_offset** | **`number`** | Optional. X offset |
| **y\_offset** | **`number`** | Optional. Y offset |

### rect\_shadow\_ex

`render.rect_shadow_ex(position: vector_2d, size: vector_2d, rings: number, sbr: vector, length: number, color: color[, x_offset: number, y_offset: number])`

<table><thead><tr><th width="163">Name</th><th width="148">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>position</strong></td><td><strong><code>vector_2d</code></strong></td><td>Shadow position</td></tr><tr><td><strong>size</strong></td><td><strong><code>vector_2d</code></strong></td><td>Shadow size</td></tr><tr><td><strong>rings</strong></td><td><strong><code>number</code></strong></td><td>Shadow rings</td></tr><tr><td><strong>sbr</strong></td><td><strong><code>vector</code></strong></td><td><code>vector(between_rings: number, per_corner_side: number, between_samples: number)</code></td></tr><tr><td><strong>length</strong></td><td><strong><code>number</code></strong></td><td>Shadow length</td></tr><tr><td><strong>color</strong></td><td><strong><code>color</code></strong></td><td>Shadow color</td></tr><tr><td><strong>x_offset</strong></td><td><strong><code>number</code></strong></td><td>Optional. X offset</td></tr><tr><td><strong>y_offset</strong></td><td><strong><code>number</code></strong></td><td>Optional. Y offset</td></tr></tbody></table>

### begin\_cliprect

`render.begin_cliprect(x: number, y: number, width: number, height: number)`

| Name       | Type         | Description |
| ---------- | ------------ | ----------- |
| **x**      | **`number`** | X position  |
| **y**      | **`number`** | Y position  |
| **width**  | **`number`** | Width       |
| **height** | **`number`** | Height      |

Applies the clip region to the given rectangle for all subsequent elements.

### end\_cliprect

`render.end_cliprect()`

Discards an early set rectangle clipping region.
