public class HSBColor extends java.lang.Object implements RColor
fill(myHsbObject.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 |
|---|
HSBColor(float... channels)
Creates a new HSBColor object.
|
HSBColor(java.lang.Float h,
java.lang.Float s,
java.lang.Float b)
Creates a new opaque HSBColor object.
|
HSBColor(java.lang.Float h,
java.lang.Float s,
java.lang.Float b,
java.lang.Float alpha)
Creates a new HSBColor object.
|
| Modifier and Type | Method and Description |
|---|---|
HSBColor |
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 |
getBrightness()
Returns the current value of brightness 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.
|
static HSBColor |
getMeanColor(java.util.ArrayList<RColor> colors)
Calculates the mean color of the input colors
|
static HSBColor |
getMeanColor(int start,
int end,
java.util.ArrayList<RColor> colors)
Calculates the mean color of the input colors.
|
static HSBColor |
getMeanColor(int start,
int end,
RColor... colors)
Calculates the mean color of the input colors.
|
static HSBColor |
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 HSBColor |
getRandomHSB()
Creates a new opaque HSBColor with random values.
|
java.lang.Float |
getSaturation()
Returns the current value of saturation 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 HSBColor |
lerpColors(RColor input1,
RColor input2,
float amt)
Lerps the two input colors and creates a new color.
|
HSBColor |
setAlpha(java.lang.Float alpha)
Sets the value of alpha / transparency.
|
HSBColor |
setAlpha(int alpha)
Sets the value of alpha / transparency.
|
HSBColor |
setBrightness(java.lang.Float b)
Sets the hue value.
|
HSBColor |
setBrightness(int b)
Sets the hue value.
|
HSBColor |
setHue(java.lang.Float h)
Sets the hue value.
|
HSBColor |
setHue(int h)
Sets the hue value.
|
HSBColor |
setSaturation(java.lang.Float s)
Sets the saturation value.
|
HSBColor |
setSaturation(int s)
Sets the saturation value.
|
HSBColor |
toHSB()
Returns a HSBColor representation of the current color.
|
static HSBColor |
toHSB(int hex)
Creates an opaque HSBColor by the given input value.
|
static HSBColor |
toHSB(int hex,
float alpha)
Creates HSBColor with transparency by the given input value.
|
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 HSBColor(java.lang.Float h,
java.lang.Float s,
java.lang.Float b)
h - The hue value [0, 360]s - The saturation value [0, 100]b - The brightness value [0, 100]public HSBColor(java.lang.Float h,
java.lang.Float s,
java.lang.Float b,
java.lang.Float alpha)
h - The hue value [0, 360]s - The saturation value [0, 100]b - The brightness value [0, 100]alpha - THe alpha value [0, 100]public HSBColor(float... channels)
channels - Either [h, s, b] or [h, s, b, alpha].public int getColor()
RColorHSBColor hsb = new HSBColor(244, 100, 100); fill(hsb.getColor());
public HSBColor setAlpha(java.lang.Float alpha)
RColorpublic HSBColor setAlpha(int alpha)
alpha - The value of the colors transparency.public java.lang.Float getAlpha()
RColorpublic HSBColor setHue(int h)
h - The new hue value [0, 360].public HSBColor setHue(java.lang.Float h)
h - The new hue value [0, 360].public HSBColor setSaturation(int s)
s - The new saturation value [0, 100].public HSBColor setSaturation(java.lang.Float s)
s - The new saturation value [0, 100].public HSBColor setBrightness(int b)
b - The new brightness value [0, 100].public HSBColor setBrightness(java.lang.Float b)
b - The new brightness value [0, 100].public java.lang.Float getHue()
public java.lang.Float getSaturation()
public java.lang.Float getBrightness()
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 java.lang.String getName()
RColorpublic ColorSpace getColorSpace()
RColorgetColorSpace in interface RColorpublic float[] getValues()
RColorpublic float[] getValuesNormalized()
RColorgetValuesNormalized in interface RColorpublic HSBColor copy()
RColorpublic boolean equals(RColor other)
public java.lang.String toString()
toString in class java.lang.Objectpublic static HSBColor getMeanColor(RColor... colors)
colors - Colors (1 or more).public static HSBColor getMeanColor(java.util.ArrayList<RColor> colors)
colors - Colors.public static HSBColor 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 HSBColor 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 HSB 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 HSB 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 HSB 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 HSB 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 HSBColor lerpColors(RColor input1, RColor input2, float amt)
input1 - The first color.input2 - The second color.amt - The lerping value [0, 1].public static HSBColor getRandomHSB()
public static HSBColor toHSB(int hex)
color c1 = color(255, 0, 0); color c2 = #FF0000; HSBColor hsb1 = HSBColor.toHSB(c1); HSBColor hsb2 = HSBColor.toHSB(c2);
hex - The color value.public static HSBColor toHSB(int hex, float alpha)
color c1 = color(255, 0, 0, 120); color c2 = #FF0000; HSBColor hsb1 = HSBColor.toHSB(c1, alpha(c1) / 2.55); HSBColor hsb2 = HSBColor.toHSB(c2, 120);
hex - The color value.alpha - The transparency value.public RGBColor toRGB()
RColorpublic HSBColor toHSB()
RColorpublic XYZColor toXYZ()
RColorpublic LabColor toLab()
RColor