Class ColourUtils


  • public class ColourUtils
    extends Object
    Color manipulation utilities
    Since:
    5.0
    • Field Detail

      • EPSILON

        public static final Double EPSILON
    • Constructor Detail

      • ColourUtils

        public ColourUtils()
    • Method Detail

      • colorToHex

        public static String colorToHex​(Color color)
        Returns hexadecimal value for a color.
        Parameters:
        color - color object
        Returns:
        color hexadecimal value
      • hexToColor

        public static Color hexToColor​(String hexColor)
        Given a color hexadecimal value returns a Color object.
        Parameters:
        hexColor - color hexadecimal value
        Returns:
        Color object
      • darken

        public static String darken​(String hexColor,
                                    double amount)
        Returns a color darker than the given color
        Parameters:
        hexColor - color hexadecimal value
        amount - value between 0 and 100.
        Returns:
        darker color
      • lighten

        public static String lighten​(String hexColor,
                                     double amount)
        Returns a color lighter than the given color
        Parameters:
        hexColor - color hexadecimal value
        amount - value between 0 and 100.
        Returns:
        lighter color
      • saturate

        public static String saturate​(String hexColor,
                                      double amount)
        Returns a color more saturated than the given color
        Parameters:
        hexColor - color hexadecimal value
        amount - value between 0 and 100.
        Returns:
        saturated color
      • desaturate

        public static String desaturate​(String hexColor,
                                        double amount)
        Returns a color less saturate than the given color
        Parameters:
        hexColor - color hexadecimal value
        amount - value between 0 and 100.
        Returns:
        desaturated color
      • darken

        public static Color darken​(Color color,
                                   double amount)
        Returns a color darker than the given color
        Parameters:
        color - color onject
        amount - value between 0 and 100.
        Returns:
        darker color
      • lighten

        public static Color lighten​(Color color,
                                    double amount)
        Returns a color lighter than the given color
        Parameters:
        color - color object
        amount - value between 0 and 100.
        Returns:
        lighter color
      • desaturate

        public static Color desaturate​(Color color,
                                       double amount)
        Returns a color less saturate than the given color
        Parameters:
        color - color object
        amount - value between 0 and 100.
        Returns:
        desaturated color
      • saturate

        public static Color saturate​(Color color,
                                     double amount)
        Returns a color more saturated than the given color
        Parameters:
        color - color object
        amount - value between 0 and 100.
        Returns:
        saturated color
      • toHSL

        public static float[] toHSL​(Color color)
        Returns the color value in the HSL space
        Parameters:
        color - color object
        Returns:
        { hue, saturation, lightness, alpha }
      • hslToRgb

        public static int[] hslToRgb​(float[] hsl)
        Returns the color value in the RGB space
        Parameters:
        hsl - color in hsl space
        Returns:
        rgb values [0, 255]