Data Color
scripts/vscripts/alyxlib/data/color.lua
Methods
ToHexString
Converts this Color to a hexadecimal representation.
The hexadecimal string is in the format #RRGGBB.
Returns
- string
The hexadecimal representation of this Color
ToVector
Returns a Vector from this Color. In the form of [x=r, y=g, z=b], with ranges [0-255].
Returns
- Vector
The vector representation of this Color
ToDecimalVector
Returns a Vector from this Color. In the form of [x=r, y=g, z=b], with ranges [0-1].
Returns
- Vector
The decimal vector representation of this Color
SetRGB
Sets the RGBA components of this Color.
If any of the provided values have fractional parts, they will all be normalized to the range [0, 255]. If any of the provided values are nil or omitted, the corresponding component of the color will remain unchanged.
Parameters
r(optional)
number
The red component of the colorg(optional)
number
The green component of the colorb(optional)
number
The blue component of the colora(optional)
number
The alpha component of the color
GetHSL
Gets the HSL color values for this Color.
Returns
-
number
h
Hue color value in range [0-360] -
number
s
Saturation color value in range [0-100] -
number
l
Lightness color value in range [0-100]
SetHSL
Sets the HSL (Hue, Saturation, Lightness) components of this Color.
If any of the provided values have fractional parts, they will be normalized to their appropriate ranges (0 to 360 for hue, 0 to 100 for saturation and lightness). If any of the provided values are nil or omitted, the corresponding component of the color will remain unchanged.
Parameters
h(optional)
number
The hue value of the color (0 to 360), representing the color's position on the color wheels(optional)
number
The saturation value of the color (0 to 100), determining the intensity of the colorl(optional)
number
The lightness value of the color (0 to 100), affecting the brightness of the color
Functions
Color
Creates a new Color instance using range [0-255] or [0-1].
Parameters
r(optional)
number
Red color valueg(optional)
number
Green color valueb(optional)
number
Blue color valuea(optional)
number
Alpha value
Returns
- Color
The new Color
IsColor
Checks if a value is a Color.
Parameters
value
any
The value to check
Returns
- boolean
true if the value is a Color, false otherwise
Types
Color
Represents a color object with RGB and HSL components.
| Field | Type | Description |
|---|---|---|
| r | integer |
Red component |
| g | integer |
Green component |
| b | integer |
Blue component |
| a | integer |
Alpha component |
| hue | integer |
Hue component |
| saturation | integer |
Saturation component |
| lightness | integer |
Lightness component |