Skip to content
Stjepan Bakrac edited this page May 22, 2020 · 6 revisions

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 value of a Red-Green-Blue triad with optional alpha.

Definition

function ui.color.rgb(r : number, g : number, b : number, a : number = 255) : color_value

Parameters

r number

The red channel value, from 0 to 255.

g number

The blue channel value, from 0 to 255.

b number

The green channel value, from 0 to 255.

a number [default: 255]

The alpha channel value, from 0 to 255.

Return

color color_value

The integer form of the specified color, for use in the UI library.



ui.color.hsv

Returns the integer value of a Hue-Saturation-Value triad with optional alpha.

Definition

function ui.color.hsv(h : number, s : number, v : number, a : number = 255) : color_value

Parameters

h number

The hue component, from 0 to 360.

s number

The saturation component, from 0 to 1.

v number

The value component, from 0 to 1.

a number [default: 255]

The alpha component, from 0 to 255.

Return

color color_value

The integer form of the specified color, for use in the UI library.



ui.color.torgb

Returns the RGB components of a specified color.

Definition

function ui.color.torgb(color : color_value) : number, number, number, number

Parameters

color color_value

The integer form of the specified color.

Return

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.



ui.color.tohsv

Returns the HSV components of a specified color.

Definition

function ui.color.tohsv(color : color_value) : number, number, number

Parameters

color color_value

The integer form of the specified color.

Return

h number

The hue component of the color.

s number

The saturation component of the color.

v number

The value component of the color.



ui.color.tohex

Returns the hexadecimal form of a specified color.

Definition

function ui.color.tohex(color : color_value) : string

Parameters

color color_value

The integer form of the specified color.

Return

hex string

The hexadecimal form of the color.

For example, for the ui.color.red constant: ##FF0000FF



ui.color.fade

Returns the specified color with a new alpha channel value.

Definition

function ui.color.fade(color : color_value, a : number) : color_value

Parameters

color color_value

The integer form of the original color.

a number

The alpha component, from 0 to 255.

Return

color color_value

The integer form of the specified color with the new alpha channel value.



Color Constants

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.

Special Named Colors

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.
Clone this wiki locally