public class RGBColor extends java.lang.Object implements RColor
fill(myRGBObject.getColor());The difference between multiple color objects can be calculated with the methods of ColorDifference class.
| Modifier and Type | Field and Description |
|---|---|
static ColorSpace |
NAME
The ColorSpace of RGB colors.
|
| Constructor and Description |
|---|
RGBColor(float... channels)
Creates a new RGBColor object.
|
RGBColor(java.lang.Float r,
java.lang.Float g,
java.lang.Float b)
Creates a new opaque RGBColor object.
|
RGBColor(java.lang.Float r,
java.lang.Float g,
java.lang.Float b,
java.lang.Float alpha)
Creates a new RGBColor object.
|
| Modifier and Type | Method and Description |
|---|---|
RGBColor |
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 |
getBlue()
Returns the current value of blue of this color.
|
int |
getColor()
Returns a int representation of the current color.
|
ColorSpace |
getColorSpace()
Returns the color space of the color.
|
java.lang.Float |
getGreen()
Returns the current value of green of this color.
|
java.lang.String |
getHexString()
Returns a String representation of the current color using hexadecimal
numbers.
|
static java.lang.Float |
getLoss(RColor rvMean,
java.util.ArrayList<RColor> colors,
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> colors,
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.
|
static RGBColor |
getMeanColor(java.util.ArrayList<RColor> colors)
Calculates the mean color of the input colors
|
static RGBColor |
getMeanColor(int start,
int end,
java.util.ArrayList<RColor> colors)
Calculates the mean color of the input colors.
|
static RGBColor |
getMeanColor(int start,
int end,
RColor... colors)
Calculates the mean color of the input colors.
|
static RGBColor |
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 RGBColor |
getRandomRGB()
Creates a new opaque RGBColor with random values.
|
java.lang.Float |
getRed()
Returns the current value of red of this color.
|
float[] |
getValues()
Returns the color values of the current object.
|
float[] |
getValuesNormalized()
Returns the normalized color values of the current object.
|
static RGBColor |
lerpColors(RColor input1,
RColor input2,
float amt)
Lerps the two input colors and creates a new color.
|
RGBColor |
set(int hex)
Sets the channel values by the given color.
|
RGBColor |
setAlpha(java.lang.Float alpha)
Sets the value of alpha / transparency.
|
RGBColor |
setAlpha(int alpha)
Sets the value of alpha / transparency.
|
RGBColor |
setBlue(java.lang.Float b)
Sets the blue value.
|
RGBColor |
setBlue(int b)
Sets the blue value.
|
RGBColor |
setGreen(java.lang.Float g)
Sets the green value.
|
RGBColor |
setGreen(int g)
Sets the green value.
|
RGBColor |
setRed(java.lang.Float r)
Sets the red value.
|
RGBColor |
setRed(int r)
Sets the red value.
|
HSBColor |
toHSB()
Returns a HSBColor representation of the current color.
|
static HSBColor |
toHSB(float... paramters)
Creates HSBColor with given RGB values.
|
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.
|
static RGBColor |
toRGB(java.lang.Integer hex)
Creates an opaque RGBColor by the given input value.
|
static RGBColor |
toRGB(java.lang.Integer hex,
float alpha)
Creates RGBColor with transparency by the given input value.
|
java.lang.String |
toString() |
XYZColor |
toXYZ()
Returns a XYZColor representation of the current color.
|
public static final ColorSpace NAME
public RGBColor(java.lang.Float r,
java.lang.Float g,
java.lang.Float b)
r - The red value [0, 255]g - The green value [0, 255]b - The blue value [0, 255]public RGBColor(java.lang.Float r,
java.lang.Float g,
java.lang.Float b,
java.lang.Float alpha)
r - The red value [0, 255]g - The green value [0, 255]b - The blue value [0, 255]alpha - THe alpha value [0, 255]public RGBColor(float... channels)
channels - Either [gray], [gray, alpha] or [r, g, b] or [r, g, b, alpha].public int getColor()
RColorHSBColor hsb = new HSBColor(244, 100, 100); fill(hsb.getColor());
public RGBColor setAlpha(java.lang.Float alpha)
RColorpublic RGBColor setAlpha(int alpha)
alpha - The value of the colors transparency.public java.lang.Float getAlpha()
RColorpublic RGBColor setRed(java.lang.Float r)
r - The new red value [0, 255].public RGBColor set(int hex)
hex - The new color of this object. Should be in range of
000000-FFFFFF.public RGBColor setRed(int r)
r - The new red value [0, 255].public RGBColor setGreen(java.lang.Float g)
g - The new green value [0, 255].public RGBColor setGreen(int g)
g - The new green value [0, 255].public RGBColor setBlue(java.lang.Float b)
b - The new blue value [0, 255].public RGBColor setBlue(int b)
b - The new blue value [0, 255].public java.lang.Float getRed()
public java.lang.Float getGreen()
public java.lang.Float getBlue()
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 RGBColor copy()
RColorpublic boolean equals(RColor other)
public java.lang.String toString()
toString in class java.lang.Objectpublic static RGBColor getMeanColor(RColor... colors)
colors - Colors (1 or more).public static RGBColor getMeanColor(java.util.ArrayList<RColor> colors)
colors - Colors.public static RGBColor 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 RGBColor 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> 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, java.util.ArrayList<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 RGBColor lerpColors(RColor input1, RColor input2, float amt)
input1 - The first color.input2 - The second color.amt - The lerping value [0, 1].public static RGBColor getRandomRGB()
public static RGBColor toRGB(java.lang.Integer hex)
color c1 = color(255, 0, 0); color c2 = #FF0000; RGBColor rgb1 = RGBColor.toRGB(c1); RGBColor rgb2 = RGBColor.toRGB(c2);
hex - The color value.public static RGBColor toRGB(java.lang.Integer hex, float alpha)
color c1 = color(255, 0, 0, 120); color c2 = #FF0000; RGBColor rgb1 = RGBColor.toRGB(c1, alpha(c1)); RGBColor rgb2 = RGBColor.toRGB(c2, 120);
hex - The color value.alpha - The transparency value.public static HSBColor toHSB(float... paramters)
HSBColor hsb = RGBColor.toHSB(255.0, 0, 255.0);
paramters - Either [gray], [gray, alpha] or [r, g, b] or [r, g, b, alpha].public RGBColor toRGB()
RColorpublic HSBColor toHSB()
RColorpublic XYZColor toXYZ()
RColorpublic LabColor toLab()
RColor