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’.
self.color = Color.lerp(color1, color2, t)

rgb

Returns a color constructed from red, green, and blue channels. Alpha defaults to 255 (fully opaque). Channel values are clamped to [0, 255].
-- Red
self.color = Color.rgb(255, 0, 0)

rgba

Returns a color constructed from red, green, blue, and alpha channels. Channel values are clamped to [0, 255].
-- Red at 50% opacity
self.color = Color.rgba(255, 0, 0, 128)

Static Functions

red

Returns the red channel of the color. If a value is provided, returns a new color with that channel updated.
print("Red:", Color.red(myColor))

green

Returns the green channel of the color. If a value is provided, returns a new color with that channel updated.
print("Green:", Color.green(myColor))

blue

Returns the blue channel of the color. If a value is provided, returns a new color with that channel updated.
print("Blue:", Color.blue(myColor))

alpha

Returns the alpha channel of the color, or returns a new color with the alpha channel set to the specified value. Values are clamped to [0, 255].
print("Alpha:", Color.alpha(myColor))

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.
print("Opacity:", Color.opacity(myColor))