public class Color extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BLACK |
static int |
BLUE |
static int |
CYAN |
static int |
DKGRAY |
static int |
GRAY |
static int |
GREEN |
static int |
LTGRAY |
static int |
MAGENTA |
static int |
RED |
static int |
TRANSPARENT |
static int |
WHITE |
static int |
YELLOW |
Constructor and Description |
---|
Color() |
Modifier and Type | Method and Description |
---|---|
static int |
alpha(int color)
Return the alpha component of a color int.
|
static int |
argb(int alpha,
int red,
int green,
int blue)
Return a color-int from alpha, red, green, blue components.
|
static int |
blue(int color)
Return the blue component of a color int.
|
static void |
colorToHSV(int color,
float[] hsv)
Convert the argb color to its HSV components.
|
static int |
getHtmlColor(String color)
Converts an HTML color (named or numeric) to an integer RGB value.
|
static int |
green(int color)
Return the green component of a color int.
|
static int |
HSVToColor(float[] hsv)
Convert HSV components to an ARGB color.
|
static int |
HSVToColor(int alpha,
float[] hsv)
Convert HSV components to an ARGB color.
|
static float |
luminance(int color)
Returns the relative luminance of a color.
|
static int |
parseColor(String colorString)
Parse the color string, and return the corresponding color-int.
|
static int |
red(int color)
Return the red component of a color int.
|
static int |
rgb(int red,
int green,
int blue)
Return a color-int from red, green, blue components.
|
static void |
RGBToHSV(int red,
int green,
int blue,
float[] hsv)
Convert RGB components to HSV.
|
public static final int BLACK
public static final int DKGRAY
public static final int GRAY
public static final int LTGRAY
public static final int WHITE
public static final int RED
public static final int GREEN
public static final int BLUE
public static final int YELLOW
public static final int CYAN
public static final int MAGENTA
public static final int TRANSPARENT
public static int alpha(int color)
public static int red(int color)
public static int green(int color)
public static int blue(int color)
public static int rgb(int red, int green, int blue)
red
- Red component [0..255] of the colorgreen
- Green component [0..255] of the colorblue
- Blue component [0..255] of the colorpublic static int argb(int alpha, int red, int green, int blue)
alpha
- Alpha component [0..255] of the colorred
- Red component [0..255] of the colorgreen
- Green component [0..255] of the colorblue
- Blue component [0..255] of the colorpublic static float luminance(int color)
Assumes sRGB encoding. Based on the formula for relative luminance defined in WCAG 2.0, W3C Recommendation 11 December 2008.
public static int parseColor(String colorString)
public static void RGBToHSV(int red, int green, int blue, float[] hsv)
red
- red component value [0..255]green
- green component value [0..255]blue
- blue component value [0..255]hsv
- 3 element array which holds the resulting HSV components.public static void colorToHSV(int color, float[] hsv)
color
- the argb color to convert. The alpha component is ignored.hsv
- 3 element array which holds the resulting HSV components.public static int HSVToColor(float[] hsv)
hsv
- 3 element array which holds the input HSV components.public static int HSVToColor(int alpha, float[] hsv)
alpha
- the alpha component of the returned argb color.hsv
- 3 element array which holds the input HSV components.public static int getHtmlColor(String color)
color
- Non-null color string.-1
if the color string could not be interpreted.