public interface Color
If all the components except alpha are at zero and the alpha is at 1, the
result is black. If all are at 1, the result is the brightest representable white.
Important: the component values out of the 0..1 range are not allowed and
should not be used.
| Modifier and Type | Interface and Description |
|---|---|
static class |
Color.Builder
A builder of
Color. |
| Modifier and Type | Method and Description |
|---|---|
default float |
alpha()
Returns the opacity channel value in the
0..1 range. |
default float |
blue()
Returns the blue channel value in the
0..1 range. |
default float |
green()
Returns the green channel value in the
0..1 range. |
default boolean |
isValid()
Returns
true if this color is a valid color. |
static Color.Builder |
newBuilder()
Creates a new
Color builder with the given required parameters. |
default float |
red()
Returns the red channel value in the
0..1 range. |
static Color |
rgb(float red,
float green,
float blue)
Creates a new
Color instance from the passed RGB values with opacity (alpha)
channel set to 1 (non-transparent). |
static Color |
rgba(float red,
float green,
float blue,
float alpha)
Creates a new
Color instance from the passed RGBA values. |
default java.lang.String |
toHexRGB()
Returns a string representation for this color in the
#RGB hex format. |
default java.lang.String |
toHexRGBA()
Returns a string representation for this color in the
#RGBA hex format. |
static Color.Builder newBuilder()
Color builder with the given required parameters.Color.Builder instancestatic Color rgba(float red, float green, float blue, float alpha)
Color instance from the passed RGBA values.red - the red channel value in the 0..1 rangegreen - the green channel value in the 0..1 rangeblue - the blue channel value in the 0..1 rangealpha - the opacity channel value in the 0..1 rangeColor instancejava.lang.IllegalArgumentException - if any of the passed values is out
of the 0..1 rangestatic Color rgb(float red, float green, float blue)
Color instance from the passed RGB values with opacity (alpha)
channel set to 1 (non-transparent).red - the red channel value in the 0..1 rangegreen - the green channel value in the 0..1 rangeblue - the blue channel value in the 0..1 rangeColor instancejava.lang.IllegalArgumentException - if any of the passed values is out
of the 0..1 rangedefault boolean isValid()
true if this color is a valid color. The color is valid only if its channel
values are in the 0..1 range.default java.lang.String toHexRGBA()
#RGBA hex format.java.lang.IllegalArgumentException - when this color is invaliddefault java.lang.String toHexRGB()
#RGB hex format.java.lang.IllegalArgumentException - when this color is invaliddefault float alpha()
0..1 range. When the value is 1, the color
is 100% opaque. When 0, the color is 100% transparent.default float blue()
0..1 range.default float green()
0..1 range.default float red()
0..1 range.