public class LCHColor extends java.lang.Object implements RColor
fill(myLchObject.getColor());The difference between multiple color objects can be calculated with the methods of ColorDifference class.
| Modifier and Type | Field and Description |
|---|---|
static float |
MAX_C
The maximal chroma value any LCH color can have (approximation).
|
static ColorSpace |
NAME
The ColorSpace of RGB colors.
|
| Constructor and Description |
|---|
LCHColor(float... channels)
Creates a new LCHColor object.
|
LCHColor(java.lang.Float l,
java.lang.Float c,
java.lang.Float h)
Creates a new opaque LCHColor object.
|
LCHColor(java.lang.Float l,
java.lang.Float c,
java.lang.Float h,
java.lang.Float alpha)
Creates a new LCHColor object.
|
| Modifier and Type | Method and Description |
|---|---|
LCHColor |
copy()
Creates a deep copy of the object.
|
boolean |
equals(RColor other)
Checks if the input color is equal to this object.
|
java.lang.Float |
getAlpha()
Returns the value of alpha / transparency.
|
java.lang.Float |
getChroma()
Returns the current value of chroma of this color.
|
int |
getColor()
Returns a int representation of the current color.
|
ColorSpace |
getColorSpace()
Returns the color space of the color.
|
java.lang.String |
getHexString()
Returns a String representation of the current color using hexadecimal
numbers.
|
java.lang.Float |
getHue()
Returns the current value of hue of this color.
|
static java.lang.Float |
getLoss(RColor rvMean,
java.util.ArrayList<RColor> lColors,
ColorDifferenceMeasure m)
Calculates the loss - the mean distance of all members of colors to
rvMean.
|
static java.lang.Float |
getLoss(RColor rvMean,
java.util.ArrayList<RColor> lColors,
ColorDifferenceMeasure m,
int start,
int end)
Calculates the loss - the mean distance of all members of colors to
rvMean.
|
static java.lang.Float |
getLoss(RColor rvMean,
RColor[] colors,
ColorDifferenceMeasure m)
Calculates the loss - the mean distance of all members of colors to
rvMean.
|
static java.lang.Float |
getLoss(RColor rvMean,
RColor[] colors,
ColorDifferenceMeasure m,
int start,
int end)
Calculates the loss - the mean distance of all members of colors to
rvMean.
|
java.lang.Float |
getLuminance()
Returns the current value of luminance of this color.
|
static LCHColor |
getMeanColor(java.util.ArrayList<RColor> colors)
Calculates the mean color of the input colors
|
static LCHColor |
getMeanColor(int start,
int end,
java.util.ArrayList<RColor> colors)
Calculates the mean color of the input colors.
|
static LCHColor |
getMeanColor(int start,
int end,
RColor... colors)
Calculates the mean color of the input colors.
|
static LCHColor |
getMeanColor(RColor... colors)
Calculates the mean color of the input colors
|
java.lang.String |
getName()
Returns the name of the color space e.g.
|
int |
getOpColor()
Returns a int representation of the current color - but ignoring the
alpha value.
|
java.lang.String |
getOpHexString()
Returns a String representation of the current color using hexadecimal
numbers.
|
static LCHColor |
getRandomLCH()
Creates a new opaque LabColor with random values.
|
float[] |
getValues()
Returns the color values of the current object.
|
float[] |
getValuesNormalized()
Returns the normalized color values of the current object.
|
static LCHColor |
lerpColors(RColor input1,
RColor input2,
float amt)
Lerps the two input colors and creates a new color.
|
LCHColor |
setAlpha(java.lang.Float alpha)
Sets the value of alpha / transparency.
|
LCHColor |
setAlpha(int alpha)
Sets the value of alpha / transparency.
|
LCHColor |
setChroma(java.lang.Float c)
Sets the chroma value.
|
LCHColor |
setChroma(int c)
Sets the chroma value.
|
LCHColor |
setHue(java.lang.Float h)
Sets the hue value.
|
LCHColor |
setHue(int h)
Sets the hue value.
|
LCHColor |
setLuminance(java.lang.Float l)
Sets the luminance value.
|
LCHColor |
setLuminance(int l)
Sets the luminance value.
|
HSBColor |
toHSB()
Returns a HSBColor representation of the current color.
|
LabColor |
toLab()
Returns a LabColor representation of the current color.
|
LCHColor |
toLCH()
Returns a LCHColor representation of the current color.
|
RGBColor |
toRGB()
Returns a RGBColor representation of the current color.
|
java.lang.String |
toString() |
XYZColor |
toXYZ()
Returns a XYZColor representation of the current color.
|
public static final ColorSpace NAME
public static final float MAX_C
public LCHColor(java.lang.Float l,
java.lang.Float c,
java.lang.Float h)
l - The luminance value [0, 100]c - The chroma value [0, 133.45]h - The hue value [0, 360]public LCHColor(java.lang.Float l,
java.lang.Float c,
java.lang.Float h,
java.lang.Float alpha)
l - The luminance value [0, 100]c - The chroma value [0, 133.45]h - The hue value [0, 360]alpha - THe alpha value [0, 100]public LCHColor(float... channels)
channels - Either [l,c, h] or [l, c, h, alpha].public int getColor()
RColorHSBColor hsb = new HSBColor(244, 100, 100); fill(hsb.getColor());
public LCHColor setAlpha(java.lang.Float alpha)
RColorpublic LCHColor setAlpha(int alpha)
alpha - The value of the colors transparency.public java.lang.Float getAlpha()
RColorpublic LCHColor setLuminance(java.lang.Float l)
l - The new luminance value [0, 100].public LCHColor setLuminance(int l)
l - The new luminance value [0, 100].public LCHColor setHue(java.lang.Float h)
h - The new hue value [0, 360].public LCHColor setHue(int h)
h - The new hue value [0, 360].public LCHColor setChroma(java.lang.Float c)
c - The new chroma value [0, 133.45].public LCHColor setChroma(int c)
c - The new chroma value [0, 133.45].public java.lang.Float getLuminance()
public java.lang.Float getHue()
public java.lang.Float getChroma()
public java.lang.String getHexString()
RColorRGBColor rgb = new RGBColor(255, 0, 128, 0); rgb.getHexString(); // "00FF0080"
getHexString in interface RColorpublic int getOpColor()
RColorHSBColor hsb = new HSBColor(244, 100, 100, 50); fill(hsb.getOpColor());
getOpColor in interface RColorpublic java.lang.String getOpHexString()
RColorRGBColor rgb = new RGBColor(255, 0, 128, 0); rgb.getOpHexString(); // "FF0080"
getOpHexString in interface RColorpublic float[] getValues()
RColorpublic float[] getValuesNormalized()
RColorgetValuesNormalized in interface RColorpublic java.lang.String getName()
RColorpublic ColorSpace getColorSpace()
RColorgetColorSpace in interface RColorpublic LCHColor copy()
RColorpublic boolean equals(RColor other)
public java.lang.String toString()
toString in class java.lang.Objectpublic static LCHColor getMeanColor(RColor... colors)
colors - Colors.public static LCHColor getMeanColor(java.util.ArrayList<RColor> colors)
colors - Colors.public static LCHColor getMeanColor(int start, int end, RColor... colors)
start - Start index of the subset of the input colors (start < end).
start will be member of the subset.end - End index of the subset of the input colors (start < end). end
will not be member of the subset.colors - Colors (1 or more).public static LCHColor getMeanColor(int start, int end, java.util.ArrayList<RColor> colors)
start - Start index of the subset of the input colors (start < end).
start will be member of the subset.end - End index of the subset of the input colors (start < end). end
will not be member of the subset.colors - Colors.public static java.lang.Float getLoss(RColor rvMean, RColor[] colors, ColorDifferenceMeasure m)
rvMean - A base color which will be used to calculate the distance to.colors - Colors.m - The measure which defines how the loss is calculated and which
color model will be used. This should be an RGB color
difference measure.public static java.lang.Float getLoss(RColor rvMean, RColor[] colors, ColorDifferenceMeasure m, int start, int end)
rvMean - A base color which will be used to calculate the distance to.colors - Colors.m - The measure which defines how the loss is calculated and which
color model will be used. This should be an RGB color
difference measure.start - Start index of the subset of the input colors (start < end).
start will be member of the subset.end - End index of the subset of the input colors (start < end). end
will not be member of the subset.public static java.lang.Float getLoss(RColor rvMean, java.util.ArrayList<RColor> lColors, ColorDifferenceMeasure m)
rvMean - A base color which will be used to calculate the distance to.lColors - Colors.m - The measure which defines how the loss is calculated and which
color model will be used. This should be an RGB color
difference measure.public static java.lang.Float getLoss(RColor rvMean, java.util.ArrayList<RColor> lColors, ColorDifferenceMeasure m, int start, int end)
rvMean - A base color which will be used to calculate the distance to.lColors - Colors.m - The measure which defines how the loss is calculated and which
color model will be used. This should be an RGB color
difference measure.start - Start index of the subset of the input colors (start < end).
start will be member of the subset.end - End index of the subset of the input colors (start < end). end
will not be member of the subset.public static LCHColor lerpColors(RColor input1, RColor input2, float amt)
input1 - The first color.input2 - The second color.amt - The lerping value [0, 1].public static LCHColor getRandomLCH()
public RGBColor toRGB()
RColorpublic HSBColor toHSB()
RColorpublic XYZColor toXYZ()
RColorpublic LabColor toLab()
RColor