color table reference - Stingray Lua API Reference

color table reference

Description

Represents a single color, created by a call to the stingray.Color() function.

This function accepts separate values for the R,G,B color channels, or for A,R,G,B if you want the color to be partially transparent.

For example, this call creates a fully opaque orange color:

local orange = stingray.Color(255, 127, 0) -- Red = 255, Green = 127, Blue = 0

Note that if you specify an alpha value, it must be first. For example, this call creates a semi-transparent yellow:

local yellow = stingray.Color(127, 255, 255, 0) -- Alpha = 127, Red = 255, Green = 255, Blue = 0

Colors are internally represented using stingray.Vector4 objects. This means that they are temporary objects that cannot be stored from one frame to another. This also means that you can use the functions defined for the stingray.Vector4 object on the resulting color.

For example, after you create a color, you can retrieve its channel values by calling stingray.Vector4.to_elements():

local mycolor = stingray.Color(255, 33, 44, 55)
local alpha, red, green, blue = stingray.Vector4.to_elements(mycolor)