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

public class LABColor extends Color
Represents a color in the LAB (CIELAB) color space
See Also:
  • Constructor Details

    • LABColor

      public LABColor(double l, double a, double b) throws IllegalArgumentException
      Parameters:
      l - Lightness value (0-100)
      a - a value (-128-128)
      b - b value (-128-128)
      Throws:
      IllegalArgumentException - If any of the values are out of range
  • Method Details

    • getL

      public double getL()
      Get the lightness value of the color (0-100)
      Returns:
      Lightness value
    • getA

      public double getA()
      Get the a value of the color (Red-Green axis) (-128-128)
      Returns:
      a value
    • getB

      public double getB()
      Get the b value of the color (Yellow-Blue axis) (-128-128)
      Returns:
      b 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 LABColor fromHex(String hex) throws IllegalArgumentException
      Get the LAB representation of a color from a hex string
      Parameters:
      hex - Hex representation of the color (e.g. "#ff0000")
      Returns:
      LAB representation of the color
      Throws:
      IllegalArgumentException - If the HEX code is invalid