|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.levigo.util.base.Colors
public class Colors
A bunch of static utility methods useful in conjunction with colors.
Method Summary | |
---|---|
static Color |
alpha(Color c,
float alpha)
Create a new color identical to the given one, but having its alpha value replaced with the given one. |
static Color |
alpha(Color c,
int alpha)
Create a new color identical to the given one, but having its alpha value replaced with the given one. |
static Color |
alphaComposite(Color fg,
Color bg)
Composite two colors using alpha compositing. |
static Color |
fromHSB(float[] hsl)
Convert the given color in the HSB (sometimes called HSL) color model into a Color in
the color space sRGB. |
static Color |
fromHSB(float h,
float s,
float b)
Convert the given color in the HSB (sometimes called HSL) color model into a Color in
the color space sRGB. |
static Color |
invert(Color c)
Create a new color which is the inverse of the given one. |
static float |
luminance(Color c)
Return the color's luminance normalized to the range [0,1]. |
static float |
luminanceContrast(Color c1,
Color c2)
Return luminance contrast between the two colors normalized to the range [0,1]. |
static Color |
optimizeContrastColor(Color color,
Color background,
int minimumContrastPercent)
|
static Color |
optimizeContrastColorNoAlpha(Color color,
Color background,
int minimumContrastPercent)
This is an experimental new contrast optimization strategy. |
static Color |
optimizeForegroundContrast(Color fg,
Color bg)
Optimize the contrast of the foreground color against the background by inverting it, if inversion leads to a higher contrast. |
static Color |
parseColor(String colorString)
|
static float[] |
toHSL(Color c)
Convert the given color to the HSB (sometimes called HSL) color model. |
static String |
toHtml(Color c)
Convert the given RGB(A) color into an HTML color code of the Form #[6 or 8 hex digits] . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Color alpha(Color c, int alpha)
c
- alpha
-
public static Color alpha(Color c, float alpha)
c
- alpha
-
public static Color alphaComposite(Color fg, Color bg)
fg
- the foreground colorbg
- the background color
public static float luminance(Color c)
c
-
public static float luminanceContrast(Color c1, Color c2)
c1
- first colorc2
- second color
public static Color invert(Color c)
c
- public static Color optimizeForegroundContrast(Color fg, Color bg)
fg
- the foreground colorbg
- the background color
public static Color optimizeContrastColorNoAlpha(Color color, Color background, int minimumContrastPercent)
color
- background
- minimumContrastPercent
-
public static Color optimizeContrastColor(Color color, Color background, int minimumContrastPercent)
public static float[] toHSL(Color c)
c
- public static Color fromHSB(float[] hsl)
Color
in
the color space sRGB. The given values must be normalized to the range [0,1].
hsl
- the HSL componentspublic static Color fromHSB(float h, float s, float b)
Color
in
the color space sRGB. The given values must be normalized to the range [0,1].
h
- hues
- saturationb
- brightnesspublic static Color parseColor(String colorString)
public static String toHtml(Color c)
#[6 or 8 hex digits]
. The conversion will automatically include the alpha channel
(8 hex digits) or not (6 digits) depending on whether the color has transparency (
Color.getTransparency()
).
c
- the color
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |