Package graphics

Class HSLColor

java.lang.Object
graphics.HSLColor

public class HSLColor extends Object

Azurite

Represents a HSLA color.
Since:
14.07.2021
Author:
Juyas
  • Field Details

  • 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 range
      s - the saturation ranging from 0 to 100, values are limited to this range
      l - the luminance ranging from 0 to 100, values are limited to this range
      a - the alpha ranging from 0 to 1, values are limited to this range
  • Method Details

    • getHSLColor

      public static HSLColor getHSLColor(float x, float y, float z, float a, int inputType)
    • 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

      public Color toRGBColor()
      Convert this HSLColor to a RGB Color using toRGBA(float[])
      Returns:
      a RGB Color representing the same color
    • toNormalizedRGBColor

      public Color toNormalizedRGBColor()
      Convert this HSLColor to a normalized RGB Color using toRGBA(float[])
      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 are HUE, SATURATION, LUMINANCE and ALPHA
      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 are HUE, SATURATION, LUMINANCE and ALPHA
      Returns:
      the value of the component
    • toHSLVector

      public org.joml.Vector3f toHSLVector()
      Create a Vector3f containing the HSL values.
      Returns:
      a vector containing (h,s,l)
    • toHSLAVector

      public org.joml.Vector4f toHSLAVector()
      Create a Vector4f containing the HSLA values.
      Returns:
      a vector containing (h,s,l,a)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object