color
Make and change colours. Every colour in the API is one packed integer.
A colour is a whole number that holds red, green, blue and alpha (0 to 255 each). Make one with color(r, g, b, a) and pass it to any draw, ui or menu function. Store it in a variable once instead of building it every frame.
color is both a function and a table: color(255, 0, 0) and color.rgba(255, 0, 0) do the same thing.
| Function | What it does |
|---|---|
color(r, g, b[, a]) | Packs four channels into one colour. Values outside 0 to 255 are clamped. |
color.rgba(r, g, b[, a]) | Same as color(r, g, b, a). |
color.unpack(c) | Splits a colour back into its channels. |
color.alpha(c, a) | Returns the same colour with a new alpha. The best way to fade something in or out. |
color.lerp(a, b, t) | Mixes two colours. t = 0 gives a, t = 1 gives b. Keep t between 0 and 1. |
color.hsv(h, s, v[, a]) | Makes a colour from hue, saturation and value. Handy for rainbow effects. |
#color
color(r, g, b[, a])Packs four channels into one colour. Values outside 0 to 255 are clamped.
Arguments
rintegergintegerbintegeraintegeroptionalReturns
local red = color(255, 70, 70)
local glass = color(12, 14, 18, 200)#color.rgba
color.rgba(r, g, b[, a])Same as color(r, g, b, a).
Returns
#color.unpack
color.unpack(c)Splits a colour back into its channels.
Arguments
cintegerReturns
local r, g, b, a = color.unpack(ui.get("col"))#color.alpha
color.alpha(c, a)Returns the same colour with a new alpha. The best way to fade something in or out.
Arguments
cintegeranumberReturns
draw.text(20, 20, "Hi", color.alpha(white, 255 * fade))#color.lerp
color.lerp(a, b, t)Mixes two colours. t = 0 gives a, t = 1 gives b. Keep t between 0 and 1.
Arguments
aintegerbintegertnumberReturns
local hp_col = color.lerp(color(255, 60, 60), color(80, 230, 120), p.health / 100)#color.hsv
color.hsv(h, s, v[, a])Makes a colour from hue, saturation and value. Handy for rainbow effects.
Arguments
hnumbersnumbervnumberaintegeroptionalReturns
local rainbow = color.hsv(globals.time() * 90, 0.7, 1)