# rgb2num proc

Source: https://ref.dm-lang.org/proc/rgb2num

### Format
- `rgb2num(color)`
- `rgb2num(color, space)`


### Args
- `color`: A color value (see [HTML colors](https://ref.dm-lang.org/appendix/html-colors.md))
- `space`: [Color space](https://ref.dm-lang.org/appendix/color-space.md); default is `COLORSPACE_RGB`


### Returns
> A list with the components of this color

Parses a color into a list with 3 or 4 component values; the 4th value is alpha, if it's part of the color provided.

```dm /rgb2num/
var/list/RGB = rgb2num("#ff8000")
src << RGB[1]     // red (255)
src << RGB[2]     // green (128)
src << RGB[3]     // blue (0)
```

By specifying a different color space, you can convert a color into a different format.

```dm /rgb2num/
var/list/HSL = rgb2num("#5af", COLORSPACE_HSL)
src << HSL[1]     // hue (210)
src << HSL[2]     // saturation (100)
src << HSL[3]     // luminance (66.6667)
```

### See also
- [rgb proc](https://ref.dm-lang.org/proc/rgb.md)
- [gradient proc](https://ref.dm-lang.org/proc/gradient.md)
- [Color space](https://ref.dm-lang.org/appendix/color-space.md)
- [HTML colors](https://ref.dm-lang.org/appendix/html-colors.md)
