Class CssColorSpecUtil


  • public final class CssColorSpecUtil
    extends Object
    This class contains the color-conversion algorithms found in the CSS Color Specification.
    See Also:
    CSS Color Module Level 4
    • Method Detail

      • hslToRgb

        public static double[] hslToRgb​(double hue,
                                        double sat,
                                        double light)
        Converts the given HSL color to RGB.
        Parameters:
        hue - Hue as degrees: 0..360
        sat - Saturation as percentage: 0..100
        light - Lightness as percentage: 0..100
        Returns:
        Array of RGB values: 0..1
        See Also:
        8.1. Converting HSL Colors to sRGB
      • rgbToHsl

        public static double[] rgbToHsl​(double red,
                                        double green,
                                        double blue)
        Converts the given RGB color to HSL.
        Parameters:
        red - Red component of the color, normalized to 0..1.
        green - Green component of the color, normalized to 0..1.
        blue - Blue component of the color, normalized to 0..1.
        Returns:
        Array of HSL values. Hue as degrees (0..360), Saturation and Lightness as percentages (0..100)
        See Also:
        8.2. Converting sRGB Colors to HSL
      • hwbToRgb

        public static double[] hwbToRgb​(double hue,
                                        double white,
                                        double black)
        Converts the given HWB color to RGB.
        Parameters:
        hue - Hue as degrees: 0..360
        white - Whiteness as percentage: 0..100
        black - Blackness as percentage: 0..100
        Returns:
        Array of RGB values: 0..1
        See Also:
        9.1. Converting HWB Colors to sRGB
      • rgbToHwb

        public static double[] rgbToHwb​(double red,
                                        double green,
                                        double blue)
        Converts the given HWB color to RGB.
        Parameters:
        red - Red component of the color, normalized to 0..1.
        green - Green component of the color, normalized to 0..1.
        blue - Blue component of the color, normalized to 0..1.
        Returns:
        Array of HWB values. Hue as degrees 0..360, Whiteness and Blackness as percentages (0..100).
        See Also:
        9.2. Converting sRGB Colors to HWB