Color
Inherits from: Paint > Interpolatable
Overview
The Color class is used to encapsulate colors in the default sRGB color space. Every color has an implicit alpha value of 1.0 or an explicit one provided in the constructor. The alpha value defines the transparency of a color and can be represented by a float value in the range 0.0-1.0 or 0-255. An alpha value of 1.0 or 255 means that the color is completely opaque and an alpha value of 0 or 0.0 means that the color is completely transparent. When constructing a Color with an explicit alpha or getting the color/alpha components of a Color, the color components are never premultiplied by the alpha component.
Colors can be created with the constructor or with one of several utility methods. The following lines of code all create the same blue color:
var c = Color.BLUE; //use the blue constant var c = Color { red: 0 green: 0 blue: 1.0 }; // standard constructor var c = Color.color(0,0,1.0); //use 0->1.0 values. implicit alpha of 1.0 var c = Color.color(0,0,1.0,1.0); //use 0->1.0 values, explicit alpha of 1.0 var c = Color.rgb(0,0,255); //use 0->255 integers, implict alpha of 1.0 var c = Color.rgb(0,0,255,1.0); //use 0->255 integers, explict alpha of 1.0 var c = Color.hsb(270,1.0,1.0); //hue = 270, saturation & value = 1.0. inplict alpha of 1.0 var c = Color.hsb(270,1.0,1.0,1.0); //hue = 270, saturation & value = 1.0, explict alpha of 1.0 var c = Color.web("0x0000FF",1.0);// blue as a hex web value, explict alpha var c = Color.web("0x0000FF");// blue as a hex web value, implict alpha var c = Color.web("#0000FF",1.0);// blue as a hex web value, explict alpha var c = Color.web("#0000FF");// blue as a hex web value, implict alpha var c = Color.web("0000FF",1.0);// blue as a hex web value, explict alpha var c = Color.web("0000FF");// blue as a hex web value, implict alpha
The creation of a Color will throw IllegalArgumentException if any of the values are out of range.
Profile: common
Constants Summary
| name | type | description |
|---|---|---|
| TRANSPARENT | Color |
A fully transparent color. |
| ALICEBLUE | Color |
|
| ANTIQUEWHITE | Color |
|
| AQUA | Color |
|
| AQUAMARINE | Color |
|
| AZURE | Color |
|
| BEIGE | Color |
|
| BISQUE | Color |
|
| BLACK | Color |
|
| BLANCHEDALMOND | Color |
|
| BLUE | Color |
|
| BLUEVIOLET | Color |
|
| BROWN | Color |
|
| BURLYWOOD | Color |
|
| CADETBLUE | Color |
|
| CHARTREUSE | Color |
|
| CHOCOLATE | Color |
|
| CORAL | Color |
|
| CORNFLOWERBLUE | Color |
|
| CORNSILK | Color |
|
| CRIMSON | Color |
|
| CYAN | Color |
|
| DARKBLUE | Color |
|
| DARKCYAN | Color |
|
| DARKGOLDENROD | Color |
|
| DARKGRAY | Color |
|
| DARKGREEN | Color |
|
| DARKGREY | Color |
|
| DARKKHAKI | Color |
|
| DARKMAGENTA | Color |
|
| DARKOLIVEGREEN | Color |
|
| DARKORANGE | Color |
|
| DARKORCHID | Color |
|
| DARKRED | Color |
|
| DARKSALMON | Color |
|
| DARKSEAGREEN | Color |
|
| DARKSLATEBLUE | Color |
|
| DARKSLATEGRAY | Color |
|
| DARKSLATEGREY | Color |
|
| DARKTURQUOISE | Color |
|
| DARKVIOLET | Color |
|
| DEEPPINK | Color |
|
| DEEPSKYBLUE | Color |
|
| DIMGRAY | Color |
|
| DIMGREY | Color |
|
| DODGERBLUE | Color |
|
| FIREBRICK | Color |
|
| FLORALWHITE | Color |
|
| FORESTGREEN | Color |
|
| FUCHSIA | Color |
|
| GAINSBORO | Color |
|
| GHOSTWHITE | Color |
|
| GOLD | Color |
|
| GOLDENROD | Color |
|
| GRAY | Color |
|
| GREEN | Color |
|
| GREENYELLOW | Color |
|
| GREY | Color |
|
| HONEYDEW | Color |
|
| HOTPINK | Color |
|
| INDIANRED | Color |
|
| INDIGO | Color |
|
| IVORY | Color |
|
| KHAKI | Color |
|
| LAVENDER | Color |
|
| LAVENDERBLUSH | Color |
|
| LAWNGREEN | Color |
|
| LEMONCHIFFON | Color |
|
| LIGHTBLUE | Color |
|
| LIGHTCORAL | Color |
|
| LIGHTCYAN | Color |
|
| LIGHTGOLDENRODYELLOW | Color |
|
| LIGHTGRAY | Color |
|
| LIGHTGREEN | Color |
|
| LIGHTGREY | Color |
|
| LIGHTPINK | Color |
|
| LIGHTSALMON | Color |
|
| LIGHTSEAGREEN | Color |
|
| LIGHTSKYBLUE | Color |
|
| LIGHTSLATEGRAY | Color |
|
| LIGHTSLATEGREY | Color |
|
| LIGHTSTEELBLUE | Color |
|
| LIGHTYELLOW | Color |
|
| LIME | Color |
|
| LIMEGREEN | Color |
|
| LINEN | Color |
|
| MAGENTA | Color |
|
| MAROON | Color |
|
| MEDIUMAQUAMARINE | Color |
|
| MEDIUMBLUE | Color |
|
| MEDIUMORCHID | Color |
|
| MEDIUMPURPLE | Color |
|
| MEDIUMSEAGREEN | Color |
|
| MEDIUMSLATEBLUE | Color |
|
| MEDIUMSPRINGGREEN | Color |
|
| MEDIUMTURQUOISE | Color |
|
| MEDIUMVIOLETRED | Color |
|
| MIDNIGHTBLUE | Color |
|
| MINTCREAM | Color |
|
| MISTYROSE | Color |
|
| MOCCASIN | Color |
|
| NAVAJOWHITE | Color |
|
| NAVY | Color |
|
| OLDLACE | Color |
|
| OLIVE | Color |
|
| OLIVEDRAB | Color |
|
| ORANGE | Color |
|
| ORANGERED | Color |
|
| ORCHID | Color |
|
| PALEGOLDENROD | Color |
|
| PALEGREEN | Color |
|
| PALETURQUOISE | Color |
|
| PALEVIOLETRED | Color |
|
| PAPAYAWHIP | Color |
|
| PEACHPUFF | Color |
|
| PERU | Color |
|
| PINK | Color |
|
| PLUM | Color |
|
| POWDERBLUE | Color |
|
| PURPLE | Color |
|
| RED | Color |
|
| ROSYBROWN | Color |
|
| ROYALBLUE | Color |
|
| SADDLEBROWN | Color |
|
| SALMON | Color |
|
| SANDYBROWN | Color |
|
| SEAGREEN | Color |
|
| SEASHELL | Color |
|
| SIENNA | Color |
|
| SILVER | Color |
|
| SKYBLUE | Color |
|
| SLATEBLUE | Color |
|
| SLATEGRAY | Color |
|
| SLATEGREY | Color |
|
| SNOW | Color |
|
| SPRINGGREEN | Color |
|
| STEELBLUE | Color |
|
| TAN | Color |
|
| TEAL | Color |
|
| THISTLE | Color |
|
| TOMATO | Color |
|
| TURQUOISE | Color |
|
| VIOLET | Color |
|
| WHEAT | Color |
|
| WHITE | Color |
|
| WHITESMOKE | Color |
|
| YELLOW | Color |
|
| YELLOWGREEN | Color |
|
Variable Summary
| name | type | Default Value | description |
|---|---|---|---|
| red | Number | 0.0 |
The red component of the |
| green | Number | 0.0 |
The green component of the |
| blue | Number | 0.0 |
The blue component of the |
| opacity | Number | 1.0 |
The opacity of the |
Inherited Variables
Function Summary
-
- color( red: Number green: Number blue: Number opacity: Number ) : Color
-
Creates an sRGB color with the specified red, green and blue values in the range
link0.0-1.0, and a given opacity.Creates an sRGB color with the specified red, green and blue values in the range
0.0-1.0, and a given opacity.- Parameters
- red
-
- green
-
- blue
-
- opacity
-
Profile: common
-
-
- color( red: Number green: Number blue: Number ) : Color
-
Creates an opaque sRGB color with the specified red, green and blue values in the range
link0.0-1.0.Creates an opaque sRGB color with the specified red, green and blue values in the range
0.0-1.0.- Parameters
- red
-
- green
-
- blue
-
Profile: common
-
-
- rgb( red: Integer green: Integer blue: Integer opacity: Number ) : Color
-
Creates an sRGB color with the specified RGB values in the range
link0-255, and a given opacity.Creates an sRGB color with the specified RGB values in the range
0-255, and a given opacity.- Parameters
- red
-
- green
-
- blue
-
- opacity
-
Profile: common
-
-
- rgb( red: Integer green: Integer blue: Integer ) : Color
-
Creates an opaque sRGB color with the specified RGB values in the range
link0-255.Creates an opaque sRGB color with the specified RGB values in the range
0-255.- Parameters
- red
-
- green
-
- blue
-
Profile: common
-
-
- hsb( hue: Integer saturation: Number brightness: Number opacity: Number ) : Color
-
Creates a
linkColorbased on the specified values in the HSB color model, and a given opacity.Creates a
Colorbased on the specified values in the HSB color model, and a given opacity.- Parameters
- hue
-
- saturation
-
- brightness
-
- opacity
-
Profile: common
-
-
-
-
