Class Color
This class represents an RGBA color. It consists of red, green, blue and alpha components.
The values of these components are between 0 and 255.
The alpha component is the transparency of the color. Alpha value 0 means fully transparent and 255 is
fully opaque. Default color is fully opaque black.
CONSTANTS
CONSTRUCTION
COMPARISION
OTHER METHODS
main
// Create new colors using constructors
color c1 = rgb 255, 0, 0 // Fully opaque red
color c2 = rgb 255, 255, 255 alpha 128 // Semi-transparent white color
color c3 = rgb 0, 0, 255 alpha 0 // Transparent blue
// You can use the color constants too
color c4 = color.magenta
if c1 == color.red
print "Yes" // LOG: Yes
// The default color is fully opaque black
color c5
if c5 == color.black
print "Yes" // LOG: Yes
(color) color.red
Return the predefined color red.
Return value
(color) color.green
Return the predefined color green.
Return value
main
color c = color.green
(color) color.blue
Return the predefined color blue.
Return value
main
color c = color.blue
(color) color.black
Return the predefined color black.
Return value
main
color c = color.black
(color) color.white
Return the predefined color white.
Return value
main
color c = color.white
(color) color.cyan
Return the predefined color cyan.
Return value
main
color c = color.cyan
(color) color.magenta
Return the predefined color magenta.
Return value
main
color c = color.magenta
(color) color.yellow
Return the predefined color yellow.
Return value
main
color c = color.yellow
(color) color.grey
Return the predefined color grey.
Return value
main
color c = color.grey
(color) color.brown
Return the predefined color brown.
Return value
main
color c = color.brown
(color) color.orange
Return the predefined color orange.
Return value
main
color c = color.orange
Creates a new color that is an exact copy of source.
Parameters
- source - The color that will be copied.
main
color c1 = rgb 255, 255, 255
color c2 = c1.copy // c2 == white
(color) rgb <int red>, <int green>, <int blue> [alpha <int alpha = 255>]
Creates a new color with the given color components. Default alpha is 255.
Parameters
- red - The red component
- green - The green component
- blue - The blue component
- alpha - The alpha component
Exceptions
- InvalidArgumentException - If any parameter has a value that is less than 0 or more than 255.
main
color c = rgb 255, 255, 255 alpha 0
Comparision
Parameters
- c1 - Operand
- c2 - Operand
Return value
- true, if operands are equal, otherwise false.
main
color c1 = rgb 255, 255, 255
color c2 = rgb 0, 0, 0
bool result = c1 == c2 // result == false
Comparision
Parameters
- c1 - Operand
- c2 - Operand
Return value
- true, if operands are not equal, otherwise false.
main
color c1 = rgb 255, 255, 255
color c2 = rgb 0, 0, 0
bool result = c1 != c2 // result == true
(int) <color this>.get red
Get the value of the red component.
Parameters
Return value
main
color c = rgb 255, 128, 0
int red = c.get red // red == 255
(int) <color this>.get green
Get the value of the green component.
Parameters
Return value
main
color c = rgb 255, 128, 0
int green = c.get green // green == 128
(int) <color this>.get blue
Get the value of the blue component.
Parameters
Return value
main
color c = rgb 255, 128, 0
int blue = c.get blue // blue == 0
(int) <color this>.get alpha
Get the value of the alpha component.
Parameters
Return value
main
color c = rgb 255, 128, 0
int alpha = c.get alpha // alpha == 255
<color this>.set red to <int v>
Assing a new value for the red component.
Parameters
- this - This
- v - New value
Exceptions
- InvalidArgumentException - If the new value is less than 0 or more than 255.
main
color c = rgb 255, 128, 0
c.set red to 0 // c == 0, 128, 0, 255
<color this>.set green to <int v>
Assing a new value for the green component.
Parameters
- this - This
- v - New value
Exceptions
- InvalidArgumentException - If the new value is less than 0 or more than 255.
main
color c = rgb 255, 128, 0
c.set green to 0 // c == 255, 0, 0, 255
<color this>.set blue to <int v>
Assing a new value for the blue component.
Parameters
- this - This
- v - New value
Exceptions
- InvalidArgumentException - If the new value is less than 0 or more than 255.
main
color c = rgb 255, 128, 0
c.set blue to 255 // c == 255, 128, 255, 255
<color this>.set alpha to <int v>
Assing a new value for the alpha component.
Parameters
- this - This
- v - New value
Exceptions
- InvalidArgumentException - If the new value is less than 0 or more than 255.
main
color c = rgb 255, 128, 0
c.set alpha to 0 // c == 255, 128, 0, 0