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

Example

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

Example

main
  color c = color.red
                        

(color) color.green

Return the predefined color green.

Return value

Example

main
  color c = color.green
                        

(color) color.blue

Return the predefined color blue.

Return value

Example

main
  color c = color.blue
                        

(color) color.black

Return the predefined color black.

Return value

Example

main
  color c = color.black
                        

(color) color.white

Return the predefined color white.

Return value

Example

main
  color c = color.white
                        

(color) color.cyan

Return the predefined color cyan.

Return value

Example

main
  color c = color.cyan
                        

(color) color.magenta

Return the predefined color magenta.

Return value

Example

main
  color c = color.magenta
                        

(color) color.yellow

Return the predefined color yellow.

Return value

Example

main
  color c = color.yellow
                        

(color) color.grey

Return the predefined color grey.

Return value

Example

main
  color c = color.grey
                        

(color) color.brown

Return the predefined color brown.

Return value

Example

main
  color c = color.brown
                        

(color) color.orange

Return the predefined color orange.

Return value

Example

main
  color c = color.orange
                        

(color) <color source>.copy

Creates a new color that is an exact copy of source.

Parameters

Example

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

Exceptions

Example

main
  color c = rgb 255, 255, 255 alpha 0
                        

(bool) <color c1> == <color c2>

Comparision

Parameters

Return value

Example

main
  color c1 = rgb 255, 255, 255
  color c2 = rgb 0, 0, 0
  bool result = c1 == c2    // result == false
                        

(bool) <color c1> != <color c2>

Comparision

Parameters

Return value

Example

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

Example

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

Example

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

Example

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

Example

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

Exceptions

Example

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

Exceptions

Example

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

Exceptions

Example

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

Exceptions

Example

main
  color c = rgb 255, 128, 0
  c.set alpha to 0                // c == 255, 128, 0, 0