-
Notifications
You must be signed in to change notification settings - Fork 20
ui.color
Widgets and text formatting in the Windower UI library use colors encoded as integers (color_value
). This table contains color-related helper functions and color constants to ease the process of working with them.
The ui.color
table contains the following entries:
- ui.color.rgb : Returns the integer color_value of an RGB triad with optional alpha.
- ui.color.hsv : Returns the integer color_value of an HSV triad with optional alpha.
- ui.color.torgb : Returns the RGB components of a specified color.
- ui.color.tohex : Returns the hexadecimal form of a specified color.
- ui.color.tohsv : Returns the HSV components of a specified color.
- ui.color.fade : Returns the specified color with a new alpha channel value.
- ui.color.<constants> : Named color constants.
Returns the integer value of a Red-Green-Blue triad with optional alpha.
function ui.color.rgb(r : number, g : number, b : number, a : number = 255) : color_value
r number
The red channel value, from
0
to255
.
g number
The blue channel value, from
0
to255
.
b number
The green channel value, from
0
to255
.
a number [default: 255
]
The alpha channel value, from
0
to255
.
color color_value
The integer form of the specified color, for use in the UI library.
Returns the integer value of a Hue-Saturation-Value triad with optional alpha.
function ui.color.hsv(h : number, s : number, v : number, a : number = 255) : color_value
h number
The hue component, from
0
to360
.
s number
The saturation component, from
0
to1
.
v number
The value component, from
0
to1
.
a number [default: 255
]
The alpha component, from
0
to255
.
color color_value
The integer form of the specified color, for use in the UI library.
Returns the RGB components of a specified color.
function ui.color.torgb(color : color_value) : number, number, number, number
color color_value
The integer form of the specified color.
r number
The red channel value of the color.
g number
The blue channel value of the color.
b number
The green channel value of the color.
a number
The alpha channel value of the color.
Returns the HSV components of a specified color.
function ui.color.tohsv(color : color_value) : number, number, number
color color_value
The integer form of the specified color.
h number
The hue component of the color.
s number
The saturation component of the color.
v number
The value component of the color.
Returns the hexadecimal form of a specified color.
function ui.color.tohex(color : color_value) : string
color color_value
The integer form of the specified color.
hex string
The hexadecimal form of the color.
For example, for the
ui.color.red
constant:##FF0000FF
Returns the specified color with a new alpha channel value.
function ui.color.fade(color : color_value, a : number) : color_value
color color_value
The integer form of the original color.
a number
The alpha component, from
0
to255
.
color color_value
The integer form of the specified color with the new alpha channel value.
The ui.color
table also contains a large number of named color values. For example, ui.color.red
.
For a complete list of supported named colors, see the CSS Color Keywords.
In addition to the standard CSS named colors, the ui.color
table contains several special named colors:
- ui.color.accent : A pre-defined accent color tied to the Windower build type.
- ui.color.transparent : An entirely transparent color.