# tocolor (Shared)

> Packs a colour's components into a single ARGB number. It is the same function as `rgb`.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Data and utilities
- **URL**: https://wiki.mymp.gg/en/tocolor

## Syntax

```lua
int tocolor(int red, int green, int blue [, int alpha = 255])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `red` | `int` | The red, from 0 to 255. |
| `green` | `int` | The green, from 0 to 255. |
| `blue` | `int` | The blue, from 0 to 255. |
| `alpha` | `int` | The opacity, from 0 to 255. *(default: `255`)* |

## Returns

The colour as a number. If an argument is not an integer, opaque black.

Values outside 0 to 255 are clamped.

## Example

```lua
dxDrawRectangle(10, 10, 200, 40, tocolor(0, 0, 0, 160))
```

## See also

- [rgb (Shared)](https://wiki.mymp.gg/en/rgb.md): Packs a colour's components into a single ARGB number. It is the same function as tocolor.
- [rgba (Shared)](https://wiki.mymp.gg/en/rgba.md): Packs a colour's components into a single ARGB number, with the opacity from 0 to 1.
