Skip to main content

Constructors

lerp

Linearly interpolates between two colors using the parameter t, where t = 0 returns ‘from’ and t = 1 returns ‘to’.

rgb

Returns a color constructed from red, green, and blue channels. Alpha defaults to 255 (fully opaque). Only the low 8 bits of each channel are kept, so 300 becomes 44 and -1 becomes 255.

rgba

Returns a color constructed from red, green, blue, and alpha channels. Only the low 8 bits of each channel are kept, so 300 becomes 44 and -1 becomes 255.

Static Functions

red

Returns the red channel of the color. If a value is provided, returns a new color with that channel updated.

green

Returns the green channel of the color. If a value is provided, returns a new color with that channel updated.

blue

Returns the blue channel of the color. If a value is provided, returns a new color with that channel updated.

alpha

Returns the alpha channel of the color, or returns a new color with the alpha channel set to the specified value. Only the low 8 bits of the value are kept.

opacity

Returns the opacity of the color as a normalized value in the range [0.0, 1.0], or returns a new color with its alpha set from the specified opacity.

toFloat

Convert a Color (ARGB packed integer) to an {r, g, b, a} table with values in 0–1 range. Use with clearColor in render passes.