Class Color
- All Implemented Interfaces:
Interpolatable<Paint>
public final class Color extends Paint
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:
Color c = Color.BLUE; //use the blue constant
Color c = new Color(0,0,1,1.0); // standard constructor, use 0->1.0 values, explicit alpha of 1.0
Color c = Color.color(0,0,1.0); //use 0->1.0 values. implicit alpha of 1.0
Color c = Color.color(0,0,1.0,1.0); //use 0->1.0 values, explicit alpha of 1.0
Color c = Color.rgb(0,0,255); //use 0->255 integers, implicit alpha of 1.0
Color c = Color.rgb(0,0,255,1.0); //use 0->255 integers, explicit alpha of 1.0
Color c = Color.hsb(270,1.0,1.0); //hue = 270, saturation & value = 1.0. implicit alpha of 1.0
Color c = Color.hsb(270,1.0,1.0,1.0); //hue = 270, saturation & value = 1.0, explicit alpha of 1.0
Color c = Color.web("0x0000FF",1.0);// blue as a hex web value, explicit alpha
Color c = Color.web("0x0000FF");// blue as a hex web value, implicit alpha
Color c = Color.web("0x00F");// blue as a short hex web value, implicit alpha
Color c = Color.web("#0000FF",1.0);// blue as a hex web value, explicit alpha
Color c = Color.web("#0000FF");// blue as a hex web value, implicit alpha
Color c = Color.web("#00F");// blue as a short hex web value, implicit alpha
Color c = Color.web("0000FF",1.0);// blue as a hex web value, explicit alpha
Color c = Color.web("0000FF");// blue as a hex web value, implicit alpha
Color c = Color.web("00F");// blue as a short hex web value, implicit alpha
Color c = Color.web("rgba(0,0,255,1.0)");// blue as an rgb web value, explicit alpha
Color c = Color.web("rgb(0,0,255)");// blue as an rgb web value, implicit alpha
Color c = Color.web("rgba(0,0,100%,1.0)");// blue as an rgb percent web value, explicit alpha
Color c = Color.web("rgb(0,0,100%)");// blue as an rgb percent web value, implicit alpha
Color c = Color.web("hsla(270,100%,100%,1.0)");// blue as an hsl web value, explicit alpha
Color c = Color.web("hsl(270,100%,100%)");// blue as an hsl web value, implicit alpha
The creation of a Color will throw IllegalArgumentException if any of the values are out of range.
For example:
Rectangle rec1 = new Rectangle(5, 5, 50, 40);
rec1.setFill(Color.RED);
rec1.setStroke(Color.GREEN);
rec1.setStrokeWidth(3);
Rectangle rec2 = new Rectangle(65, 5, 50, 40);
rec2.setFill(Color.rgb(91, 127, 255));
rec2.setStroke(Color.hsb(40, 0.7, 0.8));
rec2.setStrokeWidth(3);
- Since:
- JavaFX 2.0
Field Summary
| Modifier and Type | Field | Description |
|---|---|---|
static final Color |
ALICEBLUE |
The color alice blue with an RGB value of #F0F8FF |
static final Color |
ANTIQUEWHITE |
The color antique white with an RGB value of #FAEBD7 |
static final Color |
AQUA |
The color aqua with an RGB value of #00FFFF |
static final Color |
AQUAMARINE |
The color aquamarine with an RGB value of #7FFFD4 |
static final Color |
AZURE |
The color azure with an RGB value of #F0FFFF |
static final Color |
BEIGE |
The color beige with an RGB value of #F5F5DC |
static final Color |
BISQUE |
The color bisque with an RGB value of #FFE4C4 |
static final Color |
BLACK |
The color black with an RGB value of #000000 |
static final Color |
BLANCHEDALMOND |
The color blanched almond with an RGB value of #FFEBCD |
static final Color |
BLUE |
The color blue with an RGB value of #0000FF |
static final Color |
BLUEVIOLET |
The color blue violet with an RGB value of #8A2BE2 |
static final Color |
BROWN |
The color brown with an RGB value of #A52A2A |
static final Color |
BURLYWOOD |
The color burly wood with an RGB value of #DEB887 |
static final Color |
CADETBLUE |
The color cadet blue with an RGB value of #5F9EA0 |
static final Color |
CHARTREUSE |
The color chartreuse with an RGB value of #7FFF00 |
static final Color |
CHOCOLATE |
The color chocolate with an RGB value of #D2691E |
static final Color |
CORAL |
The color coral with an RGB value of #FF7F50 |
static final Color |
CORNFLOWERBLUE |
The color cornflower blue with an RGB value of #6495ED |
static final Color |
CORNSILK |
The color cornsilk with an RGB value of #FFF8DC |
static final Color |
CRIMSON |
The color crimson with an RGB value of #DC143C |
static final Color |
CYAN |
The color cyan with an RGB value of #00FFFF |
static final Color |
DARKBLUE |
The color dark blue with an RGB value of #00008B |
static final Color |
DARKCYAN |
The color dark cyan with an RGB value of #008B8B |
static final Color |
DARKGOLDENROD |
The color dark goldenrod with an RGB value of #B8860B |
static final Color |
DARKGRAY |
The color dark gray with an RGB value of #A9A9A9 |
static final Color |
DARKGREEN |
The color dark green with an RGB value of #006400 |
static final Color |
DARKGREY |
The color dark grey with an RGB value of #A9A9A9 |
static final Color |
DARKKHAKI |
The color dark khaki with an RGB value of #BDB76B |
static final Color |
DARKMAGENTA |
The color dark magenta with an RGB value of #8B008B |
static final Color |
DARKOLIVEGREEN |
The color dark olive green with an RGB value of #556B2F |
static final Color |
DARKORANGE |
The color dark orange with an RGB value of #FF8C00 |
static final Color |
DARKORCHID |
The color dark orchid with an RGB value of #9932CC |
static final Color |
DARKRED |
The color dark red with an RGB value of #8B0000 |
static final Color |
DARKSALMON |
The color dark salmon with an RGB value of #E9967A |
static final Color |
DARKSEAGREEN |
The color dark sea green with an RGB value of #8FBC8F |
static final Color |
DARKSLATEBLUE |
The color dark slate blue with an RGB value of #483D8B |
static final Color |
DARKSLATEGRAY |
The color dark slate gray with an RGB value of #2F4F4F |
static final Color |
DARKSLATEGREY |
The color dark slate grey with an RGB value of #2F4F4F |
static final Color |
DARKTURQUOISE |
The color dark turquoise with an RGB value of #00CED1 |
static final Color |
DARKVIOLET |
The color dark violet with an RGB value of #9400D3 |
static final Color |
DEEPPINK |
The color deep pink with an RGB value of #FF1493 |
static final Color |
DEEPSKYBLUE |
The color deep sky blue with an RGB value of #00BFFF |
static final Color |
DIMGRAY |
The color dim gray with an RGB value of #696969 |
static final Color |
DIMGREY |
The color dim grey with an RGB value of #696969 |
static final Color |
DODGERBLUE |
The color dodger blue with an RGB value of #1E90FF |
static final Color |
FIREBRICK |
The color firebrick with an RGB value of #B22222 |
static final Color |
FLORALWHITE |
The color floral white with an RGB value of #FFFAF0 |
static final Color |
FORESTGREEN |
The color forest green with an RGB value of #228B22 |
static final Color |
FUCHSIA |
The color fuchsia with an RGB value of #FF00FF |
static final Color |
GAINSBORO |
The color gainsboro with an RGB value of #DCDCDC |
static final Color |
GHOSTWHITE |
The color ghost white with an RGB value of #F8F8FF |
static final Color |
GOLD |
The color gold with an RGB value of #FFD700 |
static final Color |
GOLDENROD |
The color goldenrod with an RGB value of #DAA520 |
static final Color |
GRAY |
The color gray with an RGB value of #808080 |
static final Color |
GREEN |
The color green with an RGB value of #008000 |
static final Color |
GREENYELLOW |
The color green yellow with an RGB value of #ADFF2F |
static final Color |
GREY |
The color grey with an RGB value of #808080 |
static final Color |
HONEYDEW |
The color honeydew with an RGB value of #F0FFF0 |
static final Color |
HOTPINK |
The color hot pink with an RGB value of #FF69B4 |
static final Color |
INDIANRED |
The color indian red with an RGB value of #CD5C5C |
static final Color |
INDIGO |
The color indigo with an RGB value of #4B0082 |
static final Color |
IVORY |
The color ivory with an RGB value of #FFFFF0 |
static final Color |
KHAKI |
The color khaki with an RGB value of #F0E68C |
static final Color |
LAVENDER |
The color lavender with an RGB value of #E6E6FA |
static final Color |
LAVENDERBLUSH |
The color lavender blush with an RGB value of #FFF0F5 |
static final Color |
LAWNGREEN |
The color lawn green with an RGB value of #7CFC00 |
static final Color |
LEMONCHIFFON |
The color lemon chiffon with an RGB value of #FFFACD |
static final Color |
LIGHTBLUE |
The color light blue with an RGB value of #ADD8E6 |
static final Color |
LIGHTCORAL |
The color light coral with an RGB value of #F08080 |
static final Color |
LIGHTCYAN |
The color light cyan with an RGB value of #E0FFFF |
static final Color |
LIGHTGOLDENRODYELLOW |
The color light goldenrod yellow with an RGB value of #FAFAD2 |
static final Color |
LIGHTGRAY |
The color light gray with an RGB value of #D3D3D3 |
static final Color |
LIGHTGREEN |
The color light green with an RGB value of #90EE90 |
static final Color |
LIGHTGREY |
The color light grey with an RGB value of #D3D3D3 |
static final Color |
LIGHTPINK |
The color light pink with an RGB value of #FFB6C1 |
static final Color |
LIGHTSALMON |
The color light salmon with an RGB value of #FFA07A |
static final Color |
LIGHTSEAGREEN |
The color light sea green with an RGB value of #20B2AA |
static final Color |
LIGHTSKYBLUE |
The color light sky blue with an RGB value of #87CEFA |
static final Color |
LIGHTSLATEGRAY |
The color light slate gray with an RGB value of #778899 |
static final Color |
LIGHTSLATEGREY |
The color light slate grey with an RGB value of #778899 |
static final Color |
LIGHTSTEELBLUE |
The color light steel blue with an RGB value of #B0C4DE |
static final Color |
LIGHTYELLOW |
The color light yellow with an RGB value of #FFFFE0 |
static final Color |
LIME |
The color lime with an RGB value of #00FF00 |
static final Color |
LIMEGREEN |
The color lime green with an RGB value of #32CD32 |
static final Color |
LINEN |
The color linen with an RGB value of #FAF0E6 |
static final Color |
MAGENTA |
The color magenta with an RGB value of #FF00FF |
static final Color |
MAROON |
The color maroon with an RGB value of #800000 |
static final Color |
MEDIUMAQUAMARINE |
The color medium aquamarine with an RGB value of #66CDAA |
static final Color |
MEDIUMBLUE |
The color medium blue with an RGB value of #0000CD |
static final Color |
MEDIUMORCHID |
The color medium orchid with an RGB value of #BA55D3 |
static final Color |
MEDIUMPURPLE |
The color medium purple with an RGB value of #9370DB |
static final Color |
MEDIUMSEAGREEN |
The color medium sea green with an RGB value of #3CB371 |
static final Color |
MEDIUMSLATEBLUE |
The color medium slate blue with an RGB value of #7B68EE |
static final Color |
MEDIUMSPRINGGREEN |
The color medium spring green with an RGB value of #00FA9A |
static final Color |
MEDIUMTURQUOISE |
The color medium turquoise with an RGB value of #48D1CC |
static final Color |
MEDIUMVIOLETRED |
The color medium violet red with an RGB value of #C71585 |
static final Color |
MIDNIGHTBLUE |
The color midnight blue with an RGB value of #191970 |
static final Color |
MINTCREAM |
The color mint cream with an RGB value of #F5FFFA |
static final Color |
MISTYROSE |
The color misty rose with an RGB value of #FFE4E1 |
static final Color |
MOCCASIN |
The color moccasin with an RGB value of #FFE4B5 |
static final Color |
NAVAJOWHITE |
The color navajo white with an RGB value of #FFDEAD |
static final Color |
NAVY |
The color navy with an RGB value of #000080 |
static final Color |
OLDLACE |
The color old lace with an RGB value of #FDF5E6 |
static final Color |
OLIVE |
The color olive with an RGB value of #808000 |
static final Color |
OLIVEDRAB |
The color olive drab with an RGB value of #6B8E23 |
static final Color |
ORANGE |
The color orange with an RGB value of #FFA500 |
static final Color |
ORANGERED |
The color orange red with an RGB value of #FF4500 |
static final Color |
ORCHID |
The color orchid with an RGB value of #DA70D6 |
static final Color |
PALEGOLDENROD |
The color pale goldenrod with an RGB value of #EEE8AA |
static final Color |
PALEGREEN |
The color pale green with an RGB value of #98FB98 |
static final Color |
PALETURQUOISE |
The color pale turquoise with an RGB value of #AFEEEE |
static final Color |
PALEVIOLETRED |
The color pale violet red with an RGB value of #DB7093 |
static final Color |
PAPAYAWHIP |
The color papaya whip with an RGB value of #FFEFD5 |
static final Color |
PEACHPUFF |
The color peach puff with an RGB value of #FFDAB9 |
static final Color |
PERU |
The color peru with an RGB value of #CD853F |
static final Color |
PINK |
The color pink with an RGB value of #FFC0CB |
static final Color |
PLUM |
The color plum with an RGB value of #DDA0DD |
static final Color |
POWDERBLUE |
The color powder blue with an RGB value of #B0E0E6 |
static final Color |
PURPLE |
The color purple with an RGB value of #800080 |
static final Color |
RED |
The color red with an RGB value of #FF0000 |
static final Color |
ROSYBROWN |
The color rosy brown with an RGB value of #BC8F8F |
static final Color |
ROYALBLUE |
The color royal blue with an RGB value of #4169E1 |
static final Color |
SADDLEBROWN |
The color saddle brown with an RGB value of #8B4513 |
static final Color |
SALMON |
The color salmon with an RGB value of #FA8072 |
static final Color |
SANDYBROWN |
The color sandy brown with an RGB value of #F4A460 |
static final Color |
SEAGREEN |
The color sea green with an RGB value of #2E8B57 |
static final Color |
SEASHELL |
The color sea shell with an RGB value of #FFF5EE |
static final Color |
SIENNA |
The color sienna with an RGB value of #A0522D |
static final Color |
SILVER |
The color silver with an RGB value of #C0C0C0 |
static final Color |
SKYBLUE |
The color sky blue with an RGB value of #87CEEB |
static final Color |
SLATEBLUE |
The color slate blue with an RGB value of #6A5ACD |
static final Color |
SLATEGRAY |
The color slate gray with an RGB value of #708090 |
static final Color |
SLATEGREY |
The color slate grey with an RGB value of #708090 |
static final Color |
SNOW |
The color snow with an RGB value of #FFFAFA |
static final Color |
SPRINGGREEN |
The color spring green with an RGB value of #00FF7F |
static final Color |
STEELBLUE |
The color steel blue with an RGB value of #4682B4 |
static final Color |
TAN |
The color tan with an RGB value of #D2B48C |
static final Color |
TEAL |
The color teal with an RGB value of #008080 |
static final Color |
THISTLE |
The color thistle with an RGB value of #D8BFD8 |
static final Color |
TOMATO |
The color tomato with an RGB value of #FF6347 |
static final Color |
TRANSPARENT |
A fully transparent color with an ARGB value of #00000000. |
static final Color |
TURQUOISE |
The color turquoise with an RGB value of #40E0D0 |
static final Color |
VIOLET |
The color violet with an RGB value of #EE82EE |
static final Color |
WHEAT |
The color wheat with an RGB value of #F5DEB3 |
static final Color |
WHITE |
The color white with an RGB value of #FFFFFF |
static final Color |
WHITESMOKE |
The color white smoke with an RGB value of #F5F5F5 |
static final Color |
YELLOW |
The color yellow with an RGB value of #FFFF00 |
static final Color |
YELLOWGREEN |
The color yellow green with an RGB value of #9ACD32 |
Constructor Summary
| Constructor | Description |
|---|---|
Color |
Creates a Color with the specified red, green, blue, and alpha values in the range 0.0-1.0. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
Color |
brighter() |
Creates a new Color that is a brighter version of this Color. |
static Color |
color |
Creates an opaque sRGB color with the specified red, green and blue values in the range 0.0-1.0. |
static Color |
color |
Creates an sRGB color with the specified red, green and blue values in the range 0.0-1.0, and a given opacity. |
Color |
darker() |
Creates a new Color that is a darker version of this Color. |
Color |
deriveColor |
Creates a new Color based on this Color with hue, saturation, brightness and opacity values altered. |
Color |
desaturate() |
Creates a new Color that is a less saturated version of this Color. |
boolean |
equals |
Indicates whether some other object is "equal to" this one. |
final double |
getBlue() |
The blue component of the Color, in the range 0.0-1.0. |
double |
getBrightness() |
Gets the brightness component of this Color. |
final double |
getGreen() |
The green component of the Color, in the range 0.0-1.0. |
double |
getHue() |
Gets the hue component of this Color. |
final double |
getOpacity() |
The opacity of the Color, in the range 0.0-1.0. |
final double |
getRed() |
The red component of the Color, in the range 0.0-1.0. |
double |
getSaturation() |
Gets the saturation component of this Color. |
static Color |
gray |
Creates an opaque grey color. |
static Color |
gray |
Creates a grey color. |
static Color |
grayRgb |
This is a shortcut for rgb(gray, gray, gray). |
static Color |
grayRgb |
This is a shortcut for rgb(gray, gray, gray, opacity). |
Color |
grayscale() |
Creates a new Color that is grayscale equivalent of this Color. |
int |
hashCode() |
Returns a hash code for this Color object. |
static Color |
hsb |
Creates an opaque Color based on the specified values in the HSB color model. |
static Color |
hsb |
Creates a Color based on the specified values in the HSB color model, and a given opacity. |
Color |
interpolate |
Returns an intermediate value between the value of this Color and the specified endValue using the linear interpolation factor t, ranging from 0 (inclusive) to 1 (inclusive). |
Paint |
interpolate |
Returns an intermediate value between the value of this Interpolatable and the specified endValue using the linear interpolation factor t, ranging from 0 (inclusive) to 1 (inclusive). |
Color |
invert() |
Creates a new Color that is inversion of this Color. |
final boolean |
isOpaque() |
Gets whether this Paint is completely opaque. |
static Color |
rgb |
Creates an opaque sRGB color with the specified RGB values in the range 0-255. |
static Color |
rgb |
Creates an sRGB color with the specified RGB values in the range 0-255, and a given opacity. |
Color |
saturate() |
Creates a new Color that is a more saturated version of this Color. |
String |
toString() |
Returns a string representation of this Color. |
static Color |
valueOf |
Creates a color value from a string representation. |
static Color |
web |
Creates an RGB color specified with an HTML or CSS attribute string. |
static Color |
web |
Creates an RGB color specified with an HTML or CSS attribute string. |
Field Details
TRANSPARENT
public static final Color TRANSPARENT
ALICEBLUE
public static final Color ALICEBLUE
ANTIQUEWHITE
public static final Color ANTIQUEWHITE
AQUA
public static final Color AQUA
AQUAMARINE
public static final Color AQUAMARINE
AZURE
public static final Color AZURE
BEIGE
public static final Color BEIGE
BISQUE
public static final Color BISQUE
BLACK
public static final Color BLACK
BLANCHEDALMOND
public static final Color BLANCHEDALMOND
BLUE
public static final Color BLUE
BLUEVIOLET
public static final Color BLUEVIOLET
BROWN
public static final Color BROWN
BURLYWOOD
public static final Color BURLYWOOD
CADETBLUE
public static final Color CADETBLUE
CHARTREUSE
public static final Color CHARTREUSE
CHOCOLATE
public static final Color CHOCOLATE
CORAL
public static final Color CORAL
CORNFLOWERBLUE
public static final Color CORNFLOWERBLUE
CORNSILK
public static final Color CORNSILK
CRIMSON
public static final Color CRIMSON
CYAN
public static final Color CYAN
DARKBLUE
public static final Color DARKBLUE
DARKCYAN
public static final Color DARKCYAN
DARKGOLDENROD
public static final Color DARKGOLDENROD
DARKGRAY
public static final Color DARKGRAY
DARKGREEN
public static final Color DARKGREEN
DARKGREY
public static final Color DARKGREY
DARKKHAKI
public static final Color DARKKHAKI
DARKMAGENTA
public static final Color DARKMAGENTA
DARKOLIVEGREEN
public static final Color DARKOLIVEGREEN
DARKORANGE
public static final Color DARKORANGE
DARKORCHID
public static final Color DARKORCHID
DARKRED
public static final Color DARKRED
DARKSALMON
public static final Color DARKSALMON
DARKSEAGREEN
public static final Color DARKSEAGREEN
DARKSLATEBLUE
public static final Color DARKSLATEBLUE
DARKSLATEGRAY
public static final Color DARKSLATEGRAY
DARKSLATEGREY
public static final Color DARKSLATEGREY
DARKTURQUOISE
public static final Color DARKTURQUOISE
DARKVIOLET
public static final Color DARKVIOLET
DEEPPINK
public static final Color DEEPPINK
DEEPSKYBLUE
public static final Color DEEPSKYBLUE
DIMGRAY
public static final Color DIMGRAY
DIMGREY
public static final Color DIMGREY
DODGERBLUE
public static final Color DODGERBLUE
FIREBRICK
public static final Color FIREBRICK
FLORALWHITE
public static final Color FLORALWHITE
FORESTGREEN
public static final Color FORESTGREEN
FUCHSIA
public static final Color FUCHSIA
GAINSBORO
public static final Color GAINSBORO
GHOSTWHITE
public static final Color GHOSTWHITE
GOLD
public static final Color GOLD
GOLDENROD
public static final Color GOLDENROD
GRAY
public static final Color GRAY
GREEN
public static final Color GREEN
GREENYELLOW
public static final Color GREENYELLOW
GREY
public static final Color GREY
HONEYDEW
public static final Color HONEYDEW
HOTPINK
public static final Color HOTPINK
INDIANRED
public static final Color INDIANRED
INDIGO
public static final Color INDIGO
IVORY
public static final Color IVORY
KHAKI
public static final Color KHAKI
LAVENDER
public static final Color LAVENDER
LAVENDERBLUSH
public static final Color LAVENDERBLUSH
LAWNGREEN
public static final Color LAWNGREEN
LEMONCHIFFON
public static final Color LEMONCHIFFON
LIGHTBLUE
public static final Color LIGHTBLUE
LIGHTCORAL
public static final Color LIGHTCORAL
LIGHTCYAN
public static final Color LIGHTCYAN
LIGHTGOLDENRODYELLOW
public static final Color LIGHTGOLDENRODYELLOW
LIGHTGRAY
public static final Color LIGHTGRAY
LIGHTGREEN
public static final Color LIGHTGREEN
LIGHTGREY
public static final Color LIGHTGREY
LIGHTPINK
public static final Color LIGHTPINK
LIGHTSALMON
public static final Color LIGHTSALMON
LIGHTSEAGREEN
public static final Color LIGHTSEAGREEN
LIGHTSKYBLUE
public static final Color LIGHTSKYBLUE
LIGHTSLATEGRAY
public static final Color LIGHTSLATEGRAY
LIGHTSLATEGREY
public static final Color LIGHTSLATEGREY
LIGHTSTEELBLUE
public static final Color LIGHTSTEELBLUE
LIGHTYELLOW
public static final Color LIGHTYELLOW
LIME
public static final Color LIME
LIMEGREEN
public static final Color LIMEGREEN
LINEN
public static final Color LINEN
MAGENTA
public static final Color MAGENTA
MAROON
public static final Color MAROON
MEDIUMAQUAMARINE
public static final Color MEDIUMAQUAMARINE
MEDIUMBLUE
public static final Color MEDIUMBLUE
MEDIUMORCHID
public static final Color MEDIUMORCHID
MEDIUMPURPLE
public static final Color MEDIUMPURPLE
MEDIUMSEAGREEN
public static final Color MEDIUMSEAGREEN
MEDIUMSLATEBLUE
public static final Color MEDIUMSLATEBLUE
MEDIUMSPRINGGREEN
public static final Color MEDIUMSPRINGGREEN
MEDIUMTURQUOISE
public static final Color MEDIUMTURQUOISE
MEDIUMVIOLETRED
public static final Color MEDIUMVIOLETRED
MIDNIGHTBLUE
public static final Color MIDNIGHTBLUE
MINTCREAM
public static final Color MINTCREAM
MISTYROSE
public static final Color MISTYROSE
MOCCASIN
public static final Color MOCCASIN
NAVAJOWHITE
public static final Color NAVAJOWHITE
NAVY
public static final Color NAVY
OLDLACE
public static final Color OLDLACE
OLIVE
public static final Color OLIVE
OLIVEDRAB
public static final Color OLIVEDRAB
ORANGE
public static final Color ORANGE
ORANGERED
public static final Color ORANGERED
ORCHID
public static final Color ORCHID
PALEGOLDENROD
public static final Color PALEGOLDENROD
PALEGREEN
public static final Color PALEGREEN
PALETURQUOISE
public static final Color PALETURQUOISE
PALEVIOLETRED
public static final Color PALEVIOLETRED
PAPAYAWHIP
public static final Color PAPAYAWHIP
PEACHPUFF
public static final Color PEACHPUFF
PERU
public static final Color PERU
PINK
public static final Color PINK
PLUM
public static final Color PLUM
POWDERBLUE
public static final Color POWDERBLUE
PURPLE
public static final Color PURPLE
RED
public static final Color RED
ROSYBROWN
public static final Color ROSYBROWN
ROYALBLUE
public static final Color ROYALBLUE
SADDLEBROWN
public static final Color SADDLEBROWN
SALMON
public static final Color SALMON
SANDYBROWN
public static final Color SANDYBROWN
SEAGREEN
public static final Color SEAGREEN
SEASHELL
public static final Color SEASHELL
SIENNA
public static final Color SIENNA
SILVER
public static final Color SILVER
SKYBLUE
public static final Color SKYBLUE
SLATEBLUE
public static final Color SLATEBLUE
SLATEGRAY
public static final Color SLATEGRAY
SLATEGREY
public static final Color SLATEGREY
SNOW
public static final Color SNOW
SPRINGGREEN
public static final Color SPRINGGREEN
STEELBLUE
public static final Color STEELBLUE
TAN
public static final Color TAN
TEAL
public static final Color TEAL
THISTLE
public static final Color THISTLE
TOMATO
public static final Color TOMATO
TURQUOISE
public static final Color TURQUOISE
VIOLET
public static final Color VIOLET
WHEAT
public static final Color WHEAT
WHITE
public static final Color WHITE
WHITESMOKE
public static final Color WHITESMOKE
YELLOW
public static final Color YELLOW
YELLOWGREEN
public static final Color YELLOWGREEN
Constructor Details
Color
public Color(double red, double green, double blue, double opacity)
Color with the specified red, green, blue, and alpha values in the range 0.0-1.0.- Parameters:
-
red- red component ranging from0to1 -
green- green component ranging from0to1 -
blue- blue component ranging from0to1 -
opacity- opacity ranging from0to1
Method Details
color
public static Color color(double red, double green, double blue, double opacity)
0.0-1.0, and a given opacity.- Parameters:
-
red- the red component, in the range0.0-1.0 -
green- the green component, in the range0.0-1.0 -
blue- the blue component, in the range0.0-1.0 -
opacity- the opacity component, in the range0.0-1.0 - Returns:
- the
Color - Throws:
-
IllegalArgumentException- if any value is out of range
color
public static Color color(double red, double green, double blue)
0.0-1.0.- Parameters:
-
red- the red component, in the range0.0-1.0 -
green- the green component, in the range0.0-1.0 -
blue- the blue component, in the range0.0-1.0 - Returns:
- the
Color - Throws:
-
IllegalArgumentException- if any value is out of range
rgb
public static Color rgb(int red, int green, int blue, double opacity)
0-255, and a given opacity.- Parameters:
-
red- the red component, in the range0-255 -
green- the green component, in the range0-255 -
blue- the blue component, in the range0-255 -
opacity- the opacity component, in the range0.0-1.0 - Returns:
- the
Color - Throws:
-
IllegalArgumentException- if any value is out of range
rgb
public static Color rgb(int red, int green, int blue)
0-255.- Parameters:
-
red- the red component, in the range0-255 -
green- the green component, in the range0-255 -
blue- the blue component, in the range0-255 - Returns:
- the
Color - Throws:
-
IllegalArgumentException- if any value is out of range
grayRgb
public static Color grayRgb(int gray)
rgb(gray, gray, gray).- Parameters:
-
gray- the gray component, in the range0-255 - Returns:
- the
Color
grayRgb
public static Color grayRgb(int gray, double opacity)
rgb(gray, gray, gray, opacity).- Parameters:
-
gray- the gray component, in the range0-255 -
opacity- the opacity component, in the range0.0-1.0 - Returns:
- the
Color
gray
public static Color gray(double gray, double opacity)
- Parameters:
-
gray- color on gray scale in the range0.0(black) -1.0(white). -
opacity- the opacity component, in the range0.0-1.0 - Returns:
- the
Color - Throws:
-
IllegalArgumentException- if any value is out of range
gray
public static Color gray(double gray)
- Parameters:
-
gray- color on gray scale in the range0.0(black) -1.0(white). - Returns:
- the
Color - Throws:
-
IllegalArgumentException- if any value is out of range
hsb
public static Color hsb(double hue, double saturation, double brightness, double opacity)
Color based on the specified values in the HSB color model, and a given opacity.- Parameters:
-
hue- the hue, in degrees -
saturation- the saturation,0.0 to 1.0 -
brightness- the brightness,0.0 to 1.0 -
opacity- the opacity,0.0 to 1.0 - Returns:
- the
Color - Throws:
-
IllegalArgumentException- ifsaturation,brightnessoropacityare out of range
hsb
public static Color hsb(double hue, double saturation, double brightness)
Color based on the specified values in the HSB color model.- Parameters:
-
hue- the hue, in degrees -
saturation- the saturation,0.0 to 1.0 -
brightness- the brightness,0.0 to 1.0 - Returns:
- the
Color - Throws:
-
IllegalArgumentException- ifsaturationorbrightnessare out of range
web
public static Color web(String colorString, double opacity)
This method supports the following formats:
- Any standard HTML color name
- An HTML long or short format hex string with an optional hex alpha channel. Hexadecimal values may be preceded by either
"0x"or"#"and can either be 2 digits in the range00to0xFFor a single digit in the range0toF. - An
rgb(r,g,b)orrgba(r,g,b,a)format string. Each of ther,g, orbvalues can be an integer from 0 to 255 or a floating point percentage value from 0.0 to 100.0 followed by the percent (%) character. The alpha component, if present, is a floating point value from 0.0 to 1.0. Spaces are allowed before or after the numbers and between the percentage number and its percent sign (%). - An
hsl(h,s,l)orhsla(h,s,l,a)format string. Thehvalue is a floating point number from 0.0 to 360.0 representing the hue angle on a color wheel in degrees with0.0or360.0representing red,120.0representing green, and240.0representing blue. Thesvalue is the saturation of the desired color represented as a floating point percentage from gray (0.0) to the fully saturated color (100.0) and thelvalue is the desired lightness or brightness of the desired color represented as a floating point percentage from black (0.0) to the full brightness of the color (100.0). The alpha component, if present, is a floating point value from 0.0 to 1.0. Spaces are allowed before or after the numbers and between the percentage number and its percent sign (%).
For formats without an alpha component and for named colors, opacity is set according to the opacity argument. For colors specified with an alpha component, the resulting opacity is a combination of the parsed alpha component and the opacity argument, so a transparent color becomes more transparent by specifying opacity.
Examples:
| Web Format String | Equivalent constructor or factory call |
|---|---|
Color.web("orange", 0.5); | new Color(1.0, 0xA5/255.0, 0.0, 0.5) |
Color.web("0xff66cc33", 0.5); | new Color(1.0, 0.4, 0.8, 0.1) |
Color.web("0xff66cc", 0.5); | new Color(1.0, 0.4, 0.8, 0.5) |
Color.web("#ff66cc", 0.5); | new Color(1.0, 0.4, 0.8, 0.5) |
Color.web("#f68", 0.5); | new Color(1.0, 0.4, 0.8, 0.5) |
Color.web("rgb(255,102,204)", 0.5); | new Color(1.0, 0.4, 0.8, 0.5) |
Color.web("rgb(100%,50%,50%)", 0.5); | new Color(1.0, 0.5, 0.5, 0.5) |
Color.web("rgb(255,50%,50%,0.25)", 0.5); | new Color(1.0, 0.5, 0.5, 0.125) |
Color.web("hsl(240,100%,100%)", 0.5); | Color.hsb(240.0, 1.0, 1.0, 0.5) |
Color.web("hsla(120,0%,0%,0.25)", 0.5); | Color.hsb(120.0, 0.0, 0.0, 0.125) |
- Parameters:
-
colorString- the name or numeric representation of the color in one of the supported formats -
opacity- the opacity component in range from 0.0 (transparent) to 1.0 (opaque) - Returns:
- the RGB color specified with the colorString
- Throws:
-
NullPointerException- ifcolorStringisnull -
IllegalArgumentException- ifcolorStringspecifies an unsupported color name or contains an illegal numeric value
web
public static Color web(String colorString)
This method supports the following formats:
- Any standard HTML color name
- An HTML long or short format hex string with an optional hex alpha channel. Hexadecimal values may be preceded by either
"0x"or"#"and can either be 2 digits in the range00to0xFFor a single digit in the range0toF. - An
rgb(r,g,b)orrgba(r,g,b,a)format string. Each of ther,g, orbvalues can be an integer from 0 to 255 or a floating point percentage value from 0.0 to 100.0 followed by the percent (%) character. The alpha component, if present, is a floating point value from 0.0 to 1.0. Spaces are allowed before or after the numbers and between the percentage number and its percent sign (%). - An
hsl(h,s,l)orhsla(h,s,l,a)format string. Thehvalue is a floating point number from 0.0 to 360.0 representing the hue angle on a color wheel in degrees with0.0or360.0representing red,120.0representing green, and240.0representing blue. Thesvalue is the saturation of the desired color represented as a floating point percentage from gray (0.0) to the fully saturated color (100.0) and thelvalue is the desired lightness or brightness of the desired color represented as a floating point percentage from black (0.0) to the full brightness of the color (100.0). The alpha component, if present, is a floating point value from 0.0 to 1.0. Spaces are allowed before or after the numbers and between the percentage number and its percent sign (%).
Examples:
| Web Format String | Equivalent constant or factory call |
|---|---|
Color.web("orange"); | Color.ORANGE |
Color.web("0xff668840"); | Color.rgb(255, 102, 136, 0.25) |
Color.web("0xff6688"); | Color.rgb(255, 102, 136, 1.0) |
Color.web("#ff6688"); | Color.rgb(255, 102, 136, 1.0) |
Color.web("#f68"); | Color.rgb(255, 102, 136, 1.0) |
Color.web("rgb(255,102,136)"); | Color.rgb(255, 102, 136, 1.0) |
Color.web("rgb(100%,50%,50%)"); | Color.rgb(255, 128, 128, 1.0) |
Color.web("rgb(255,50%,50%,0.25)"); | Color.rgb(255, 128, 128, 0.25) |
Color.web("hsl(240,100%,100%)"); | Color.hsb(240.0, 1.0, 1.0, 1.0) |
Color.web("hsla(120,0%,0%,0.25)"); | Color.hsb(120.0, 0.0, 0.0, 0.25) |
- Parameters:
-
colorString- the name or numeric representation of the color in one of the supported formats - Returns:
- an RGB color
- Throws:
-
NullPointerException- ifcolorStringisnull -
IllegalArgumentException- ifcolorStringspecifies an unsupported color name or contains an illegal numeric value
valueOf
public static Color valueOf(String value)
web(String).- Parameters:
-
value- the string to convert - Returns:
- a
Colorobject holding the value represented by the string argument - Throws:
-
NullPointerException- if thevalueisnull -
IllegalArgumentException- if thevaluespecifies an unsupported color name or illegal hexadecimal value - Since:
- JavaFX 2.1
- See Also:
getHue
public double getHue()
Color.- Returns:
- Hue value in the range in the range
0.0-360.0.
getSaturation
public double getSaturation()
Color.- Returns:
- Saturation value in the range in the range
0.0-1.0.
getBrightness
public double getBrightness()
Color.- Returns:
- Brightness value in the range in the range
0.0-1.0.
deriveColor
public Color deriveColor(double hueShift, double saturationFactor, double brightnessFactor, double opacityFactor)
Color based on this Color with hue, saturation, brightness and opacity values altered. Hue is shifted about the given value and normalized into its natural range, the other components' values are multiplied by the given factors and clipped into their ranges. Increasing brightness of black color is allowed by using an arbitrary, very small source brightness instead of zero.- Parameters:
-
hueShift- the hue shift -
saturationFactor- the saturation factor -
brightnessFactor- the brightness factor -
opacityFactor- the opacity factor - Returns:
- a
Colorbased based on thisColorwith hue, saturation, brightness and opacity values altered.
brighter
public Color brighter()
- Returns:
- a Color that is a brighter version of this Color
darker
public Color darker()
- Returns:
- a Color that is a darker version of this Color
saturate
public Color saturate()
- Returns:
- a Color that is a more saturated version of this Color
desaturate
public Color desaturate()
- Returns:
- a Color that is a less saturated version of this Color
grayscale
public Color grayscale()
- Returns:
- a Color that is grayscale equivalent of this Color
invert
public Color invert()
- Returns:
- a Color that is inversion of this Color
getRed
public final double getRed()
Color, in the range 0.0-1.0.- Default value:
- 0.0
- Interpolation Type:
- linear
- Returns:
- the red component of the
Color, in the range0.0-1.0
getGreen
public final double getGreen()
Color, in the range 0.0-1.0.- Default value:
- 0.0
- Interpolation Type:
- linear
- Returns:
- the green component of the
Color, in the range0.0-1.0
getBlue
public final double getBlue()
Color, in the range 0.0-1.0.- Default value:
- 0.0
- Interpolation Type:
- linear
- Returns:
- the blue component of the
Color, in the range0.0-1.0
getOpacity
public final double getOpacity()
Color, in the range 0.0-1.0.- Default value:
- 1.0
- Interpolation Type:
- linear
- Returns:
- the opacity of the
Color, in the range0.0-1.0
isOpaque
public final boolean isOpaque()
interpolate
public Color interpolate(Color endValue, double t)
Color and the specified endValue using the linear interpolation factor t, ranging from 0 (inclusive) to 1 (inclusive).- Parameters:
-
endValue- the target value -
t- the interpolation factor - Returns:
- the intermediate value
- Throws:
-
NullPointerException- ifendValueisnull
interpolate
public Paint interpolate(Paint endValue, double t)
Interpolatable and the specified endValue using the linear interpolation factor t, ranging from 0 (inclusive) to 1 (inclusive). The returned value might not be a new instance; the implementation might also return one of the two existing instances if the intermediate value would be equal to one of the existing values. However, this is an optimization and applications should not assume any particular identity of the returned value.
- Parameters:
-
endValue- the target value -
t- the interpolation factor - Returns:
- the intermediate value
- Throws:
-
NullPointerException- ifendValueisnull - Since:
- 24
equals
hashCode
toString
public String toString()
Color. This method is intended to be used only for informational purposes. The content and format of the returned string might vary between implementations. The returned string might be empty but cannot be null.
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.