# draw

## Enumerations

### ECornerRenderFlags

Description: rounding corners render flags for all function with `roundingCorners` argument, requires `flRounding` greater than 0.0

⚠️ **Warning:** `ALL` cannot be used with other flags

| Indentifiers  |
| ------------- |
| NONE          |
| TOP\_LEFT     |
| TOP\_RIGHT    |
| BOTTOM\_LEFT  |
| BOTTOM\_RIGHT |
| ALL           |

### ERectRenderFlags

Description: render flags for [AddRect()](/baimless-lua/doc/core/draw.md#addrect)

| Indentifiers        |
| ------------------- |
| DRAW\_RECT\_NONE    |
| DRAW\_RECT\_OUTLINE |
| DRAW\_RECT\_BORDER  |
| DRAW\_RECT\_FILLED  |

### EBox3DRenderFlags

Description: render flags for [AddBox3D()](/baimless-lua/doc/core/draw.md#addbox-3-d)

| Indentifiers         |
| -------------------- |
| DRAW\_BOX3D\_NONE    |
| DRAW\_BOX3D\_OUTLINE |
| DRAW\_BOX3D\_FILLED  |

### ECircleRenderFlags

Description: render flags for [AddCircle()](/baimless-lua/doc/core/draw.md#addcircle)

| Indentifiers          |
| --------------------- |
| DRAW\_CIRCLE\_NONE    |
| DRAW\_CIRCLE\_OUTLINE |
| DRAW\_CIRCLE\_FILLED  |

### ECircle3DRenderFlags

Description: render flags for [AddCircle3D()](/baimless-lua/doc/core/draw.md#addcircle-3-d)

| Indentifiers            |
| ----------------------- |
| DRAW\_CIRCLE3D\_NONE    |
| DRAW\_CIRCLE3D\_OUTLINE |
| DRAW\_CIRCLE3D\_FILLED  |
| DRAW\_CIRCLE3D\_DOTTED  |

### ETriangleRenderFlags

Description: render flags for [AddTriangle()](/baimless-lua/doc/core/draw.md#addtriangle)

| Indentifiers            |
| ----------------------- |
| DRAW\_TRIANGLE\_NONE    |
| DRAW\_TRIANGLE\_OUTLINE |
| DRAW\_TRIANGLE\_FILLED  |

### EQuadRenderFlags

Description: render flags for [AddQuad()](/baimless-lua/doc/core/draw.md#addquad)

| Indentifiers        |
| ------------------- |
| DRAW\_QUAD\_NONE    |
| DRAW\_QUAD\_OUTLINE |
| DRAW\_QUAD\_FILLED  |

### EPolygonRenderFlags

Description: render flags for [AddPolygon()](/baimless-lua/doc/core/draw.md#addpolygon)

| Indentifiers           |
| ---------------------- |
| DRAW\_POLYGON\_NONE    |
| DRAW\_POLYGON\_OUTLINE |
| DRAW\_POLYGON\_FILLED  |

### ETextRenderFlags

Description: render flags for [AddText()](/baimless-lua/doc/core/draw.md#addtext)

⚠️ **Warning:** `DRAW_TEXT_DROPSHADOW` and `DRAW_TEXT_OUTLINE` flags cannot be used together

| Indentifiers           |
| ---------------------- |
| DRAW\_TEXT\_NONE       |
| DRAW\_TEXT\_DROPSHADOW |
| DRAW\_TEXT\_OUTLINE    |

### ERasterizerFlags

Description: rasterizer flags for [AddFont()](/baimless-lua/doc/core/draw.md#addfont)

| Indentifiers    |
| --------------- |
| NO\_HINTING     |
| NO\_AUTOHINT    |
| FORCE\_AUTOHINT |
| LIGHT\_HINTING  |
| MONO\_HINTING   |
| BOLD            |
| OBLIQUE         |
| MONOCHROME      |

## Functions

### WorldToScreen

Parameters:

| Name           | Type                                            | Description             |
| -------------- | ----------------------------------------------- | ----------------------- |
| vecWorldOrigin | [Vector](/baimless-lua/doc/datatypes/vector.md) | position in world space |

Returns:

| Type                                                | Description                                   |
| --------------------------------------------------- | --------------------------------------------- |
| [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | position of given world space in screen space |

Code:

```lua
local vecLocalOrigin = pLocal.GetOrigin()
local vecScreen = Draw.WorldToScreen(vecLocalOrigin)
```

### AddLine

Parameters:

| Name          | Type                                                | Description            |
| ------------- | --------------------------------------------------- | ---------------------- |
| vecStart      | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | start position of line |
| vecEnd        | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | end position of line   |
| colLine       | [Color](/baimless-lua/doc/datatypes/color.md)       | color of line          |
| *flThickness* | float                                               | thickness of line      |

Code:

```lua
Draw.AddLine(Vector2D.new(100.0, 100.0), Vector2D.new(200.0, 100.0), Color.new(), 2.0)
```

### AddRect

Parameters:

| Name                                                                   | Type                                                | Description                                           |
| ---------------------------------------------------------------------- | --------------------------------------------------- | ----------------------------------------------------- |
| vecMin                                                                 | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | minimal position of rect                              |
| vecMax                                                                 | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | maximal position of rect                              |
| colRect                                                                | [Color](/baimless-lua/doc/datatypes/color.md)       | color of rect                                         |
| [*uFlags*](/baimless-lua/doc/core/draw.md#erectrenderflags)            | [bitflag](https://en.wiktionary.org/wiki/bitflag)   | render flags                                          |
| *colOutline*                                                           | [Color](/baimless-lua/doc/datatypes/color.md)       | color of outline                                      |
| *flRounding*                                                           | float                                               | corners rounding value                                |
| [*roundingCorners*](/baimless-lua/doc/core/draw.md#ecornerrenderflags) | [bitflag](https://en.wiktionary.org/wiki/bitflag)   | rounding corners render flags                         |
| *flThickness*                                                          | float                                               | thickness of non-filled rect / outline of filled rect |

Code:

```lua
local bit = require("bit")
Draw.AddRect(Vector2D.new(100.0, 100.0), Vector2D.new(200.0, 200.0), Color.new(), bit.bor(ERectRenderFlags.DRAW_RECT_OUTLINE, ERectRenderFlags.DRAW_RECT_BORDER), Color.new(100, 0, 0, 255), 15.0)
```

### AddRectMultiColor

Parameters:

| Name           | Type                                                | Description                          |
| -------------- | --------------------------------------------------- | ------------------------------------ |
| vecMin         | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | minimal position of rect             |
| vecMax         | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | maximal position of rect             |
| colUpperLeft   | [Color](/baimless-lua/doc/datatypes/color.md)       | color of upper-left corner of rect   |
| colUpperRight  | [Color](/baimless-lua/doc/datatypes/color.md)       | color of upper-right corner of rect  |
| colBottomRight | [Color](/baimless-lua/doc/datatypes/color.md)       | color of bottom-right corner of rect |
| colBottomLeft  | [Color](/baimless-lua/doc/datatypes/color.md)       | color of bottom-left corner of rect  |

Code:

```lua
Draw.AddRectMultiColor(Vector2D.new(100.0, 100.0), Vector2D.new(200.0, 200.0), Color.new(0, 150, 200), Color.new(100, 150, 0), Color.new(0, 200, 0), Color.new(180, 0, 0))
```

### AddBox3D

Parameters:

| Name                                                           | Type                                              | Description                                               |
| -------------------------------------------------------------- | ------------------------------------------------- | --------------------------------------------------------- |
| vecCenter                                                      | [Vector](/baimless-lua/doc/datatypes/vector.md)   | center position of 3D box in world space                  |
| vecAbsMin                                                      | [Vector](/baimless-lua/doc/datatypes/vector.md)   | absolute minimal 3D box expansion                         |
| vecAbsMax                                                      | [Vector](/baimless-lua/doc/datatypes/vector.md)   | absolute maximal 3D box expansion                         |
| angOrientation                                                 | [QAngle](/baimless-lua/doc/datatypes/qangle.md)   | angle of 3D box rotation                                  |
| colBox                                                         | [Color](/baimless-lua/doc/datatypes/color.md)     | color of 3D box                                           |
| [*uFlags*](/baimless-lua/doc/core/draw.md#ebox-3-drenderflags) | [bitflag](https://en.wiktionary.org/wiki/bitflag) | render flags                                              |
| *colOutline*                                                   | [Color](/baimless-lua/doc/datatypes/color.md)     | color of outline                                          |
| *flThickness*                                                  | float                                             | thickness of non-filled 3D box / outline of filled 3D box |

Code:

```lua
Draw.AddBox(Vector.new(150.0, 150.0, 150.0), Vector.new(-2.0, -2.0, -2.0), Vector.new(2.0, 2.0, 2.0), QAngle.new(), Color.new(), EBox3DRenderFlags.DRAW_BOX3D_FILLED)
```

### AddCircle

Parameters:

| Name                                                          | Type                                                | Description                                               |
| ------------------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------------- |
| vecCenter                                                     | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | center position of circle                                 |
| flRadius                                                      | float                                               | radius of circle                                          |
| colCircle                                                     | [Color](/baimless-lua/doc/datatypes/color.md)       | color of circle                                           |
| nSegments                                                     | int                                                 | segments count for circle                                 |
| [*uFlags*](/baimless-lua/doc/core/draw.md#ecirclerenderflags) | [bitflag](https://en.wiktionary.org/wiki/bitflag)   | render flags                                              |
| *colOutline*                                                  | [Color](/baimless-lua/doc/datatypes/color.md)       | color of outline                                          |
| *flThickness*                                                 | float                                               | thickness of non-filled circle / outline of filled circle |

Code:

```lua
local bit = require("bit")
Draw.AddCircle(Vector2D.new(150.0, 150.0), 50.0, Color.new(), 12, bit.bor(ECircleRenderFlags.DRAW_CIRCLE_FILLED, ECircleRenderFlags.DRAW_CIRCLE_OUTLINE))
```

### AddCircle3D

Parameters:

| Name                                                              | Type                                              | Description                                                     |
| ----------------------------------------------------------------- | ------------------------------------------------- | --------------------------------------------------------------- |
| vecCenter                                                         | [Vector](/baimless-lua/doc/datatypes/vector.md)   | center position of 3D circle in world space                     |
| flRadius                                                          | float                                             | radius of 3D circle                                             |
| colCircle                                                         | [Color](/baimless-lua/doc/datatypes/color.md)     | color of 3D circle                                              |
| nSegments                                                         | int                                               | segments count for 3D circle                                    |
| [*uFlags*](/baimless-lua/doc/core/draw.md#ecircle-3-drenderflags) | [bitflag](https://en.wiktionary.org/wiki/bitflag) | render flags                                                    |
| *colOutline*                                                      | [Color](/baimless-lua/doc/datatypes/color.md)     | color of outline                                                |
| *flThickness*                                                     | float                                             | thickness of non-filled 3D circle / outline of filled 3D circle |

Code:

```lua
Draw.AddCircle3D(pLocal.GetOrigin(), 50.0, Color.new(), 36, ECircle3DRenderFlags.DRAW_CIRCLE3D_DOTTED)
```

### AddTriangle

Parameters:

| Name                                                            | Type                                                | Description                                                   |
| --------------------------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------- |
| vecFirst                                                        | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | first position of triangle                                    |
| vecSecond                                                       | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | second position of triangle                                   |
| vecThird                                                        | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | third position of triangle                                    |
| colTriangle                                                     | [Color](/baimless-lua/doc/datatypes/color.md)       | color of triangle                                             |
| [*uFlags*](/baimless-lua/doc/core/draw.md#etrianglerenderflags) | [bitflag](https://en.wiktionary.org/wiki/bitflag)   | render flags                                                  |
| *colOutline*                                                    | [Color](/baimless-lua/doc/datatypes/color.md)       | color of outline                                              |
| *flThickness*                                                   | float                                               | thickness of non-filled triangle / outline of filled triangle |

Code:

```lua
Draw.AddTriangle(Vector2D.new(150.0, 100.0), Vector2D.new(100.0, 200.0), Vector2D.new(200.0, 200.0), Color.new())
```

### AddQuad

Parameters:

| Name                                                        | Type                                                | Description                                           |
| ----------------------------------------------------------- | --------------------------------------------------- | ----------------------------------------------------- |
| vecFirst                                                    | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | first position of quad                                |
| vecSecond                                                   | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | second position of quad                               |
| vecThird                                                    | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | third position of quad                                |
| vecFourth                                                   | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | fourth position of quad                               |
| colQuad                                                     | [Color](/baimless-lua/doc/datatypes/color.md)       | color of quad                                         |
| [*uFlags*](/baimless-lua/doc/core/draw.md#equadrenderflags) | [bitflag](https://en.wiktionary.org/wiki/bitflag)   | render flags                                          |
| *colOutline*                                                | [Color](/baimless-lua/doc/datatypes/color.md)       | color of outline                                      |
| *flThickness*                                               | float                                               | thickness of non-filled quad / outline of filled quad |

Code:

```lua
Draw.AddTriangle(Vector2D.new(150.0, 100.0), Vector2D.new(100.0, 200.0), Vector2D.new(200.0, 200.0), Color.new(), EQuadRenderFlags.DRAW_QUAD_OUTLINE)
```

### AddArc

Parameters:

| Name          | Type                                                | Description                       |
| ------------- | --------------------------------------------------- | --------------------------------- |
| vecCenter     | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | center position of arc            |
| flRadius      | float                                               | radius of arc                     |
| vecAngleRange | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | minimal and maximal angles of arc |
| colArc        | [Color](/baimless-lua/doc/datatypes/color.md)       | color of arc                      |
| flThickness   | float                                               | thickness of arc                  |

Code:

```lua
Draw.AddArc(Vector2D.new(150.0, 150.0), 50.0, Vector2D.new(-45.0, 45.0), Color.new(), 2.0)
```

### AddPolygon

Parameters:

| Name                                                           | Type                                              | Description                                                      |
| -------------------------------------------------------------- | ------------------------------------------------- | ---------------------------------------------------------------- |
| vecPoints                                                      | table                                             | polygon positions                                                |
| colPolygon                                                     | [Color](/baimless-lua/doc/datatypes/color.md)     | color of polygon                                                 |
| [*uFlags*](/baimless-lua/doc/core/draw.md#epolygonrenderflags) | [bitflag](https://en.wiktionary.org/wiki/bitflag) | render flags                                                     |
| *colOutline*                                                   | [Color](/baimless-lua/doc/datatypes/color.md)     | color of outline                                                 |
| *bClosed*                                                      | bool                                              | if true after last point will be automatically added first point |
| *flThickness*                                                  | float                                             | thickness of non-filled polygon / outline of filled polygon      |

Code:

```lua
Draw.AddPolygon({ Vector2D.new(150.0, 100.0), Vector2D.new(140.0, 120.0), Vector2D.new(110.0, 140.0), Vector2D.new(140.0, 160.0), Vector2D.new(150.0, 180.0) }, Color.new(), EPolygonRenderFlags.DRAW_POLYGON_OUTLINE)
```

### AddFont

Parameters:

| Name                                                        | Type                                              | Description                     |
| ----------------------------------------------------------- | ------------------------------------------------- | ------------------------------- |
| vecPoints                                                   | string                                            | path to font file (.ttf / .otf) |
| flFontSize                                                  | float                                             | size of font in pixels          |
| [*uFlags*](/baimless-lua/doc/core/draw.md#erasterizerflags) | [bitflag](https://en.wiktionary.org/wiki/bitflag) | rasterizer flags                |

Returns:

| Type   | Description        |
| ------ | ------------------ |
| uint32 | hash of added font |

Code:

```lua
local uSeguiUI = Draw.AddFont("C:\\Windows\\Fonts\\seguiui.ttf", 20.0, ERasterizerFlags.BOLD)
```

### RemoveFont

Parameters:

| Name      | Type   | Description                       |
| --------- | ------ | --------------------------------- |
| uFontHash | uint32 | hash of font that will be removed |

Code:

```lua
Client.RegisterCallback("Destroy", function()
Draw.RemoveFont(uSeguiUI)
end)
```

### GetTextSize

Parameters:

| Name       | Type   | Description                              |
| ---------- | ------ | ---------------------------------------- |
| uFontHash  | uint32 | hash of font for will be calculated size |
| flFontSize | float  | size of font in pixels                   |
| szText     | string | text for will be calculated size         |

Returns:

| Type                                                | Description                         |
| --------------------------------------------------- | ----------------------------------- |
| [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | size for given font with given text |

Code:

```lua
local vecTextSize = Draw.GetTextSize(uSeguiUI, 20.0, "Test")
```

### AddText

Parameters:

| Name                                                        | Type                                                | Description                             |
| ----------------------------------------------------------- | --------------------------------------------------- | --------------------------------------- |
| uFontHash                                                   | uint32                                              | hash of font text will be rendered with |
| flFontSize                                                  | float                                               | size of font in pixels                  |
| vecPosition                                                 | [Vector2D](/baimless-lua/doc/datatypes/vector2d.md) | left-top corner position of text        |
| szText                                                      | string                                              | text to render by given font hash       |
| colText                                                     | [Color](/baimless-lua/doc/datatypes/color.md)       | color of text                           |
| [*uFlags*](/baimless-lua/doc/core/draw.md#etextrenderflags) | [bitflag](https://en.wiktionary.org/wiki/bitflag)   | render flags                            |
| *colOutline*                                                | [Color](/baimless-lua/doc/datatypes/color.md)       | color of outline                        |
| *flThickness*                                               | float                                               | thickness of outlined text              |

Code:

```lua
Draw.AddText(uSeguiUI, 20.0, Vector2D.new(150.0, 150.0) - vecTextSize * 0.5, Color.new(), "Test", ETextRenderFlags.DRAW_TEXT_OUTLINE)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://baimless.gitbook.io/baimless-lua/doc/core/draw.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
