Codea's built-in reference documents most of the
color() function. The function returns a userdata value that is a vector in four dimensions, used to represent red, green, blue and alpha (opacity) values.
Setting and getting individual coordinates
Indexing can be used to set and get individual co-ordinates, either by (r, g, b, a) or by ordinal number or by other letters - (x, y, z, w), as summarised in the table below:
|Co-ordinate||Index scheme||Index scheme||Index scheme|
Each co-ordinate can be set to any number value (and is not constrained, for example, to the range 0 to 255). The graphical color picking in Codea's Editor tolerates this.
From version 1.4.3 of Codea, like
vec4(), the result of the
color() function supports operators, such as the
== operator. For example:
print(color(0, 0, 0, 0) == color(0, 0, 0, 0)) -- Output is 'true' print(vec4(0, 0, 0, 0) == vec4(0, 0, 0, 0)) -- Output is 'true'
The result supports
tostring() to produce nicely-formatted output. Consequently,
print() also generates nicely-formatted output.