public class LabColor extends java.lang.Object implements RColor
fill(myLabObject.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_A
The maximal a value any Lab color can have (approximation).
|
static float |
MAX_B
The maximal b value any Lab color can have (approximation).
|
static float |
MAX_L
The maximal luminance value any Lab color can have.
|
static float |
MIN_A
The minimal a value any Lab color can have (approximation).
|
static float |
MIN_B
The minimal b value any Lab color can have (approximation).
|
static float |
MIN_L
The minimal luminance value any Lab color can have.
|
static ColorSpace |
NAME
The ColorSpace of RGB colors.
|
| Constructor and Description |
|---|
LabColor(float... channels)
Creates a new LabColor object.
|
LabColor(java.lang.Float l,
java.lang.Float a,
java.lang.Float b)
Creates a new opaque LabColor object.
|
LabColor(java.lang.Float l,
java.lang.Float a,
java.lang.Float b,
java.lang.Float alpha)
Creates a new LabColor object.
|
| Modifier and Type | Method and Description |
|---|---|
LabColor |
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 |
getA()
Returns the current value of a of this color.
|
java.lang.Float |
getAlpha()
Returns the value of alpha / transparency.
|
java.lang.Float |
getB()
Returns the current value of b of this color.
|
java.lang.Float |
getChroma()
Returns the current value of chroma of this color (equivalent to the
chroma value of this color's LCH conversion).
|
static float |
getChroma(java.lang.Float a,
java.lang.Float b)
Calculates the chroma value of a given set of a and b values.
|
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 (equivalent to the hue
value of this color's LCH conversion).
|
static float |
getHue(double a,
double b)
Calculates the hue value of a given set of a and b values.
|
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.
|
float |
getLuminance()
Returns the current value of luminance of this color.
|
static LabColor |
getMeanColor(java.util.ArrayList<RColor> colors)
Calculates the mean color of the input colors
|
static LabColor |
getMeanColor(int start,
int end,
java.util.ArrayList<RColor> colors)
Calculates the mean color of the input colors.
|
static LabColor |
getMeanColor(int start,
int end,
RColor... colors)
Calculates the mean color of the input colors.
|
static LabColor |
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 LabColor |
getRandomLab()
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 LabColor |
lerpColors(RColor input1,
RColor input2,
float amt)
Lerps the two input colors and creates a new color.
|
LabColor |
setA(java.lang.Float a)
Sets the a value.
|
LabColor |
setA(int a)
Sets the a value.
|
LabColor |
setAlpha(java.lang.Float alpha)
Sets the value of alpha / transparency.
|
LabColor |
setAlpha(int alpha)
Sets the value of alpha / transparency.
|
LabColor |
setB(java.lang.Float b)
Sets the b value.
|
LabColor |
setB(int b)
Sets the b value.
|
LabColor |
setLuminance(java.lang.Float l)
Sets the luminance value.
|
LabColor |
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 MIN_L
public static final float MAX_L
public static final float MIN_A
public static final float MAX_A
public static final float MIN_B
public static final float MAX_B
public LabColor(java.lang.Float l,
java.lang.Float a,
java.lang.Float b)
l - The luminance value [0, 100]a - The a value [-86, 98]b - The b value [-107.6, 94.6]public LabColor(java.lang.Float l,
java.lang.Float a,
java.lang.Float b,
java.lang.Float alpha)
l - The luminance value [0, 100]a - The a value [-86, 98]b - The b value [-107.6, 94.6]alpha - THe alpha value [0, 100]public LabColor(float... channels)
channels - Either [l, a, b] or [l, a, b, alpha].public int getColor()
RColorHSBColor hsb = new HSBColor(244, 100, 100); fill(hsb.getColor());
public LabColor setAlpha(java.lang.Float alpha)
RColorpublic LabColor setAlpha(int alpha)
alpha - The value of the colors transparency.public java.lang.Float getAlpha()
RColorpublic LabColor setLuminance(java.lang.Float l)
l - The new luminance value [0, 100].public LabColor setLuminance(int l)
l - The new luminance value [0, 100].public LabColor setA(java.lang.Float a)
a - The new a value [-86, 98].public LabColor setA(int a)
a - The new a value [-86, 98].public LabColor setB(java.lang.Float b)
b - The new a value [-107.6, 94.6].public LabColor setB(int b)
b - The new a value [-107.6, 94.6].public float getLuminance()
public java.lang.Float getA()
public java.lang.Float getB()
public java.lang.Float getChroma()
public java.lang.Float getHue()
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 LabColor copy()
RColorpublic boolean equals(RColor other)
public java.lang.String toString()
toString in class java.lang.Objectpublic static LabColor getMeanColor(RColor... colors)
colors - Colors (1 or more).public static LabColor getMeanColor(java.util.ArrayList<RColor> colors)
colors - Colors.public static LabColor 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 LabColor 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 Lab 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 Lab 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 Lab 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 Lab 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 LabColor lerpColors(RColor input1, RColor input2, float amt)
input1 - The first color.input2 - The second color.amt - The lerping value [0, 1].public static LabColor getRandomLab()
public static float getChroma(java.lang.Float a,
java.lang.Float b)
a - The a value (e.g. getA() of any Lab color)b - The b value (e.g. getB() of any Lab color)public static float getHue(double a,
double b)
a - The a value (e.g. getA() of any Lab color)b - The b value (e.g. getB() of any Lab color)public RGBColor toRGB()
RColorpublic HSBColor toHSB()
RColorpublic XYZColor toXYZ()
RColorpublic LabColor toLab()
RColor