Overview
NOTE: this definition, while correct, contains a lot of information which is irrelevant to most developers. We should get to the basic definition and usage patterns sooner.
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.
Color
s can be created with the constructor or with one of several
static 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
//NOTE, shouldn't Color.rgb use 0->255 for the alpha?
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
var c = Color.fromAWTColor(java.awt.Color.BLUE }; //convert from an AWT color
Note. Once created the attributes of a color should never be modified.
Profile: common
This comment needs review.
Attribute Summary
name | type | description |
---|---|---|
Public | ||
ALICEBLUE | Color | More: [+] |
ANTIQUEWHITE | Color | More: [+] |
AQUA | Color | More: [+] |
AQUAMARINE | Color | More: [+] |
AZURE | Color | More: [+] |
BEIGE | Color | More: [+] |
BISQUE | Color | More: [+] |
BLACK | Color | More: [+] |
BLANCHEDALMOND | Color | More: [+] |
blue | Number |
Defines the color blue in the default sRGB space. More: [+]Defines the color blue in the default sRGB space. This attribute should not be modifed once set in the constructor. Note: this attribute can only be set once. Any changes after the constructor is called will be ignored. Profile: common This comment needs review. |
BLUE | Color | More: [+] |
BLUEVIOLET | Color | More: [+] |
BROWN | Color | More: [+] |
BURLYWOOD | Color | More: [+] |
CADETBLUE | Color | More: [+] |
CHARTREUSE | Color | More: [+] |
CHOCOLATE | Color | More: [+] |
CORAL | Color | More: [+] |
CORNFLOWERBLUE | Color | More: [+] |
CORNSILK | Color | More: [+] |
CRIMSON | Color | More: [+] |
CYAN | Color | More: [+] |
DARKBLUE | Color | More: [+] |
DARKCYAN | Color | More: [+] |
DARKGOLDENROD | Color | More: [+] |
DARKGRAY | Color | More: [+] |
DARKGREEN | Color | More: [+] |
DARKGREY | Color | More: [+] |
DARKKHAKI | Color | More: [+] |
DARKMAGENTA | Color | More: [+] |
DARKOLIVEGREEN | Color | More: [+] |
DARKORANGE | Color | More: [+] |
DARKORCHID | Color | More: [+] |
DARKRED | Color | More: [+] |
DARKSALMON | Color | More: [+] |
DARKSEAGREEN | Color | More: [+] |
DARKSLATEBLUE | Color | More: [+] |
DARKSLATEGRAY | Color | More: [+] |
DARKSLATEGREY | Color | More: [+] |
DARKTURQUOISE | Color | More: [+] |
DARKVIOLET | Color | More: [+] |
DEEPPINK | Color | More: [+] |
DEEPSKYBLUE | Color | More: [+] |
DIMGRAY | Color | More: [+] |
DIMGREY | Color | More: [+] |
DODGERBLUE | Color | More: [+] |
FIREBRICK | Color | More: [+] |
FLORALWHITE | Color | More: [+] |
FORESTGREEN | Color | More: [+] |
FUCHSIA | Color | More: [+] |
GAINSBORO | Color | More: [+] |
GHOSTWHITE | Color | More: [+] |
GOLD | Color | More: [+] |
GOLDENROD | Color | More: [+] |
GRAY | Color | More: [+] |
green | Number |
Defines the color green in the default sRGB space. More: [+]Defines the color green in the default sRGB space. This attribute should not be modifed once set in the constructor. Note: this attribute can only be set once. Any changes after the constructor is called will be ignored. Profile: common This comment needs review. |
GREEN | Color | More: [+] |
GREENYELLOW | Color | More: [+] |
GREY | Color | More: [+] |
HONEYDEW | Color | More: [+] |
HOTPINK | Color | More: [+] |
INDIANRED | Color | More: [+] |
INDIGO | Color | More: [+] |
IVORY | Color | More: [+] |
KHAKI | Color | More: [+] |
LAVENDER | Color | More: [+] |
LAVENDERBLUSH | Color | More: [+] |
LAWNGREEN | Color | More: [+] |
LEMONCHIFFON | Color | More: [+] |
LIGHTBLUE | Color | More: [+] |
LIGHTCORAL | Color | More: [+] |
LIGHTCYAN | Color | More: [+] |
LIGHTGOLDENRODYELLOW | Color | More: [+] |
LIGHTGRAY | Color | More: [+] |
LIGHTGREEN | Color | More: [+] |
LIGHTGREY | Color | More: [+] |
LIGHTPINK | Color | More: [+] |
LIGHTSALMON | Color | More: [+] |
LIGHTSEAGREEN | Color | More: [+] |
LIGHTSKYBLUE | Color | More: [+] |
LIGHTSLATEGRAY | Color | More: [+] |
LIGHTSLATEGREY | Color | More: [+] |
LIGHTSTEELBLUE | Color | More: [+] |
LIGHTYELLOW | Color | More: [+] |
LIME | Color | More: [+] |
LIMEGREEN | Color | More: [+] |
LINEN | Color | More: [+] |
MAGENTA | Color | More: [+] |
MAROON | Color | More: [+] |
MEDIUMAQUAMARINE | Color | More: [+] |
MEDIUMBLUE | Color | More: [+] |
MEDIUMORCHID | Color | More: [+] |
MEDIUMPURPLE | Color | More: [+] |
MEDIUMSEAGREEN | Color | More: [+] |
MEDIUMSLATEBLUE | Color | More: [+] |
MEDIUMSPRINGGREEN | Color | More: [+] |
MEDIUMTURQUOISE | Color | More: [+] |
MEDIUMVIOLETRED | Color | More: [+] |
MIDNIGHTBLUE | Color | More: [+] |
MINTCREAM | Color | More: [+] |
MISTYROSE | Color | More: [+] |
MOCCASIN | Color | More: [+] |
NAVAJOWHITE | Color | More: [+] |
NAVY | Color | More: [+] |
OLDLACE | Color | More: [+] |
OLIVE | Color | More: [+] |
OLIVEDRAB | Color | More: [+] |
opacity | Number |
Defines the opacity for this color. More: [+]Defines the opacity for this color. The default value is 1.0. This attribute should not be modifed once set in the constructor. Note: this attribute can only be set once. Any changes after the constructor is called will be ignored. Profile: common This comment needs review. |
ORANGE | Color | More: [+] |
ORANGERED | Color | More: [+] |
ORCHID | Color | More: [+] |
PALEGOLDENROD | Color | More: [+] |
PALEGREEN | Color | More: [+] |
PALETURQUOISE | Color | More: [+] |
PALEVIOLETRED | Color | More: [+] |
PAPAYAWHIP | Color | More: [+] |
PEACHPUFF | Color | More: [+] |
PERU | Color | More: [+] |
PINK | Color | More: [+] |
PLUM | Color | More: [+] |
POWDERBLUE | Color | More: [+] |
PURPLE | Color | More: [+] |
red | Number |
Defines the color red in the default sRGB space. More: [+]Defines the color red in the default sRGB space. This attribute should not be modifed once set in the constructor. Note: this attribute can only be set once. Any changes after the constructor is called will be ignored. Profile: common This comment needs review. |
RED | Color | More: [+] |
ROSYBROWN | Color | More: [+] |
ROYALBLUE | Color | More: [+] |
SADDLEBROWN | Color | More: [+] |
SALMON | Color | More: [+] |
SANDYBROWN | Color | More: [+] |
SEAGREEN | Color | More: [+] |
SEASHELL | Color | More: [+] |
SIENNA | Color | More: [+] |
SILVER | Color | More: [+] |
SKYBLUE | Color | More: [+] |
SLATEBLUE | Color | More: [+] |
SLATEGRAY | Color | More: [+] |
SLATEGREY | Color | More: [+] |
SNOW | Color | More: [+] |
SPRINGGREEN | Color | More: [+] |
STEELBLUE | Color | More: [+] |
TAN | Color | More: [+] |
TEAL | Color | More: [+] |
THISTLE | Color | More: [+] |
TOMATO | Color | More: [+] |
TRANSPARENT | Color |
Predefined Predefined Profile: common |
TURQUOISE | Color | More: [+] |
VIOLET | Color | More: [+] |
WHEAT | Color | More: [+] |
WHITE | Color | More: [+] |
WHITESMOKE | Color | More: [+] |
YELLOW | Color | More: [+] |
YELLOWGREEN | Color | More: [+] |
Protected |
Inherited Attributes
Function Summary
- public static color(red: Number, green: Number, blue: Number, opacity: Number) : Color
-
Creates an sRGB color with the specified red, green, blue, and opacity values in the range (0.0 - 1.0).
More: [+]Creates an sRGB color with the specified red, green, blue, and opacity values in the range (0.0 - 1.0). The actual color used in rendering depends on finding the best match given the color space available for a particular output device.
This comment needs review.
-
Parameters
- red
- the red component, 0->1.0
- green
- the green component, 0 -> 1.0
- blue
- the blue component, 0 -> 1.0
- opacity
- the opacity component, 0 -> 1.0
-
Returns
- Color
Profile: common
- public static color(red: Number, green: Number, blue: Number) : Color
-
Creates an opaque sRGB color with the specified red, green, and blue values in the range (0.0 - 1.0).
More: [+]Creates an opaque sRGB color with the specified red, green, and blue values in the range (0.0 - 1.0). Opacity is defaulted to
1.0
. The actual color used in rendering depends on finding the best match given the color space available for a particular output device.This comment needs review.
-
Parameters
- red
- the red component, 0->1.0
- green
- the green component, 0 -> 1.0
- blue
- the blue component, 0 -> 1.0
-
Returns
- Color
Profile: common
- public static fromAWTColor(c: java.awt.Color) : Color
-
Creates a Color instance derived from the provided
More: [+]java.awt.Color
.Creates a Color instance derived from the provided
java.awt.Color
.This comment needs review.
-
Parameters
- c
-
Returns
- Color
- public getAWTColor() : java.awt.Color
-
Returns the
More: [+]java.awt.Color
delegate for this Color.Returns the
java.awt.Color
delegate for this Color.This method should not be public. It is an implementation detail.
This comment needs review.
-
Returns
- Color
- public getAWTPaint() : java.awt.Paint
-
Returns the
More: [+]java.awt.Paint
delegate for this Color.Returns the
java.awt.Paint
delegate for this Color.This method should not be public. It is an implementation detail.
This comment needs review.
-
Returns
- Paint
- public static hsb(hue: Number, saturation: Number, brightness: Number, opacity: Number) : Color
-
NOTE, the description of the H component is confusing.
More: [+]NOTE, the description of the H component is confusing. Why can't the hue simply be from 0->360 (with wrapping. The devleoper shouldn't have to understand how it is calculated.
Creates a
Color
object based on the specified values for the HSB color model. Thesaturation
,brightness
, andopacity
components should be floating-point values between zero and one (numbers in the range0.0 - 1.0)
. Thehue
component can be any floating-point number. The floor of this number is subtracted from it to create a fraction between 0 and 1. This fractional number is then multiplied by 360 to produce the hue angle in the HSB color model.This comment needs review.
-
Parameters
- hue
- the hue component, 0->1.0 (wraps)
- saturation
- the saturation of the color, 0->1.0
- brightness
- the brightness of the color, 0->1.0
- opacity
- the opacity component, 0->1.0
-
Returns
- Color
Profile: common
- public static hsb(hue: Number, saturation: Number, brightness: Number) : Color
-
Creates a
More: [+]Color
object based on the specified values for the HSB color model.Creates a
Color
object based on the specified values for the HSB color model. Thesaturation
andbrightness
components should be floating-point values between zero and one (numbers in the range 0.0-1.0). Thehue
component can be any floating-point number. The floor of this number is subtracted from it to create a fraction between 0 and 1. This fractional number is then multiplied by 360 to produce the hue angle in the HSB color model.This comment needs review.
-
Parameters
- hue
- the hue component, 0->1.0 (wraps)
- saturation
- the saturation of the color, 0->1.0
- brightness
- the brightness of the color, 0->1.0
-
Returns
- Color
Profile: common
- public ofTheWay(endVal: java.lang.Object, t: Number) : java.lang.Object
-
More: [+]
-
Parameters
- endVal
- t
-
Returns
- Object
- public static rgb(red: Integer, green: Integer, blue: Integer, opacity: Number) : Color
-
Creates an sRGB color with the specified red, green, blue values in the range (0 - 255) and opacity value in the range (0.0 - 1.0).
More: [+]Creates an sRGB color with the specified red, green, blue values in the range (0 - 255) and opacity value in the range (0.0 - 1.0).
-
Parameters
- red
- the red component, 0->255
- green
- the green component, 0->255
- blue
- the blue component, 0->255
- opacity
- the opacity component, 0->1.0
-
Returns
- Color
Profile: common
- public static rgb(red: Integer, green: Integer, blue: Integer) : Color
-
Creates an opaque sRGB color with the specified red, green, and blue values in the range (0 - 255).
More: [+]Creates an opaque sRGB color with the specified red, green, and blue values in the range (0 - 255). The actual color used in rendering depends on finding the best match given the color space available for a given output device. Opacity is defaulted to 255.
This comment needs review.
-
Parameters
- red
- the red component, 0->255
- green
- the green component, 0->255
- blue
- the blue component, 0->255
-
Returns
- Color
Profile: common
- public toString() : java.lang.String
-
Returns a string representation of this
More: [+]Color
.Returns a string representation of this
Color
. This method is intended to be used only for debugging purposes. The content and format of the returned string might vary between implementations. The returned string might be empty but cannot benull
.-
Returns
- String
Profile: common
- public static web(color: java.lang.String, opacity: Number) : Color
-
Creates an RGB color specified with the hexadecimal notation.
More: [+]Creates an RGB color specified with the hexadecimal notation. Opacity is in the range 0.0-1.0. ex:
var c = Color.web("0xff6688",1.0); var c = Color.web("#ff6688",1.0); var c = Color.web("ff6688",1.0);
This comment needs review.
-
Parameters
- color
- the hexadecimal string to identify the RGB color
- opacity
- the opacity component
-
Returns
- Color
Profile: common
- public static web(color: java.lang.String) : Color
-
Creates an RGB color specified with the hexadecimal notation.
More: [+]Creates an RGB color specified with the hexadecimal notation. Opacity is set to
1.0
. ex:var c = Color.web("0xff6688"); var c = Color.web("#ff6688"); var c = Color.web("ff6688");
This comment needs review.
-
Parameters
- color
- the hexadecimal string to identify the RGB color
-
Returns
- Color
Profile: common
Inherited Functions
javafx.scene.paint.Paint
- public abstract getAWTPaint() : java.awt.Paint
-
Creates and returns a paint context used to generate the color pattern.
More: [+]Creates and returns a paint context used to generate the color pattern.
-
Returns
- Paint
- the paint context for generating color patterns
javafx.animation.Interpolatable
- public abstract ofTheWay(endVal: java.lang.Object, t: Number) : java.lang.Object
-
More: [+]
-
Parameters
- endVal
- t
-
Returns
- Object