public class ColorHSL
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
hue
The Hue HSL component (if computed, -1 otherwise).
|
private int |
luminosity
The Luminosity HSL component (if computed, -1 otherwise).
|
private int |
saturation
The Saturation HSL component (if computed, -1 otherwise).
|
Constructor and Description |
---|
ColorHSL()
Default constructor.
|
ColorHSL(int hue,
int saturation,
int luminosity)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Reports if the given object is the same color as this instance.
|
static ColorHSL |
fromRGB(ColorRgb rgbColor)
Computes the HSL values from the objects RGB.
|
int |
getHue()
Obtains hue value from HSL color space.
|
int |
getLuminosity()
Obtains luminosity value from HSL color space.
|
int |
getSaturation()
Obtains saturation value from HSL color space.
|
int |
hashCode()
Calculate hash code compatible with equals()
|
private float |
hue2rgb(float p,
float q,
float t)
Internal worker method used by
toRGB() method. |
void |
setHue(int hue)
Sets hue value from HSL color space.
|
void |
setLuminosity(int luminosity)
Sets luminosity value from HSL color space.
|
void |
setSaturation(int saturation)
Sets hue value from HSL color space.
|
ColorRgb |
toRGB()
Convert the current color from HSL color space to RGB.
|
private int hue
private int saturation
private int luminosity
public ColorHSL()
public ColorHSL(int hue, int saturation, int luminosity)
hue
- The hue.saturation
- The saturation.luminosity
- The luminosity.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- The object to compare.true
if the objects are equivalent, false
if the given instance is
null
, is not an instance of this class or if its HSL value is not
equivalent.public int hashCode()
hashCode
in class java.lang.Object
public int getHue()
public int getSaturation()
public int getLuminosity()
public void setHue(int hue)
hue
- the hue value in 0-240 interval.public void setSaturation(int saturation)
saturation
- the saturation value in 0-240 interval.public void setLuminosity(int luminosity)
luminosity
- the luminosity value in 0-240 interval.public static ColorHSL fromRGB(ColorRgb rgbColor)
public ColorRgb toRGB()
ColorRgb
object representing the same color but in RGB.private float hue2rgb(float p, float q, float t)
toRGB()
method.p
- Intermediary result in HSL to RGB conversion.q
- Intermediary result in HSL to RGB conversion.t
- Intermediary result in HSL to RGB conversion.