Class Colors


  • public class Colors
    extends java.lang.Object
    Utility class for color-related operations and definitions.

    The Colors class provides utility methods and constants for working with colors in terminal applications. It includes color palettes, color name mappings, and methods for color parsing and conversion.

    This class defines standard color palettes for different terminal color modes:

    • 8 standard ANSI colors
    • 256-color indexed palette
    • Named color mappings (e.g., "red", "blue", "navy")

    It also provides methods for parsing color specifications in various formats, such as RGB hex codes, CSS-style color names, and indexed color references. These utilities help with consistent color handling across different terminal types and color capabilities.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double[] AdobeRGB_environment
      Adobe RGB environment
      static double[] averageSurrounding
      Average surrounding for CAM color spaces
      static int C
      Chroma
      static double[] D50
      D50 illuminant for CAM color spaces
      static double[] D65
      D65 illuminant for CAM color spaces
      static double[] darkSurrounding
      Dark surrounding for CAM color spaces
      static int[] DEFAULT_COLORS_256
      Default 256 colors palette
      static int[] DEFAULT_COLORS_88
      Default 88 colors palette
      static double[] dimSurrounding
      Dim surrounding for CAM color spaces
      static int h
      Hue
      static int H
      Hue Composition / Hue Quadrature
      static int J
      Lightness
      static int M
      Colorfulness
      static int Q
      Brightness
      static int s
      Saturation
      static double[] sRGB_encoding_environment
      sRGB encoding environment
      static double[] sRGB_typical_environment
      sRGB typical environment
    • Constructor Summary

      Constructors 
      Constructor Description
      Colors()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double[] CAT02toHPE​(double[] RGB)  
      static double[] rgb2cielab​(double[] rgb)  
      static int rgbColor​(int col)  
      static java.lang.Integer rgbColor​(java.lang.String name)  
      static int roundColor​(int col, int max)  
      static int roundColor​(int col, int max, java.lang.String dist)  
      static int roundRgbColor​(int r, int g, int b, int max)  
      static void setRgbColors​(int[] colors)  
      • Methods inherited from class java.lang.Object

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

      • DEFAULT_COLORS_256

        public static final int[] DEFAULT_COLORS_256
        Default 256 colors palette
      • DEFAULT_COLORS_88

        public static final int[] DEFAULT_COLORS_88
        Default 88 colors palette
      • D50

        public static final double[] D50
        D50 illuminant for CAM color spaces
      • D65

        public static final double[] D65
        D65 illuminant for CAM color spaces
      • averageSurrounding

        public static final double[] averageSurrounding
        Average surrounding for CAM color spaces
      • dimSurrounding

        public static final double[] dimSurrounding
        Dim surrounding for CAM color spaces
      • darkSurrounding

        public static final double[] darkSurrounding
        Dark surrounding for CAM color spaces
      • sRGB_encoding_environment

        public static final double[] sRGB_encoding_environment
        sRGB encoding environment
      • sRGB_typical_environment

        public static final double[] sRGB_typical_environment
        sRGB typical environment
      • AdobeRGB_environment

        public static final double[] AdobeRGB_environment
        Adobe RGB environment
    • Constructor Detail

      • Colors

        public Colors()
    • Method Detail

      • setRgbColors

        public static void setRgbColors​(int[] colors)
      • rgbColor

        public static int rgbColor​(int col)
      • rgbColor

        public static java.lang.Integer rgbColor​(java.lang.String name)
      • roundColor

        public static int roundColor​(int col,
                                     int max)
      • roundColor

        public static int roundColor​(int col,
                                     int max,
                                     java.lang.String dist)
      • roundRgbColor

        public static int roundRgbColor​(int r,
                                        int g,
                                        int b,
                                        int max)
      • CAT02toHPE

        public static double[] CAT02toHPE​(double[] RGB)
      • rgb2cielab

        public static double[] rgb2cielab​(double[] rgb)