Class UI.Color
- All Implemented Interfaces:
Paint
,Transparency
,Serializable
- Enclosing class:
- UI
Color
class is a refined and more complete/modernized
implementation of the Color
class which models colors in the default
sRGB color space or colors in arbitrary color spaces identified by a
ColorSpace
.
The original
Color
class is an immutable and value based class
(it overrides equals
and hashCode
)
but it is missing so called with-methods, which are a modern way to create
updated copies of an object without having to call the full constructor
with all the parameters.
Here a list of the most useful features additionally provided by this class:
With-Methods
withRed(double)
,withGreen(double)
,withBlue(double)
withOpacity(double)
,withAlpha(int)
withHue(double)
,withSaturation(double)
,withBrightness(double)
brighterBy(double)
,darkerBy(double)
saturate()
,saturateBy(double)
desaturate()
,desaturateBy(double)
grayscale()
invert()
- ...
Color.darker()
and Color.brighter()
methods. Not only do they now return
a Color
type, but also use an implementation which updates the
brightness/darkness in terms of the HSB color space.(The original implementation considers colors like
Color.BLUE
, Color.RED
and Color.GREEN
to be the brightest possible colors, which is not true in terms
of the much more useful HSB color space modelling.)
Besides the RGB values every
fully opaque Color
also has an implicit alpha value of 1.0.
But you may also construct a Color
with an explicit alpha value
by using the Color(float, float, float, float)
constructor for example.
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.
The default color space for the Java 2D(tm) API is sRGB, a proposed standard RGB color space. For further information on sRGB, see http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html .
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final UI.Color
The color alice blue with an RGB value of #F0F8FFstatic final UI.Color
The color antique white with an RGB value of #FAEBD7static final UI.Color
The color aqua with an RGB value of #00FFFFstatic final UI.Color
The color aquamarine with an RGB value of #7FFFD4static final UI.Color
The color azure with an RGB value of #F0FFFFstatic final UI.Color
The color beige with an RGB value of #F5F5DCstatic final UI.Color
The color bisque with an RGB value of #FFE4C4static final UI.Color
The color black with an RGB value of #000000static final UI.Color
The color blanched almond with an RGB value of #FFEBCDstatic final UI.Color
The color blue with an RGB value of #0000FFstatic final UI.Color
The color blue violet with an RGB value of #8A2BE2static final UI.Color
The color brown with an RGB value of #A52A2Astatic final UI.Color
The color burly wood with an RGB value of #DEB887static final UI.Color
The color cadet blue with an RGB value of #5F9EA0static final UI.Color
The color chartreuse with an RGB value of #7FFF00static final UI.Color
The color chocolate with an RGB value of #D2691Estatic final UI.Color
The color coral with an RGB value of #FF7F50static final UI.Color
The color cornflower blue with an RGB value of #6495EDstatic final UI.Color
The color cornsilk with an RGB value of #FFF8DCstatic final UI.Color
The color crimson with an RGB value of #DC143Cstatic final UI.Color
The color cyan with an RGB value of #00FFFFstatic final UI.Color
The color dark blue with an RGB value of #00008Bstatic final UI.Color
The color dark cyan with an RGB value of #008B8Bstatic final UI.Color
The color dark goldenrod with an RGB value of #B8860Bstatic final UI.Color
The color dark gray with an RGB value of #A9A9A9static final UI.Color
The color dark green with an RGB value of #006400static final UI.Color
The color dark grey with an RGB value of #A9A9A9static final UI.Color
The color dark khaki with an RGB value of #BDB76Bstatic final UI.Color
The color dark magenta with an RGB value of #8B008Bstatic final UI.Color
The color dark olive green with an RGB value of #556B2Fstatic final UI.Color
The color dark orange with an RGB value of #FF8C00static final UI.Color
The color dark orchid with an RGB value of #9932CCstatic final UI.Color
The color dark red with an RGB value of #8B0000static final UI.Color
The color dark salmon with an RGB value of #E9967Astatic final UI.Color
The color dark sea green with an RGB value of #8FBC8Fstatic final UI.Color
The color dark slate blue with an RGB value of #483D8Bstatic final UI.Color
The color dark slate gray with an RGB value of #2F4F4Fstatic final UI.Color
The color dark slate grey with an RGB value of #2F4F4Fstatic final UI.Color
The color dark turquoise with an RGB value of #00CED1static final UI.Color
The color dark violet with an RGB value of #9400D3static final UI.Color
The color deep pink with an RGB value of #FF1493static final UI.Color
The color deep sky blue with an RGB value of #00BFFFstatic final UI.Color
The color dim gray with an RGB value of #696969static final UI.Color
The color dim grey with an RGB value of #696969static final UI.Color
The color dodger blue with an RGB value of #1E90FFstatic final UI.Color
The color firebrick with an RGB value of #B22222static final UI.Color
The color floral white with an RGB value of #FFFAF0static final UI.Color
The color forest green with an RGB value of #228B22static final UI.Color
The color fuchsia with an RGB value of #FF00FFstatic final UI.Color
The color gainsboro with an RGB value of #DCDCDCstatic final UI.Color
The color ghost white with an RGB value of #F8F8FFstatic final UI.Color
The color gold with an RGB value of #FFD700static final UI.Color
The color goldenrod with an RGB value of #DAA520static final UI.Color
The color gray with an RGB value of #808080static final UI.Color
The color green with an RGB value of #008000static final UI.Color
The color green yellow with an RGB value of #ADFF2Fstatic final UI.Color
The color grey with an RGB value of #808080static final UI.Color
The color honeydew with an RGB value of #F0FFF0static final UI.Color
The color hot pink with an RGB value of #FF69B4static final UI.Color
The color indian red with an RGB value of #CD5C5Cstatic final UI.Color
The color indigo with an RGB value of #4B0082static final UI.Color
The color ivory with an RGB value of #FFFFF0static final UI.Color
The color khaki with an RGB value of #F0E68Cstatic final UI.Color
The color lavender with an RGB value of #E6E6FAstatic final UI.Color
The color lavender blush with an RGB value of #FFF0F5static final UI.Color
The color lawn green with an RGB value of #7CFC00static final UI.Color
The color lemon chiffon with an RGB value of #FFFACDstatic final UI.Color
The color light blue with an RGB value of #ADD8E6static final UI.Color
The color light coral with an RGB value of #F08080static final UI.Color
The color light cyan with an RGB value of #E0FFFFstatic final UI.Color
The color light goldenrod yellow with an RGB value of #FAFAD2static final UI.Color
The color light gray with an RGB value of #D3D3D3static final UI.Color
The color light green with an RGB value of #90EE90static final UI.Color
The color light grey with an RGB value of #D3D3D3static final UI.Color
The color light pink with an RGB value of #FFB6C1static final UI.Color
The color light salmon with an RGB value of #FFA07Astatic final UI.Color
The color light sea green with an RGB value of #20B2AAstatic final UI.Color
The color light sky blue with an RGB value of #87CEFAstatic final UI.Color
The color light slate gray with an RGB value of #778899static final UI.Color
The color light slate grey with an RGB value of #778899static final UI.Color
The color light steel blue with an RGB value of #B0C4DEstatic final UI.Color
The color light yellow with an RGB value of #FFFFE0static final UI.Color
The color lime with an RGB value of #00FF00static final UI.Color
The color lime green with an RGB value of #32CD32static final UI.Color
The color linen with an RGB value of #FAF0E6static final UI.Color
The color magenta with an RGB value of #FF00FFstatic final UI.Color
The color maroon with an RGB value of #800000static final UI.Color
The color medium aquamarine with an RGB value of #66CDAAstatic final UI.Color
The color medium blue with an RGB value of #0000CDstatic final UI.Color
The color medium orchid with an RGB value of #BA55D3static final UI.Color
The color medium purple with an RGB value of #9370DBstatic final UI.Color
The color medium sea green with an RGB value of #3CB371static final UI.Color
The color medium slate blue with an RGB value of #7B68EEstatic final UI.Color
The color medium spring green with an RGB value of #00FA9Astatic final UI.Color
The color medium turquoise with an RGB value of #48D1CCstatic final UI.Color
The color medium violet red with an RGB value of #C71585static final UI.Color
The color midnight blue with an RGB value of #191970static final UI.Color
The color mint cream with an RGB value of #F5FFFAstatic final UI.Color
The color misty rose with an RGB value of #FFE4E1static final UI.Color
The color moccasin with an RGB value of #FFE4B5static final UI.Color
The color navajo white with an RGB value of #FFDEADstatic final UI.Color
The color navy with an RGB value of #000080static final UI.Color
The color "oak".static final UI.Color
The color old lace with an RGB value of #FDF5E6static final UI.Color
The color olive with an RGB value of #808000static final UI.Color
The color olive drab with an RGB value of #6B8E23static final UI.Color
The color orange with an RGB value of #FFA500static final UI.Color
The color orange red with an RGB value of #FF4500static final UI.Color
The color orchid with an RGB value of #DA70D6static final UI.Color
The color pale goldenrod with an RGB value of #EEE8AAstatic final UI.Color
The color pale green with an RGB value of #98FB98static final UI.Color
The color pale turquoise with an RGB value of #AFEEEEstatic final UI.Color
The color pale violet red with an RGB value of #DB7093static final UI.Color
The color papaya whip with an RGB value of #FFEFD5static final UI.Color
The color peach puff with an RGB value of #FFDAB9static final UI.Color
The color peru with an RGB value of #CD853Fstatic final UI.Color
The color pink with an RGB value of #FFC0CBstatic final UI.Color
The color plum with an RGB value of #DDA0DDstatic final UI.Color
The color powder blue with an RGB value of #B0E0E6static final UI.Color
The color purple with an RGB value of #800080static final UI.Color
The color red with an RGB value of #FF0000static final UI.Color
The color rosy brown with an RGB value of #BC8F8Fstatic final UI.Color
The color royal blue with an RGB value of #4169E1static final UI.Color
The color saddle brown with an RGB value of #8B4513static final UI.Color
The color salmon with an RGB value of #FA8072static final UI.Color
The color sandy brown with an RGB value of #F4A460static final UI.Color
The color sea green with an RGB value of #2E8B57static final UI.Color
The color sea shell with an RGB value of #FFF5EEstatic final UI.Color
The color sienna with an RGB value of #A0522Dstatic final UI.Color
The color silver with an RGB value of #C0C0C0static final UI.Color
The color sky blue with an RGB value of #87CEEBstatic final UI.Color
The color slate blue with an RGB value of #6A5ACDstatic final UI.Color
The color slate gray with an RGB value of #708090static final UI.Color
The color slate grey with an RGB value of #708090static final UI.Color
The color snow with an RGB value of #FFFAFAstatic final UI.Color
The color spring green with an RGB value of #00FF7Fstatic final UI.Color
The color steel blue with an RGB value of #4682B4static final UI.Color
The color tan with an RGB value of #D2B48Cstatic final UI.Color
The color teal with an RGB value of #008080static final UI.Color
The color thistle with an RGB value of #D8BFD8static final UI.Color
The color tomato with an RGB value of #FF6347static final UI.Color
A fully transparent color with an ARGB value of #00000000.static final UI.Color
The color turquoise with an RGB value of #40E0D0static final UI.Color
This constant is aUI.Color
object with all of its rgba values set to 0.static final UI.Color
The color violet with an RGB value of #EE82EEstatic final UI.Color
The color wheat with an RGB value of #F5DEB3static final UI.Color
The color white with an RGB value of #FFFFFFstatic final UI.Color
The color white smoke with an RGB value of #F5F5F5static final UI.Color
The color yellow with an RGB value of #FFFF00static final UI.Color
The color yellow green with an RGB value of #9ACD32Fields inherited from class java.awt.Color
black, blue, cyan, DARK_GRAY, darkGray, gray, green, LIGHT_GRAY, lightGray, magenta, orange, pink, red, white, yellow
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
-
Method Summary
Modifier and TypeMethodDescriptiondouble
blue()
The blue component of theColor
, in the range0.0-1.0
.brighter()
Creates a new color that is a brighter version of this color.brighterBy
(double percentage) Creates an updated color whose brightness is increased by the specified factor.double
Gets the brightness component of thisColor
.darker()
Creates a new color that is a darker version of this color.darkerBy
(double percentage) Creates an updated color whose brightness is decreased by the specified percentage factor.Creates a new color that is a less saturated version of this color.desaturateBy
(double percentage) Creates a color which is desaturated by the specified percentage factor.Creates an updated color that is grayscale equivalent of this color.double
green()
The green component of theColor
, in the range0.0-1.0
.double
hue()
Gets the hue component of thisColor
.invert()
Creates a new color that is inversion of this color.static UI.Color
of
(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 UI.Color
of
(double red, double green, double blue, double opacity) Creates an sRGB color with the specified RGB values in the range0-255
, and a given opacity.static UI.Color
of
(float red, float green, float blue) Creates an opaque sRGB color with the specified red, green and blue values in the range0.0-1.0
.static UI.Color
of
(float red, float green, float blue, float opacity) Creates an sRGB color with the specified RGB values in the range0-255
, and a given opacity.static UI.Color
static UI.Color
of
(ColorSpace cspace, float[] components, float alpha) Creates a color in the specifiedColorSpace
with the color components specified in thefloat
array and the specified alpha.static UI.Color
static UI.Color
ofGray
(double gray) Creates an opaque grey color.static UI.Color
ofGray
(double gray, double opacity) Creates a grey color.static UI.Color
ofGrayRgb
(int gray) This is a shortcut forrgb(gray, gray, gray)
.static UI.Color
ofGrayRgb
(int gray, double opacity) This is a shortcut forrgb(gray, gray, gray, opacity)
.static UI.Color
ofHsb
(double hue, double saturation, double brightness, double opacity) Creates aColor
based on the specified values in the HSB color model, and a given opacity.static UI.Color
ofRgb
(int rgb) Creates an opaque sRGB color with the specified combined RGB value consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7.static UI.Color
ofRgb
(int rgba, boolean hasalpha) Creates an sRGB color with the specified combined RGBA value consisting of the alpha component in bits 24-31, the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7.static UI.Color
ofRgb
(int red, int green, int blue) Creates an opaque sRGB color with the specified RGB values in the range0-255
.static UI.Color
ofRgb
(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.static UI.Color
ofRgba
(int r, int g, int b, int a) Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0 - 255).double
opacity()
The opacity of theColor
, in the range0.0-1.0
.double
red()
The red component of theColor
, in the range0.0-1.0
.saturate()
Provides an updated color that is a more saturated version of this color.saturateBy
(double percentage) Creates a color which is saturated by the specified percentage factor.double
Gets the saturation component of thisColor
.withAlpha
(int alpha) Creates and returns an updated version of this color with the alpha component changed to the specified value in the range0-255
.withBlue
(double blue) Returns an updated version of this color with the blue component changed to the specified value in the range0.0-1.0
.withBrightness
(double brightness) Returns an updated version of this color with the brightness changed to the specified value in the range0.0-1.0
.withGreen
(double green) Returns an updated version of this color with the green component changed to the specified value in the range0.0-1.0
.withHue
(double hue) Returns an updated version of this color with the hue changed to the specified value in the range0.0-360.0
.withOpacity
(double opacity) Returns an updated version of this color with the opacity changed to the specified value in the range0.0-1.0
.withRed
(double red) Returns an updated version of this color with the red component changed to the specified value in the range0.0-1.0
.withSaturation
(double saturation) Returns an updated version of this color with the saturation changed to the specified value in the range0.0-1.0
.Methods inherited from class java.awt.Color
createContext, decode, equals, getAlpha, getBlue, getColor, getColor, getColor, getColorComponents, getColorComponents, getColorSpace, getComponents, getComponents, getGreen, getHSBColor, getRed, getRGB, getRGBColorComponents, getRGBComponents, getTransparency, hashCode, HSBtoRGB, RGBtoHSB, toString
-
Field Details
-
UNDEFINED
This constant is aUI.Color
object with all of its rgba values set to 0. Its identity is used to represent the absence of a color being specified, and it is used as a safe replacement for null, meaning that when the style engine of a component encounters it, it will pass it onto theComponent.setBackground(java.awt.Color)
andComponent.setForeground(java.awt.Color)
methods as null. Passing null to these methods means that the look and feel determines the coloring. -
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 -
OAK
The color "oak". -
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
-
-
Method Details
-
of
- Parameters:
color
- The color to convert to a color.- Returns:
- The color object.
-
ofRgb
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
-
ofRgba
Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0 - 255).- Parameters:
r
- the red componentg
- the green componentb
- the blue componenta
- the alpha component- Throws:
IllegalArgumentException
- ifr
,g
,b
ora
are outside of the range 0 to 255, inclusive- See Also:
-
ofRgb
Creates an opaque sRGB color with the specified combined RGB value consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7. The actual color used in rendering depends on finding the best match given the color space available for a particular output device. Alpha is defaulted to 255.- Parameters:
rgb
- the combined RGB components- See Also:
-
ofRgb
Creates an sRGB color with the specified combined RGBA value consisting of the alpha component in bits 24-31, the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7. If thehasalpha
argument isfalse
, alpha is defaulted to 255.- Parameters:
rgba
- the combined RGBA componentshasalpha
-true
if the alpha bits are valid;false
otherwise- See Also:
-
of
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- See Also:
-
of
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- See Also:
-
of
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- See Also:
-
of
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- See Also:
-
of
Creates a color in the specifiedColorSpace
with the color components specified in thefloat
array and the specified alpha. The number of components is determined by the type of theColorSpace
. For example, RGB requires 3 components, but CMYK requires 4 components.- Parameters:
cspace
- theColorSpace
to be used to interpret the componentscomponents
- an arbitrary number of color components that is compatible with theColorSpace
alpha
- alpha value- Throws:
IllegalArgumentException
- if any of the values in thecomponents
array oralpha
is outside of the range 0.0 to 1.0- See Also:
-
ofRgb
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
-
ofGrayRgb
This is a shortcut forrgb(gray, gray, gray)
.- Parameters:
gray
- the gray component, in the range0-255
- Returns:
- the
Color
-
ofGrayRgb
This is a shortcut forrgb(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
-
ofGray
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
-
ofGray
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
-
ofHsb
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
-
of
-
red
public double red()The red component of theColor
, in the range0.0-1.0
. If you want to get the red component in the range0-255
, use theColor.getRed()
method.- Returns:
- the red component of the
Color
, in the range0.0-1.0
- See Also:
-
green
public double green()The green component of theColor
, in the range0.0-1.0
. If you want to get the green component in the range0-255
, use theColor.getGreen()
method.- Returns:
- the green component of the
Color
, in the range0.0-1.0
- See Also:
-
blue
public double blue()The blue component of theColor
, in the range0.0-1.0
. If you want to get the blue component in the range0-255
, use theColor.getBlue()
method.- Returns:
- the blue component of the
Color
, in the range0.0-1.0
- See Also:
-
opacity
public double opacity()The opacity of theColor
, in the range0.0-1.0
. If you want to get the opacity in the form of the alpha component in the range0-255
, use theColor.getAlpha()
method.- Returns:
- the opacity of the
Color
, in the range0.0-1.0
- See Also:
-
hue
public double hue()Gets the hue component of thisColor
.- Returns:
- Hue value in the range in the range
0.0-360.0
.
-
saturation
public double saturation()Gets the saturation component of thisColor
.- Returns:
- Saturation value in the range in the range
0.0-1.0
.
-
brightness
public double brightness()Gets the brightness component of thisColor
.- Returns:
- Brightness value in the range in the range
0.0-1.0
.
-
brighter
Creates a new color that is a brighter version of this color. -
brighterBy
Creates an updated color whose brightness is increased by the specified factor.- Parameters:
percentage
- The factor by which to increase the brightness.
-
darker
Creates a new color that is a darker version of this color. -
darkerBy
Creates an updated color whose brightness is decreased by the specified percentage factor.- Parameters:
percentage
- The factor by which to decrease the brightness.
-
saturate
Provides an updated color that is a more saturated version of this color. The color will be 30% more saturated than the original color.- Returns:
- A color that is a more saturated version of this color.
-
saturateBy
Creates a color which is saturated by the specified percentage factor. So the value0.0
will return the same color and the value and the value1.0
will return a fully saturated color.- Parameters:
percentage
- The percentage factor by which to increase the saturation.
-
desaturate
Creates a new color that is a less saturated version of this color. The color will be 30% less saturated than the original color.- Returns:
- A color that is a less saturated version of this color.
-
desaturateBy
Creates a color which is desaturated by the specified percentage factor. So the value0.0
will return the same color and the value and the value1.0
will return a fully desaturated color.- Parameters:
percentage
- The percentage factor by which to decrease the saturation.
-
grayscale
Creates an updated color that is grayscale equivalent of this color. Opacity is preserved.- Returns:
- A color that is grayscale equivalent of this color
-
invert
Creates a new color that is inversion of this color. Opacity is preserved.- Returns:
- A color that is inversion of this color.
-
withRed
Returns an updated version of this color with the red component changed to the specified value in the range0.0-1.0
. The number0.0
represents no red, and1.0
represents full red.- Parameters:
red
- The red component, in the range0.0-1.0
.- Returns:
- A new
Color
object with the red component changed. - Throws:
IllegalArgumentException
- If the value is out of range (0.0-1.0)- See Also:
-
withGreen
Returns an updated version of this color with the green component changed to the specified value in the range0.0-1.0
. A number of0.0
represents no green, and1.0
represents green to the maximum extent.- Parameters:
green
- The green component, in the range0.0-1.0
- Returns:
- A new
Color
object with the green component changed - Throws:
IllegalArgumentException
- If the value is out of range (0.0-1.0)- See Also:
-
withBlue
Returns an updated version of this color with the blue component changed to the specified value in the range0.0-1.0
. A value closer to0.0
represents no blue, and closer to1.0
represents blue to the maximum extent possible.- Parameters:
blue
- The blue component, in the range0.0-1.0
- Returns:
- A new
Color
object with the blue component changed - Throws:
IllegalArgumentException
- If the value is out of range (0.0-1.0)- See Also:
-
withOpacity
Returns an updated version of this color with the opacity changed to the specified value in the range0.0-1.0
. A value closer to0.0
represents a fully transparent color, and closer to1.0
represents a fully opaque color.- Parameters:
opacity
- The opacity component, in the range0.0-1.0
- Returns:
- A new
Color
object with the opacity changed - Throws:
IllegalArgumentException
- If the value is out of range (0.0-1.0)- See Also:
-
withAlpha
Creates and returns an updated version of this color with the alpha component changed to the specified value in the range0-255
. A value closer to0
represents a fully transparent color, and closer to255
represents a fully opaque color.- Parameters:
alpha
- The alpha component, in the range0-255
.- Returns:
- A new
Color
object with the alpha component changed
-
withHue
Returns an updated version of this color with the hue changed to the specified value in the range0.0-360.0
. A value closer to0.0
represents red, and closer to360.0
represents red again.- Parameters:
hue
- The hue component, in the range0.0-360.0
- Returns:
- A new
Color
object with the hue changed - Throws:
IllegalArgumentException
- If the value is out of range (0.0-360.0)- See Also:
-
withSaturation
Returns an updated version of this color with the saturation changed to the specified value in the range0.0-1.0
. A value closer to0.0
represents a shade of grey, and closer to1.0
represents a fully saturated color.- Parameters:
saturation
- The saturation component, in the range0.0-1.0
- Returns:
- A new
Color
object with the saturation changed - Throws:
IllegalArgumentException
- If the value is out of range (0.0-1.0)- See Also:
-
withBrightness
Returns an updated version of this color with the brightness changed to the specified value in the range0.0-1.0
. A value closer to0.0
represents black, and closer to1.0
represents white.- Parameters:
brightness
- The brightness component, in the range0.0-1.0
- Returns:
- A new
Color
object with the brightness changed - Throws:
IllegalArgumentException
- If the value is out of range (0.0-1.0)- See Also:
-