Package javafx.scene.paint
Class Color
java.lang.Object
javafx.scene.paint.Color
- All Implemented Interfaces:
Interpolatable<Color>
,Paint
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 double 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
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 invalid input: '&' value = 1.0. inplicit alpha of 1.0
Color c = Color.hsb(270,1.0,1.0,1.0); //hue = 270, saturation invalid input: '&' 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 TypeFieldDescriptionstatic final Color
The color alice blue with an RGB value of #F0F8FFstatic final Color
The color antique white with an RGB value of #FAEBD7static final Color
The color aqua with an RGB value of #00FFFFstatic final Color
The color aquamarine with an RGB value of #7FFFD4static final Color
The color azure with an RGB value of #F0FFFFstatic final Color
The color beige with an RGB value of #F5F5DCstatic final Color
The color bisque with an RGB value of #FFE4C4static final Color
The color black with an RGB value of #000000static final Color
The color blanched almond with an RGB value of #FFEBCDstatic final Color
The color blue with an RGB value of #0000FFstatic final Color
The color blue violet with an RGB value of #8A2BE2static final Color
The color brown with an RGB value of #A52A2Astatic final Color
The color burly wood with an RGB value of #DEB887static final Color
The color cadet blue with an RGB value of #5F9EA0static final Color
The color chartreuse with an RGB value of #7FFF00static final Color
The color chocolate with an RGB value of #D2691Estatic final Color
The color coral with an RGB value of #FF7F50static final Color
The color cornflower blue with an RGB value of #6495EDstatic final Color
The color cornsilk with an RGB value of #FFF8DCstatic final Color
The color crimson with an RGB value of #DC143Cstatic final Color
The color cyan with an RGB value of #00FFFFstatic final Color
The color dark blue with an RGB value of #00008Bstatic final Color
The color dark cyan with an RGB value of #008B8Bstatic final Color
The color dark goldenrod with an RGB value of #B8860Bstatic final Color
The color dark gray with an RGB value of #A9A9A9static final Color
The color dark green with an RGB value of #006400static final Color
The color dark grey with an RGB value of #A9A9A9static final Color
The color dark khaki with an RGB value of #BDB76Bstatic final Color
The color dark magenta with an RGB value of #8B008Bstatic final Color
The color dark olive green with an RGB value of #556B2Fstatic final Color
The color dark orange with an RGB value of #FF8C00static final Color
The color dark orchid with an RGB value of #9932CCstatic final Color
The color dark red with an RGB value of #8B0000static final Color
The color dark salmon with an RGB value of #E9967Astatic final Color
The color dark sea green with an RGB value of #8FBC8Fstatic final Color
The color dark slate blue with an RGB value of #483D8Bstatic final Color
The color dark slate gray with an RGB value of #2F4F4Fstatic final Color
The color dark slate grey with an RGB value of #2F4F4Fstatic final Color
The color dark turquoise with an RGB value of #00CED1static final Color
The color dark violet with an RGB value of #9400D3static final Color
The color deep pink with an RGB value of #FF1493static final Color
The color deep sky blue with an RGB value of #00BFFFstatic final Color
The color dim gray with an RGB value of #696969static final Color
The color dim grey with an RGB value of #696969static final Color
The color dodger blue with an RGB value of #1E90FFstatic final Color
The color firebrick with an RGB value of #B22222static final Color
The color floral white with an RGB value of #FFFAF0static final Color
The color forest green with an RGB value of #228B22static final Color
The color fuchsia with an RGB value of #FF00FFstatic final Color
The color gainsboro with an RGB value of #DCDCDCstatic final Color
The color ghost white with an RGB value of #F8F8FFstatic final Color
The color gold with an RGB value of #FFD700static final Color
The color goldenrod with an RGB value of #DAA520static final Color
The color gray with an RGB value of #808080static final Color
The color green with an RGB value of #008000static final Color
The color green yellow with an RGB value of #ADFF2Fstatic final Color
The color grey with an RGB value of #808080static final Color
The color honeydew with an RGB value of #F0FFF0static final Color
The color hot pink with an RGB value of #FF69B4static final Color
The color indian red with an RGB value of #CD5C5Cstatic final Color
The color indigo with an RGB value of #4B0082static final Color
The color ivory with an RGB value of #FFFFF0static final Color
The color khaki with an RGB value of #F0E68Cstatic final Color
The color lavender with an RGB value of #E6E6FAstatic final Color
The color lavender blush with an RGB value of #FFF0F5static final Color
The color lawn green with an RGB value of #7CFC00static final Color
The color lemon chiffon with an RGB value of #FFFACDstatic final Color
The color light blue with an RGB value of #ADD8E6static final Color
The color light coral with an RGB value of #F08080static final Color
The color light cyan with an RGB value of #E0FFFFstatic final Color
The color light goldenrod yellow with an RGB value of #FAFAD2static final Color
The color light gray with an RGB value of #D3D3D3static final Color
The color light green with an RGB value of #90EE90static final Color
The color light grey with an RGB value of #D3D3D3static final Color
The color light pink with an RGB value of #FFB6C1static final Color
The color light salmon with an RGB value of #FFA07Astatic final Color
The color light sea green with an RGB value of #20B2AAstatic final Color
The color light sky blue with an RGB value of #87CEFAstatic final Color
The color light slate gray with an RGB value of #778899static final Color
The color light slate grey with an RGB value of #778899static final Color
The color light steel blue with an RGB value of #B0C4DEstatic final Color
The color light yellow with an RGB value of #FFFFE0static final Color
The color lime with an RGB value of #00FF00static final Color
The color lime green with an RGB value of #32CD32static final Color
The color linen with an RGB value of #FAF0E6static final Color
The color magenta with an RGB value of #FF00FFstatic final Color
The color maroon with an RGB value of #800000static final Color
The color medium aquamarine with an RGB value of #66CDAAstatic final Color
The color medium blue with an RGB value of #0000CDstatic final Color
The color medium orchid with an RGB value of #BA55D3static final Color
The color medium purple with an RGB value of #9370DBstatic final Color
The color medium sea green with an RGB value of #3CB371static final Color
The color medium slate blue with an RGB value of #7B68EEstatic final Color
The color medium spring green with an RGB value of #00FA9Astatic final Color
The color medium turquoise with an RGB value of #48D1CCstatic final Color
The color medium violet red with an RGB value of #C71585static final Color
The color midnight blue with an RGB value of #191970static final Color
The color mint cream with an RGB value of #F5FFFAstatic final Color
The color misty rose with an RGB value of #FFE4E1static final Color
The color moccasin with an RGB value of #FFE4B5static final Color
The color navajo white with an RGB value of #FFDEADstatic final Color
The color navy with an RGB value of #000080static final Color
The color old lace with an RGB value of #FDF5E6static final Color
The color olive with an RGB value of #808000static final Color
The color olive drab with an RGB value of #6B8E23static final Color
The color orange with an RGB value of #FFA500static final Color
The color orange red with an RGB value of #FF4500static final Color
The color orchid with an RGB value of #DA70D6static final Color
The color pale goldenrod with an RGB value of #EEE8AAstatic final Color
The color pale green with an RGB value of #98FB98static final Color
The color pale turquoise with an RGB value of #AFEEEEstatic final Color
The color pale violet red with an RGB value of #DB7093static final Color
The color papaya whip with an RGB value of #FFEFD5static final Color
The color peach puff with an RGB value of #FFDAB9static final Color
The color peru with an RGB value of #CD853Fstatic final Color
The color pink with an RGB value of #FFC0CBstatic final Color
The color plum with an RGB value of #DDA0DDstatic final Color
The color powder blue with an RGB value of #B0E0E6static final Color
The color purple with an RGB value of #800080static final Color
The color red with an RGB value of #FF0000static final Color
The color rosy brown with an RGB value of #BC8F8Fstatic final Color
The color royal blue with an RGB value of #4169E1static final Color
The color saddle brown with an RGB value of #8B4513static final Color
The color salmon with an RGB value of #FA8072static final Color
The color sandy brown with an RGB value of #F4A460static final Color
The color sea green with an RGB value of #2E8B57static final Color
The color sea shell with an RGB value of #FFF5EEstatic final Color
The color sienna with an RGB value of #A0522Dstatic final Color
The color silver with an RGB value of #C0C0C0static final Color
The color sky blue with an RGB value of #87CEEBstatic final Color
The color slate blue with an RGB value of #6A5ACDstatic final Color
The color slate gray with an RGB value of #708090static final Color
The color slate grey with an RGB value of #708090static final Color
The color snow with an RGB value of #FFFAFAstatic final Color
The color spring green with an RGB value of #00FF7Fstatic final Color
The color steel blue with an RGB value of #4682B4static final Color
The color tan with an RGB value of #D2B48Cstatic final Color
The color teal with an RGB value of #008080static final Color
The color thistle with an RGB value of #D8BFD8static final Color
The color tomato with an RGB value of #FF6347static final Color
A fully transparent color with an ARGB value of #00000000.static final Color
The color turquoise with an RGB value of #40E0D0static final Color
The color violet with an RGB value of #EE82EEstatic final Color
The color wheat with an RGB value of #F5DEB3static final Color
The color white with an RGB value of #FFFFFFstatic final Color
The color white smoke with an RGB value of #F5F5F5static final Color
The color yellow with an RGB value of #FFFF00static final Color
The color yellow green with an RGB value of #9ACD32 -
Constructor Summary
ConstructorDescriptionColor
(double red, double green, double blue, double opacity) Creates a new instance of color -
Method Summary
Modifier and TypeMethodDescriptionbrighter()
Creates a new Color that is a brighter version of this Color.static Color
color
(double red, double green, double blue) Creates an opaque sRGB color with the specified red, green and blue values in the range0.0-1.0
.static Color
color
(double red, double green, double blue, double opacity) Creates an sRGB color with the specified red, green and blue values in the range0.0-1.0
, and a given opacity.darker()
Creates a new Color that is a darker version of this Color.deriveColor
(double hueShift, double saturationFactor, double brightnessFactor, double opacityFactor) Creates a newColor
based on thisColor
with hue, saturation, brightness and opacity values altered.Creates a new Color that is a less saturated version of this Color.boolean
Indicates whether some other object is "equal to" this one.final double
getBlue()
The blue component of theColor
, in the range0.0-1.0
.double
Gets the brightness component of thisColor
.final double
getGreen()
The green component of theColor
, in the range0.0-1.0
.double
getHue()
Gets the hue component of thisColor
.final double
The opacity of theColor
, in the range0.0-1.0
.final double
getRed()
The red component of theColor
, in the range0.0-1.0
.double
Gets the saturation component of thisColor
.static Color
gray
(double gray) Creates an opaque grey color.static Color
gray
(double gray, double opacity) Creates a grey color.static Color
grayRgb
(int gray) This is a shortcut forrgb(gray, gray, gray)
.static Color
grayRgb
(int gray, double opacity) This is a shortcut forrgb(gray, gray, gray, opacity)
.Creates a new Color that is grayscale equivalent of this Color.int
hashCode()
Returns a hash code for thisColor
object.static Color
hsb
(double hue, double saturation, double brightness) Creates an opaqueColor
based on the specified values in the HSB color model.static Color
hsb
(double hue, double saturation, double brightness, double opacity) Creates aColor
based on the specified values in the HSB color model, and a given opacity.interpolate
(Color endValue, double t) The function calculates an interpolated value along the fractiont
between0.0
and1.0
.invert()
Creates a new Color that is inversion of this Color.final boolean
isOpaque()
static Color
rgb
(int red, int green, int blue) Creates an opaque sRGB color with the specified RGB values in the range0-255
.static Color
rgb
(int red, int green, int blue, double opacity) Creates an sRGB color with the specified RGB values in the range0-255
, and a given opacity.saturate()
Creates a new Color that is a more saturated version of this Color.toString()
Returns a string representation of thisColor
.static Color
Creates a color value from a string representation.static Color
Creates an RGB color specified with an HTML or CSS attribute string.static Color
Creates an RGB color specified with an HTML or CSS attribute string.
-
Field Details
-
TRANSPARENT
A fully transparent color with an ARGB value of #00000000. -
ALICEBLUE
The color alice blue with an RGB value of #F0F8FF -
ANTIQUEWHITE
The color antique white with an RGB value of #FAEBD7 -
AQUA
The color aqua with an RGB value of #00FFFF -
AQUAMARINE
The color aquamarine with an RGB value of #7FFFD4 -
AZURE
The color azure with an RGB value of #F0FFFF -
BEIGE
The color beige with an RGB value of #F5F5DC -
BISQUE
The color bisque with an RGB value of #FFE4C4 -
BLACK
The color black with an RGB value of #000000 -
BLANCHEDALMOND
The color blanched almond with an RGB value of #FFEBCD -
BLUE
The color blue with an RGB value of #0000FF -
BLUEVIOLET
The color blue violet with an RGB value of #8A2BE2 -
BROWN
The color brown with an RGB value of #A52A2A -
BURLYWOOD
The color burly wood with an RGB value of #DEB887 -
CADETBLUE
The color cadet blue with an RGB value of #5F9EA0 -
CHARTREUSE
The color chartreuse with an RGB value of #7FFF00 -
CHOCOLATE
The color chocolate with an RGB value of #D2691E -
CORAL
The color coral with an RGB value of #FF7F50 -
CORNFLOWERBLUE
The color cornflower blue with an RGB value of #6495ED -
CORNSILK
The color cornsilk with an RGB value of #FFF8DC -
CRIMSON
The color crimson with an RGB value of #DC143C -
CYAN
The color cyan with an RGB value of #00FFFF -
DARKBLUE
The color dark blue with an RGB value of #00008B -
DARKCYAN
The color dark cyan with an RGB value of #008B8B -
DARKGOLDENROD
The color dark goldenrod with an RGB value of #B8860B -
DARKGRAY
The color dark gray with an RGB value of #A9A9A9 -
DARKGREEN
The color dark green with an RGB value of #006400 -
DARKGREY
The color dark grey with an RGB value of #A9A9A9 -
DARKKHAKI
The color dark khaki with an RGB value of #BDB76B -
DARKMAGENTA
The color dark magenta with an RGB value of #8B008B -
DARKOLIVEGREEN
The color dark olive green with an RGB value of #556B2F -
DARKORANGE
The color dark orange with an RGB value of #FF8C00 -
DARKORCHID
The color dark orchid with an RGB value of #9932CC -
DARKRED
The color dark red with an RGB value of #8B0000 -
DARKSALMON
The color dark salmon with an RGB value of #E9967A -
DARKSEAGREEN
The color dark sea green with an RGB value of #8FBC8F -
DARKSLATEBLUE
The color dark slate blue with an RGB value of #483D8B -
DARKSLATEGRAY
The color dark slate gray with an RGB value of #2F4F4F -
DARKSLATEGREY
The color dark slate grey with an RGB value of #2F4F4F -
DARKTURQUOISE
The color dark turquoise with an RGB value of #00CED1 -
DARKVIOLET
The color dark violet with an RGB value of #9400D3 -
DEEPPINK
The color deep pink with an RGB value of #FF1493 -
DEEPSKYBLUE
The color deep sky blue with an RGB value of #00BFFF -
DIMGRAY
The color dim gray with an RGB value of #696969 -
DIMGREY
The color dim grey with an RGB value of #696969 -
DODGERBLUE
The color dodger blue with an RGB value of #1E90FF -
FIREBRICK
The color firebrick with an RGB value of #B22222 -
FLORALWHITE
The color floral white with an RGB value of #FFFAF0 -
FORESTGREEN
The color forest green with an RGB value of #228B22 -
FUCHSIA
The color fuchsia with an RGB value of #FF00FF -
GAINSBORO
The color gainsboro with an RGB value of #DCDCDC -
GHOSTWHITE
The color ghost white with an RGB value of #F8F8FF -
GOLD
The color gold with an RGB value of #FFD700 -
GOLDENROD
The color goldenrod with an RGB value of #DAA520 -
GRAY
The color gray with an RGB value of #808080 -
GREEN
The color green with an RGB value of #008000 -
GREENYELLOW
The color green yellow with an RGB value of #ADFF2F -
GREY
The color grey with an RGB value of #808080 -
HONEYDEW
The color honeydew with an RGB value of #F0FFF0 -
HOTPINK
The color hot pink with an RGB value of #FF69B4 -
INDIANRED
The color indian red with an RGB value of #CD5C5C -
INDIGO
The color indigo with an RGB value of #4B0082 -
IVORY
The color ivory with an RGB value of #FFFFF0 -
KHAKI
The color khaki with an RGB value of #F0E68C -
LAVENDER
The color lavender with an RGB value of #E6E6FA -
LAVENDERBLUSH
The color lavender blush with an RGB value of #FFF0F5 -
LAWNGREEN
The color lawn green with an RGB value of #7CFC00 -
LEMONCHIFFON
The color lemon chiffon with an RGB value of #FFFACD -
LIGHTBLUE
The color light blue with an RGB value of #ADD8E6 -
LIGHTCORAL
The color light coral with an RGB value of #F08080 -
LIGHTCYAN
The color light cyan with an RGB value of #E0FFFF -
LIGHTGOLDENRODYELLOW
The color light goldenrod yellow with an RGB value of #FAFAD2 -
LIGHTGRAY
The color light gray with an RGB value of #D3D3D3 -
LIGHTGREEN
The color light green with an RGB value of #90EE90 -
LIGHTGREY
The color light grey with an RGB value of #D3D3D3 -
LIGHTPINK
The color light pink with an RGB value of #FFB6C1 -
LIGHTSALMON
The color light salmon with an RGB value of #FFA07A -
LIGHTSEAGREEN
The color light sea green with an RGB value of #20B2AA -
LIGHTSKYBLUE
The color light sky blue with an RGB value of #87CEFA -
LIGHTSLATEGRAY
The color light slate gray with an RGB value of #778899 -
LIGHTSLATEGREY
The color light slate grey with an RGB value of #778899 -
LIGHTSTEELBLUE
The color light steel blue with an RGB value of #B0C4DE -
LIGHTYELLOW
The color light yellow with an RGB value of #FFFFE0 -
LIME
The color lime with an RGB value of #00FF00 -
LIMEGREEN
The color lime green with an RGB value of #32CD32 -
LINEN
The color linen with an RGB value of #FAF0E6 -
MAGENTA
The color magenta with an RGB value of #FF00FF -
MAROON
The color maroon with an RGB value of #800000 -
MEDIUMAQUAMARINE
The color medium aquamarine with an RGB value of #66CDAA -
MEDIUMBLUE
The color medium blue with an RGB value of #0000CD -
MEDIUMORCHID
The color medium orchid with an RGB value of #BA55D3 -
MEDIUMPURPLE
The color medium purple with an RGB value of #9370DB -
MEDIUMSEAGREEN
The color medium sea green with an RGB value of #3CB371 -
MEDIUMSLATEBLUE
The color medium slate blue with an RGB value of #7B68EE -
MEDIUMSPRINGGREEN
The color medium spring green with an RGB value of #00FA9A -
MEDIUMTURQUOISE
The color medium turquoise with an RGB value of #48D1CC -
MEDIUMVIOLETRED
The color medium violet red with an RGB value of #C71585 -
MIDNIGHTBLUE
The color midnight blue with an RGB value of #191970 -
MINTCREAM
The color mint cream with an RGB value of #F5FFFA -
MISTYROSE
The color misty rose with an RGB value of #FFE4E1 -
MOCCASIN
The color moccasin with an RGB value of #FFE4B5 -
NAVAJOWHITE
The color navajo white with an RGB value of #FFDEAD -
NAVY
The color navy with an RGB value of #000080 -
OLDLACE
The color old lace with an RGB value of #FDF5E6 -
OLIVE
The color olive with an RGB value of #808000 -
OLIVEDRAB
The color olive drab with an RGB value of #6B8E23 -
ORANGE
The color orange with an RGB value of #FFA500 -
ORANGERED
The color orange red with an RGB value of #FF4500 -
ORCHID
The color orchid with an RGB value of #DA70D6 -
PALEGOLDENROD
The color pale goldenrod with an RGB value of #EEE8AA -
PALEGREEN
The color pale green with an RGB value of #98FB98 -
PALETURQUOISE
The color pale turquoise with an RGB value of #AFEEEE -
PALEVIOLETRED
The color pale violet red with an RGB value of #DB7093 -
PAPAYAWHIP
The color papaya whip with an RGB value of #FFEFD5 -
PEACHPUFF
The color peach puff with an RGB value of #FFDAB9 -
PERU
The color peru with an RGB value of #CD853F -
PINK
The color pink with an RGB value of #FFC0CB -
PLUM
The color plum with an RGB value of #DDA0DD -
POWDERBLUE
The color powder blue with an RGB value of #B0E0E6 -
PURPLE
The color purple with an RGB value of #800080 -
RED
The color red with an RGB value of #FF0000 -
ROSYBROWN
The color rosy brown with an RGB value of #BC8F8F -
ROYALBLUE
The color royal blue with an RGB value of #4169E1 -
SADDLEBROWN
The color saddle brown with an RGB value of #8B4513 -
SALMON
The color salmon with an RGB value of #FA8072 -
SANDYBROWN
The color sandy brown with an RGB value of #F4A460 -
SEAGREEN
The color sea green with an RGB value of #2E8B57 -
SEASHELL
The color sea shell with an RGB value of #FFF5EE -
SIENNA
The color sienna with an RGB value of #A0522D -
SILVER
The color silver with an RGB value of #C0C0C0 -
SKYBLUE
The color sky blue with an RGB value of #87CEEB -
SLATEBLUE
The color slate blue with an RGB value of #6A5ACD -
SLATEGRAY
The color slate gray with an RGB value of #708090 -
SLATEGREY
The color slate grey with an RGB value of #708090 -
SNOW
The color snow with an RGB value of #FFFAFA -
SPRINGGREEN
The color spring green with an RGB value of #00FF7F -
STEELBLUE
The color steel blue with an RGB value of #4682B4 -
TAN
The color tan with an RGB value of #D2B48C -
TEAL
The color teal with an RGB value of #008080 -
THISTLE
The color thistle with an RGB value of #D8BFD8 -
TOMATO
The color tomato with an RGB value of #FF6347 -
TURQUOISE
The color turquoise with an RGB value of #40E0D0 -
VIOLET
The color violet with an RGB value of #EE82EE -
WHEAT
The color wheat with an RGB value of #F5DEB3 -
WHITE
The color white with an RGB value of #FFFFFF -
WHITESMOKE
The color white smoke with an RGB value of #F5F5F5 -
YELLOW
The color yellow with an RGB value of #FFFF00 -
YELLOWGREEN
The color yellow green with an RGB value of #9ACD32
-
-
Constructor Details
-
Color
public Color(double red, double green, double blue, double opacity) Creates a new instance of color- Parameters:
red
- red component ranging from0
to1
green
- green component ranging from0
to1
blue
- blue component ranging from0
to1
opacity
- opacity ranging from0
to1
-
-
Method Details
-
color
Creates an sRGB color with the specified red, green and blue values in the range0.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
Creates an opaque sRGB color with the specified red, green and blue values in the range0.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
Creates an sRGB color with the specified RGB values in the range0-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
Creates an opaque sRGB color with the specified RGB values in the range0-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
This is a shortcut forrgb(gray, gray, gray)
. -
grayRgb
This is a shortcut forrgb(gray, gray, gray, opacity)
. -
gray
Creates a grey color.- 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
Creates an opaque grey color.- 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
Creates aColor
based on the specified values in the HSB color model, and a given opacity.- Parameters:
hue
- the hue, in degreessaturation
- 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
,brightness
oropacity
are out of range
-
hsb
Creates an opaqueColor
based on the specified values in the HSB color model.- Parameters:
hue
- the hue, in degreessaturation
- the saturation,0.0 to 1.0
brightness
- the brightness,0.0 to 1.0
- Returns:
- the
Color
- Throws:
IllegalArgumentException
- ifsaturation
orbrightness
are out of range
-
web
Creates an RGB color specified with an HTML or CSS attribute string.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 range00
to0xFF
or a single digit in the range0
toF
. - An
rgb(r,g,b)
orrgba(r,g,b,a)
format string. Each of ther
,g
, orb
values 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. Theh
value is a floating point number from 0.0 to 360.0 representing the hue angle on a color wheel in degrees with0.0
or360.0
representing red,120.0
representing green, and240.0
representing blue. Thes
value 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 thel
value 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 theopacity
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 formatsopacity
- the opacity component in range from 0.0 (transparent) to 1.0 (opaque)- Throws:
NullPointerException
- ifcolorString
isnull
IllegalArgumentException
- ifcolorString
specifies an unsupported color name or contains an illegal numeric value
-
web
Creates an RGB color specified with an HTML or CSS attribute string.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 range00
to0xFF
or a single digit in the range0
toF
. - An
rgb(r,g,b)
orrgba(r,g,b,a)
format string. Each of ther
,g
, orb
values 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. Theh
value is a floating point number from 0.0 to 360.0 representing the hue angle on a color wheel in degrees with0.0
or360.0
representing red,120.0
representing green, and240.0
representing blue. Thes
value 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 thel
value 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- Throws:
NullPointerException
- ifcolorString
isnull
IllegalArgumentException
- ifcolorString
specifies an unsupported color name or contains an illegal numeric value
-
valueOf
Creates a color value from a string representation. The format of the string representation is the same as inweb(String)
.- Parameters:
value
- the string to convert- Returns:
- a
Color
object holding the value represented by the string argument - Throws:
NullPointerException
- if thevalue
isnull
IllegalArgumentException
- if thevalue
specifies an unsupported color name or illegal hexadecimal value- Since:
- JavaFX 2.1
- See Also:
-
getHue
public double getHue()Gets the hue component of thisColor
.- Returns:
- Hue value in the range in the range
0.0-360.0
.
-
getSaturation
public double getSaturation()Gets the saturation component of thisColor
.- Returns:
- Saturation value in the range in the range
0.0-1.0
.
-
getBrightness
public double getBrightness()Gets the brightness component of thisColor
.- 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) Creates a newColor
based on thisColor
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. -
brighter
Creates a new Color that is a brighter version of this Color. -
darker
Creates a new Color that is a darker version of this Color. -
saturate
Creates a new Color that is a more saturated version of this Color. -
desaturate
Creates a new Color that is a less saturated version of this Color. -
grayscale
Creates a new Color that is grayscale equivalent of this Color. Opacity is preserved. -
invert
Creates a new Color that is inversion of this Color. Opacity is preserved. -
getRed
public final double getRed()The red component of theColor
, in the range0.0-1.0
.- Default value:
- 0.0
-
getGreen
public final double getGreen()The green component of theColor
, in the range0.0-1.0
.- Default value:
- 0.0
-
getBlue
public final double getBlue()The blue component of theColor
, in the range0.0-1.0
.- Default value:
- 0.0
-
getOpacity
public final double getOpacity()The opacity of theColor
, in the range0.0-1.0
.- Default value:
- 1.0
-
isOpaque
public final boolean isOpaque() -
interpolate
Description copied from interface:Interpolatable
The function calculates an interpolated value along the fractiont
between0.0
and1.0
. Whent
= 1.0,endVal
is returned.- Specified by:
interpolate
in interfaceInterpolatable<Color>
- Parameters:
endValue
- target valuet
- fraction between0.0
and1.0
- Returns:
- interpolated value
-
equals
Indicates whether some other object is "equal to" this one. -
hashCode
public int hashCode()Returns a hash code for thisColor
object. -
toString
Returns a string representation of thisColor
. 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 benull
.
-