Class ColorUtils


  • public class ColorUtils
    extends java.lang.Object
    Some methods for calculating colors.
    • Constructor Summary

      Constructors 
      Constructor Description
      ColorUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double alpha​(double color)
      Get the alpha value from a color value
      static int argb​(double color)
      Convert an color value as long into integer color value
      static int blue​(double color)
      Get the blue value from a color value
      static double getColor​(Expression param, CssFormatter formatter)
      Get the color value of the expression or fire an exception if not a color.
      static int green​(double color)
      Get the green value from a color value
      static double hsla​(HSL hsl)
      Create a color value.
      static int red​(double color)
      Get the red value from a color value
      static double rgb​(int r, int g, int b)
      Create an color value.
      static double rgba​(double r, double g, double b, double a)
      Create a color from rgba values
      static double rgba​(int r, int g, int b, double a)
      Create an color value.
      static HSL toHSL​(double color)
      Create a HSL color.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ColorUtils

        public ColorUtils()
    • Method Detail

      • toHSL

        public static HSL toHSL​(double color)
        Create a HSL color.
        Parameters:
        color - argb color
        Returns:
        the HSL
      • getColor

        public static double getColor​(Expression param,
                                      CssFormatter formatter)
                               throws LessException
        Get the color value of the expression or fire an exception if not a color.
        Parameters:
        param - the expression to evaluate
        formatter - current formatter
        Returns:
        the color value of the expression
        Throws:
        LessException - if the expression is not a color value
      • rgba

        public static double rgba​(double r,
                                  double g,
                                  double b,
                                  double a)
        Create a color from rgba values
        Parameters:
        r - red in range of 0 to 255.0
        g - green in range of 0 to 255.0
        b - blue in range of 0 to 255.0
        a - alpha in range of 0.0 to 1.0
        Returns:
        color value as long
      • rgba

        public static double rgba​(int r,
                                  int g,
                                  int b,
                                  double a)
        Create an color value.
        Parameters:
        r - red in range from 0 to 255
        g - green in range from 0 to 255
        b - blue in range from 0 to 255
        a - alpha in range from 0.0 to 1.0
        Returns:
        color value as long
      • rgb

        public static double rgb​(int r,
                                 int g,
                                 int b)
        Create an color value.
        Parameters:
        r - red in range from 0 to 255
        g - green in range from 0 to 255
        b - blue in range from 0 to 255
        Returns:
        color value as long
      • argb

        public static int argb​(double color)
        Convert an color value as long into integer color value
        Parameters:
        color - color value as long
        Returns:
        color value as int
      • alpha

        public static double alpha​(double color)
        Get the alpha value from a color value
        Parameters:
        color - color value as long
        Returns:
        the alpha in the range 0.0 to 1.0
      • red

        public static int red​(double color)
        Get the red value from a color value
        Parameters:
        color - color value as long
        Returns:
        the alpha in the range 0 to 255
      • green

        public static int green​(double color)
        Get the green value from a color value
        Parameters:
        color - color value as long
        Returns:
        the alpha in the range 0 to 255
      • blue

        public static int blue​(double color)
        Get the blue value from a color value
        Parameters:
        color - color value as long
        Returns:
        the alpha in the range 0 to 255
      • hsla

        public static double hsla​(HSL hsl)
        Create a color value.
        Parameters:
        hsl - a HSL value
        Returns:
        a color as long