java.lang.Object
org.strassburger.colorlab4j.color.Color
org.strassburger.colorlab4j.color.spaces.HSLColor

public class HSLColor extends Color
Represents a color in the HSL color space
See Also:
  • Constructor Details

    • HSLColor

      public HSLColor(double h, double s, double l) throws IllegalArgumentException
      Parameters:
      h - Hue value (Degrees, 0-360)
      s - Saturation value (Fraction, 0.0-1.0)
      l - Lightness value (Fraction, 0.0-1.0)
      Throws:
      IllegalArgumentException - If any of the values are out of range
  • Method Details

    • getHue

      public double getHue()
      Get the hue value of the color (Degrees, 0-360)
      Returns:
      Hue value
    • getSaturation

      public double getSaturation()
      Get the saturation value of the color (Fraction, 0.0-1.0)
      Returns:
      Saturation value
    • getLightness

      public double getLightness()
      Get the lightness value of the color (Fraction, 0.0-1.0)
      Returns:
      Lightness value
    • toRGB

      public RGBColor toRGB()
      Description copied from class: Color
      Convert the color to RGB
      Specified by:
      toRGB in class Color
      Returns:
      RGB representation of the color
    • toHSL

      public HSLColor toHSL()
      Description copied from class: Color
      Convert the color to HSL
      Specified by:
      toHSL in class Color
      Returns:
      HSL representation of the color
    • toHSV

      public HSVColor toHSV()
      Description copied from class: Color
      Convert the color to HSV
      Specified by:
      toHSV in class Color
      Returns:
      HSV representation of the color
    • toLAB

      public LABColor toLAB()
      Description copied from class: Color
      Convert the color to LAB
      Specified by:
      toLAB in class Color
      Returns:
      LAB representation of the color
    • toXYZ

      public XYZColor toXYZ()
      Description copied from class: Color
      Convert the color to XYZ
      Specified by:
      toXYZ in class Color
      Returns:
      XYZ representation of the color
    • toCssString

      public String toCssString()
      Description copied from class: Color
      Get the CSS representation of the color
      Specified by:
      toCssString in class Color
      Returns:
      CSS representation of the color
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromHex

      public static HSLColor fromHex(String hex) throws IllegalArgumentException
      Get the HSL representation of a color from a hex string
      Parameters:
      hex - Hex representation of the color (e.g. "#ff0000")
      Returns:
      HSL representation of the color
      Throws:
      IllegalArgumentException - If the HEX code is invalid