Class HSLColor

    • Constructor Detail

      • HSLColor

        public HSLColor​(int hue,
                        double saturation,
                        double lightness)
        Creates an HSL color with the specified hue in the range (0-359), and saturation, and lightness component values in the range (0.0-1.0).
        Parameters:
        hue - The hue component as an integer value in the range (0-359).
        saturation - The saturation component in the range (0.0-1.0).
        lightness - The lightness component in the range (0.0-1.0).
        Throws:
        java.lang.IllegalArgumentException - if the hue is outside the range (0-359), and/or if one of the other values is outside the range (0.0-1.0).
      • HSLColor

        public HSLColor​(double hue,
                        double saturation,
                        double lightness)
        Creates an HSL color with the specified hue, saturation, and lightness component values in the range (0.0-1.0).
        Parameters:
        hue - The hue component.
        saturation - The saturation component.
        lightness - The lightness component.
        Throws:
        java.lang.IllegalArgumentException - if one of the values is outside the range (0.0-1.0).
    • Method Detail

      • getHue

        public double getHue()
        Returns:
        The hue component value.
      • getHueDegrees

        public double getHueDegrees()
        Determines the value of the hue in degrees in the range (0.0-360.0]. For example, retrieving a hue with value 0.5 would produce 180.
        Returns:
        The absolute value of the hue in degrees.
      • getSaturation

        public double getSaturation()
        Returns:
        The saturation component value.
      • getLightness

        public double getLightness()
        Returns:
        The lightness component value.
      • asHSL

        public HSLColor asHSL()
        Returns:
        The color in the HSL color space.
      • asRGB

        public RGBColor asRGB()
        Returns:
        The color in the RGB color space.
      • valueOf

        public static HSLColor valueOf​(java.lang.CharSequence charSequence)
        Creates an HSL color from a string representation. This representation can be in one of the following forms:
        • hsl(hue,saturation,lightness), with decimal representation with a depth of eight bits (0-255).
        • hsl(hue%,saturation%,lightness%), with decimal component values multiplied by 100 (0.0-100.0%).
        Parameters:
        charSequence - The character sequence representation of an HSL color.
        Returns:
        An RGB color object representing the color represented by the given string.
        Throws:
        java.lang.NullPointerException - if the given string is null.
        java.lang.IllegalArgumentException - if a color cannot be determined from the given string.