Linearly interpolates between two colors using the parameter t, where
t = 0 returns ‘from’ and t = 1 returns ‘to’.
local black = Color.rgb(0, 0, 0)local white = Color.rgb(255, 255, 255)local t = 0.5-- Linearly interpolate halfway between black and whitelocal gray = Color.lerp(black, white, t)print(gray)-- Returns a gray color between black and white
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(r: number, g: number, b: number, a: number) -> Color
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.
-- Red at 50% opacityself.color = Color.rgba(255, 0, 0, 128)
alpha(color: Color, value: number?) -> number | Color
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(color: Color, value: number?) -> number | Color
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.
local myColor = Color.rgba(255, 0, 0, 128)-- Get the opacity of a colorlocal myOpacity = Color.opacity(myColor)print(myOpacity)-- 0.502-- Get a new color with the specified opacitylocal newColor = Color.opacity(myColor, 1.0)print(Color.opacity(newColor))-- 1.0