Docs / API reference / color
color
Build, split, blend and fade colours.
since 1.0 no permission needed
A colour is an integer 0xRRGGBBAA (red, green, blue, alpha, one byte each), so 0xFF0000FF is opaque red and 0xFFFFFF80 is half-transparent white. Every function that takes a colour also accepts a table {r, g, b, a} with 0-255 values. See colours .
Reference# color.rgba# since 1.0 color .rgba (r: integer, g: integer, b: integer, a?: integer): integerBuilds a colour from channels.
Parameter Type Description rintegerRed, 0-255. gintegerGreen, 0-255. bintegerBlue, 0-255. a optional integerAlpha, 0-255. default 255
Returns Description integerThe colour.
lua Copy
local red = color .rgba (255 , 0 , 0 )color.hsv# since 1.0 color .hsv (h: number, s: number, v: number, a?: integer): integerBuilds a colour from hue, saturation and value. Animate the hue for a rainbow.
Parameter Type Description hnumberHue, 0 to 1. snumberSaturation, 0 to 1. vnumberValue, 0 to 1. a optional integerAlpha, 0-255. default 255
Returns Description integerThe colour.
lua Copy
local c = color .hsv ((time .now () * 0.2 ) % 1 , 0.8 , 1 )color.hex# since 1.0 color .hex (hex: string): integerParses a web colour string.
Parameter Type Description hexstring"#rrggbb" or "#rrggbbaa".
Returns Description integerThe colour.
color.split# since 1.0 color .split (c: integer): integer, integer, integer, integerParameter Type Description cintegerA colour.
Returns Description integerRed. integerGreen. integerBlue. integerAlpha.
color.lerp# since 1.0 color .lerp (a: integer, b: integer, t: number): integerParameter Type Description aintegerStart colour. bintegerEnd colour. tnumberProgress 0..1.
Returns Description integerThe blend.
color.alpha# since 1.0 color .alpha (c: integer, alpha: number): integerChanges only the opacity of a colour.
Parameter Type Description cintegerA colour. alphanumberNew opacity from 0 to 1.
Returns Description integerThe colour with that alpha.
lua Copy
draw .rect (10 , 10 , 100 , 20 , color .alpha (0xFFFFFFFF , 0.25 ))
API 1.1 · source docs-src/api/color.json