java.io.Serializable
public class Color
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Class | Description |
---|---|---|
static class |
Color.Hue |
Constructor | Description |
---|---|
Color(int colorCode) |
|
Color(int r,
int g,
int b) |
|
Color(int red,
int green,
int blue,
double alpha) |
Create a color based on Red, Green, Blue and Alpha channel.
|
Color(java.lang.String rgb) |
Modifier and Type | Method | Description |
---|---|---|
Color |
blendWith(Color otherColor) |
|
Color |
blendWith(Color thatColor,
int thatPercent) |
Blend this color with that color
|
Color |
brighter() |
|
Color |
brighter(double factor) |
Build a color brighter from a given color
|
double |
constrastWith(Color thatColor) |
Return the contrast (from 0.0 to 1.0) with that color
|
static Color |
createFromHsl(int hue,
int saturation,
int lightness) |
Create a color, from HSB instead of RGB values
|
Color |
darker() |
|
Color |
darker(double factor) |
Build a color darker from a given color
|
boolean |
equals(java.lang.Object o) |
|
static Color |
fromString(java.lang.String value) |
Converts a string formatted as #ff00ff to a Color instance.
|
int |
getBlue() |
|
int |
getBrightness() |
Get brightness
|
float[] |
getCMYK() |
Convert RGB to CMYK values.
|
Color |
getComplimentaryColor() |
Return the complimentary color.
|
Color |
getContrastColor() |
Return black or white, depending which color gives the highest contrast.
|
Color |
getGrayscale() |
Return the grayscale of a color.
|
int |
getGreen() |
|
java.lang.String |
getHexCode() |
|
int |
getHue() |
Get the hue of a color.
|
Color.Hue |
getHueCode() |
|
int |
getRed() |
|
int |
getSaturation() |
Get saturation
|
int |
getValue() |
|
int |
hashCode() |
|
float[] |
toHSB() |
Convert RGB components to HSB (hue, saturation, brightness)
|
java.lang.String |
toRGBAString() |
Represents a color as a RGBA string, that can be used in HTML.
|
java.lang.String |
toRGBString() |
Represents a color as a RGB string, that can be used in HTML.
|
java.lang.String |
toString() |
public Color(int red, int green, int blue, double alpha)
red
- in the range 0..255green
- in the range 0..255blue
- in the range 0..255alpha
- in the range 0.0 1.0 (default value 1.0)public Color(int r, int g, int b)
public Color(int colorCode)
public Color(java.lang.String rgb)
public int getRed()
public int getGreen()
public int getBlue()
public int getValue()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getHexCode()
public java.lang.String toRGBString()
public java.lang.String toRGBAString()
public static Color fromString(java.lang.String value)
value
- public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public Color getGrayscale()
public Color brighter(double factor)
factor
- from 1.0 to 100.0 (1.2 default)public Color brighter()
public Color darker(double factor)
factor
- from 1.0 to 100.0 (1.2 default)public Color darker()
public double constrastWith(Color thatColor)
thatColor
- public Color getContrastColor()
public Color getComplimentaryColor()
public Color blendWith(Color thatColor, int thatPercent)
thatColor
- the color to blend withthatPercent
- the percentage of the color to blend (default value : 50)public float[] toHSB()
public int getHue()
public int getSaturation()
public int getBrightness()
public float[] getCMYK()
public static Color createFromHsl(int hue, int saturation, int lightness)
hue
- saturation
- lightness
- public Color.Hue getHueCode()