oracle.cabo.image.painter
Class ColorUtils
java.lang.Object
|
+--oracle.cabo.image.painter.ColorUtils
- public class ColorUtils
- extends java.lang.Object
The ColorUtils Class includes class functions for performing operations
on colors.
Field Summary |
static int |
DEFAULT_LIGHTER_CHANGE
A good amount to modify a base color in order to calculate a lighter
color, equal to approximately 20% luminosity, when calling
getShadeColor(). |
static double |
NTSC_WEIGHT_BLUE
NTSC-specified weight to use for blue RGB component when converting to
luminance. |
static double |
NTSC_WEIGHT_GREEN
NTSC-specified weight to use for green RGB component when converting to
luminance. |
static double |
NTSC_WEIGHT_RED
NTSC-specified weight to use for red RGB component when converting to
luminance. |
Method Summary |
static int |
getApproximateLuminance(java.awt.Color color)
Returns the approximate luminosity of the color as an integer between 0
and 255, where 0 is black and 255 is white. |
static java.awt.Color |
shadeColor(java.awt.Color baseColor,
int change)
Given a base color, returns a new shade given a base color and an
amount to change. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NTSC_WEIGHT_RED
public static final double NTSC_WEIGHT_RED
- NTSC-specified weight to use for red RGB component when converting to
luminance.
NTSC_WEIGHT_GREEN
public static final double NTSC_WEIGHT_GREEN
- NTSC-specified weight to use for green RGB component when converting to
luminance.
NTSC_WEIGHT_BLUE
public static final double NTSC_WEIGHT_BLUE
- NTSC-specified weight to use for blue RGB component when converting to
luminance.
DEFAULT_LIGHTER_CHANGE
public static final int DEFAULT_LIGHTER_CHANGE
- A good amount to modify a base color in order to calculate a lighter
color, equal to approximately 20% luminosity, when calling
getShadeColor(). A good darker color can be found by using
-DEFAULT_LIGHTER_CHANGE.
ColorUtils
public ColorUtils()
getApproximateLuminance
public static int getApproximateLuminance(java.awt.Color color)
- Returns the approximate luminosity of the color as an integer between 0
and 255, where 0 is black and 255 is white. This approximation is
based on NTSC but rather than the NTSC contribution weights
(.299, .587, .144) for red, green, and blue, this uses (.25, .50, .25)
for speed.
- Parameters:
color
- The color to return the approximate luminance of.
shadeColor
public static java.awt.Color shadeColor(java.awt.Color baseColor,
int change)
- Given a base color, returns a new shade given a base color and an
amount to change. In order to avoid problems caused by clipping the
colors at either end of the luminosity range, shadeColor() uses
the base color's luminosity to determine how to modify the change amount
passed in.
- Parameters:
baseColor
- The color to return the new shade ofchange
- The proposed amount to change each component of the
baseColor. Depending on the baseColor's luminance, the actual
amount the baseColor's components are changed may differ. The valid range
for this value is -255 to 255.