A color object native to TouchOSC. Will be returned and can be passed anywhere a color is required. Color components
are stored as floating point values ranging from 0.0 to 1.0.
color.r
The red component of the color.
color.g
The green component of the color.
color.b
The blue component of the color.
color.a
The alpha component of the color.
function Color() -- [1]
function Color(color) -- [2]
function Color(number) -- [3]
function Color(number, number) -- [4]
function Color(number, number, number) -- [5]
function Color(number, number, number, number) -- [6]
Returns a new color object with
0.0.Color object.rgb components initialized with the first number, the a component initialized with the
second number.
rgb components initialized with the three numbers, the a component initialized with
1.0rgba components initialized with the four numbers provided.
function Color.toHexString(color)
-- example
local redColor = Color(1,0,0)
print(Color.toHexString(redColor))
> FF0000FF
Returns a hexadecimal string representation of the color in the format RRGGBBAA.
function Color.fromHexString(string)
-- example
local red = Color.fromHexString('FF0000FF')
local blue = cColor.fromHexString('0000FF')
local grayAlpha = Color.fromHexString('FF80');
local gray = Color.fromHexString('80');
Returns a color object created from the hexadecimal string representation. The string can be in one of the following
formats: RRGGBBAA, RRGGBB, GGAA, GG, with the latter two forms
creating a grayscale color from the GG value.
-- multiplication
color * color
color * number
-- division
color / color
color / number
-- addition
color + color
color + number
-- subtraction
color - color
color - number
All operators operate component-wise and return a new color object.
We use cookies to deliver website content. By continuing without changing your preferences, you agree to our use of cookies.