Class CssColorSpecUtil

java.lang.Object
de.larsgrefer.sass.embedded.util.CssColorSpecUtil

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

    Modifier and Type
    Method
    Description
    static double[]
    hslToRgb(double hue, double sat, double light)
    Converts the given HSL color to RGB.
    static double[]
    hwbToRgb(double hue, double white, double black)
    Converts the given HWB color to RGB.
    static double[]
    rgbToHsl(double red, double green, double blue)
    Converts the given RGB color to HSL.
    static double[]
    rgbToHwb(double red, double green, double blue)
    Converts the given HWB color to RGB.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • 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:
    • 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:
    • 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:
    • 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: