public class HSLColor extends Object
The HUE is the color, the Saturation is the purity of the color (with respect to grey) and Luminance is the brightness of the color (with respect to black and white)
The Hue is specified as an angel between 0 - 360 degrees where red is 0, green is 120 and blue is 240. In between you have the colors of the rainbow. Saturation is specified as a percentage between 0 - 100 where 100 is fully saturated and 0 approaches gray. Luminance is specified as a percentage between 0 - 100 where 0 is black and 100 is white.
In particular the HSL color space makes it easier change the Tone or Shade of a color by adjusting the luminance value.
| Constructor and Description |
|---|
HSLColor(Color rgb)
Create a HSLColor object using an RGB Color object.
|
HSLColor(float[] hsl)
Create a HSLColor object using an an array containing the individual HSL values and with a
default alpha value of 1.
|
HSLColor(float[] hsl,
float alpha)
Create a HSLColor object using an an array containing the individual HSL values.
|
HSLColor(float h,
float s,
float l)
Create a HSLColor object using individual HSL values and a default alpha value of 1.0.
|
HSLColor(float h,
float s,
float l,
float alpha)
Create a HSLColor object using individual HSL values.
|
| Modifier and Type | Method and Description |
|---|---|
Color |
adjustHue(float degrees)
Create a RGB Color object based on this HSLColor with a different Hue value.
|
Color |
adjustLuminance(float percent)
Create a RGB Color object based on this HSLColor with a different Luminance value.
|
Color |
adjustSaturation(float percent)
Create a RGB Color object based on this HSLColor with a different Saturation value.
|
Color |
adjustShade(float percent)
Create a RGB Color object based on this HSLColor with a different Shade.
|
Color |
adjustTone(float percent)
Create a RGB Color object based on this HSLColor with a different Tone.
|
static float[] |
fromRGB(Color color)
Convert a RGB Color to it corresponding HSL values.
|
float |
getAlpha()
Get the Alpha value.
|
Color |
getComplementary()
Create a RGB Color object that is the complementary color of this HSLColor.
|
float[] |
getHSL()
Get the HSL values.
|
float |
getHue()
Get the Hue value.
|
float |
getLuminance()
Get the Luminance value.
|
Color |
getRGB()
Get the RGB Color object represented by this HDLColor.
|
float |
getSaturation()
Get the Saturation value.
|
static Color |
toRGB(float[] hsl)
Convert HSL values to a RGB Color with a default alpha value of 1.
|
static Color |
toRGB(float[] hsl,
float alpha)
Convert HSL values to a RGB Color.
|
static Color |
toRGB(float h,
float s,
float l)
Convert HSL values to a RGB Color with a default alpha value of 1.
|
static Color |
toRGB(float h,
float s,
float l,
float alpha)
Convert HSL values to a RGB Color.
|
String |
toString() |
public HSLColor(Color rgb)
rgb - the RGB Color objectpublic HSLColor(float h,
float s,
float l)
h - is the Hue value in degrees between 0 - 360s - is the Saturation percentage between 0 - 100l - is the Lumanance percentage between 0 - 100public HSLColor(float h,
float s,
float l,
float alpha)
h - the Hue value in degrees between 0 - 360s - the Saturation percentage between 0 - 100l - the Lumanance percentage between 0 - 100alpha - the alpha value between 0 - 1public HSLColor(float[] hsl)
hsl - array containing HSL valuespublic HSLColor(float[] hsl,
float alpha)
hsl - array containing HSL valuesalpha - the alpha value between 0 - 1public Color adjustHue(float degrees)
degrees - - the Hue value between 0 - 360public Color adjustLuminance(float percent)
percent - - the Luminance value between 0 - 100public Color adjustSaturation(float percent)
percent - - the Saturation value between 0 - 100public Color adjustShade(float percent)
percent - - the value between 0 - 100public Color adjustTone(float percent)
percent - - the value between 0 - 100public float getAlpha()
public Color getComplementary()
public float getHue()
public float[] getHSL()
public float getLuminance()
public Color getRGB()
public float getSaturation()
public static float[] fromRGB(Color color)
color - the RBG color to convertpublic static Color toRGB(float[] hsl)
hsl - an array containing the 3 HSL valuespublic static Color toRGB(float[] hsl, float alpha)
hsl - an array containing the 3 HSL valuesalpha - the alpha value between 0 - 1public static Color toRGB(float h, float s, float l)
h - Hue is specified as degrees in the range 0 - 360.s - Saturation is specified as a percentage in the range 1 - 100.l - Lumanance is specified as a percentage in the range 1 - 100.public static Color toRGB(float h, float s, float l, float alpha)
h - Hue is specified as degrees in the range 0 - 360.s - Saturation is specified as a percentage in the range 1 - 100.l - Lumanance is specified as a percentage in the range 1 - 100.alpha - the alpha value between 0 - 1Copyright © 2019–2022 Dominokit. All rights reserved.