Package graphics
Class HSLColor
java.lang.Object
graphics.HSLColor
Azurite
Represents a HSLA color.- Since:
- 14.07.2021
- Author:
- Juyas
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
float
get
(int component) Get a component of this color.static HSLColor
getHSLColor
(float x, float y, float z, float a, int inputType) int
hashCode()
void
set
(int component, float newValue) Set a component of this color.static float[]
toHSLA
(float[] rgba) Convert a RGBA color to it corresponding HSLA color.org.joml.Vector4f
Create aVector4f
containing the HSLA values.org.joml.Vector3f
Create aVector3f
containing the HSL values.static float[]
toRGBA
(float[] hsla) Convert a HSLA color to RGBA.
-
Field Details
-
HUE
public static final int HUE- See Also:
-
SATURATION
public static final int SATURATION- See Also:
-
LUMINANCE
public static final int LUMINANCE- See Also:
-
ALPHA
public static final int ALPHA- See Also:
-
-
Constructor Details
-
HSLColor
public HSLColor(float h, float s, float l, float a) Create a HSLColor.- Parameters:
h
- the hue ranging from 0 to 360, values outside get smoothly fit into the ranges
- the saturation ranging from 0 to 100, values are limited to this rangel
- the luminance ranging from 0 to 100, values are limited to this rangea
- the alpha ranging from 0 to 1, values are limited to this range
-
-
Method Details
-
getHSLColor
-
toHSLA
public static float[] toHSLA(float[] rgba) Convert a RGBA color to it corresponding HSLA color. RGBA ranges are [0-1,0-1,0-1,0-1]. HSLA output ranges are [0-360,0-100,0-100,0-1].- Parameters:
rgba
- a float array containing [r,g,b,a], where a is an optional parameter- Returns:
- normalized hsla array [h,s,l,a]
-
toRGBA
public static float[] toRGBA(float[] hsla) Convert a HSLA color to RGBA. HSLA ranges are [0-360,0-100,0-100,0-1]. RGBA output ranges are [0-1,0-1,0-1,0-1]. If there is no alpha in the input, there won't be an alpha in the output as well.- Parameters:
hsla
- a float array containing [h,s,l,a], where a is an optional parameter- Returns:
- normalized rgba array [r,g,b,a]
-
toRGBColor
- Returns:
- a RGB
Color
representing the same color
-
toNormalizedRGBColor
- Returns:
- a normalized RGB
Color
representing the same color
-
set
public void set(int component, float newValue) Set a component of this color.- Parameters:
component
- the component from 0-3. Named representations areHUE
,SATURATION
,LUMINANCE
andALPHA
newValue
- the new value for the component
-
get
public float get(int component) Get a component of this color.- Parameters:
component
- the component from 0-3. Named representations areHUE
,SATURATION
,LUMINANCE
andALPHA
- Returns:
- the value of the component
-
toHSLVector
public org.joml.Vector3f toHSLVector()Create aVector3f
containing the HSL values.- Returns:
- a vector containing (h,s,l)
-
toHSLAVector
public org.joml.Vector4f toHSLAVector()Create aVector4f
containing the HSLA values.- Returns:
- a vector containing (h,s,l,a)
-
equals
-
hashCode
public int hashCode()
-