Class Hct


  • public final class Hct
    extends java.lang.Object
    HCT, hue, chroma, and tone. A color system that provides a perceptually accurate color measurement system that can also accurately render what colors will appear as in different lighting environments.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int argb  
      private double chroma  
      private double hue  
      private double tone  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Hct​(int argb)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Hct from​(double hue, double chroma, double tone)
      Create an HCT color from hue, chroma, and tone.
      static Hct fromInt​(int argb)
      Create an HCT color from a color.
      double getChroma()  
      double getHue()  
      double getTone()  
      Hct inViewingConditions​(ViewingConditions vc)
      Translate a color into different ViewingConditions.
      static boolean isBlue​(double hue)  
      static boolean isCyan​(double hue)  
      static boolean isYellow​(double hue)  
      void setChroma​(double newChroma)
      Set the chroma of this color.
      void setHue​(double newHue)
      Set the hue of this color.
      private void setInternalState​(int argb)  
      void setTone​(double newTone)
      Set the tone of this color.
      int toInt()  
      • Methods inherited from class java.lang.Object

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

      • hue

        private double hue
      • chroma

        private double chroma
      • tone

        private double tone
      • argb

        private int argb
    • Constructor Detail

      • Hct

        private Hct​(int argb)
    • Method Detail

      • from

        public static Hct from​(double hue,
                               double chroma,
                               double tone)
        Create an HCT color from hue, chroma, and tone.
        Parameters:
        hue - 0 <= hue < 360; invalid values are corrected.
        chroma - 0 <= chroma < ?; Informally, colorfulness. The color returned may be lower than the requested chroma. Chroma has a different maximum for any given hue and tone.
        tone - 0 <= tone <= 100; invalid values are corrected.
        Returns:
        HCT representation of a color in default viewing conditions.
      • fromInt

        public static Hct fromInt​(int argb)
        Create an HCT color from a color.
        Parameters:
        argb - ARGB representation of a color.
        Returns:
        HCT representation of a color in default viewing conditions
      • getHue

        public double getHue()
      • getChroma

        public double getChroma()
      • getTone

        public double getTone()
      • toInt

        public int toInt()
      • setHue

        public void setHue​(double newHue)
        Set the hue of this color. Chroma may decrease because chroma has a different maximum for any given hue and tone.
        Parameters:
        newHue - 0 <= newHue < 360; invalid values are corrected.
      • setChroma

        public void setChroma​(double newChroma)
        Set the chroma of this color. Chroma may decrease because chroma has a different maximum for any given hue and tone.
        Parameters:
        newChroma - 0 <= newChroma < ?
      • setTone

        public void setTone​(double newTone)
        Set the tone of this color. Chroma may decrease because chroma has a different maximum for any given hue and tone.
        Parameters:
        newTone - 0 <= newTone <= 100; invalid valids are corrected.
      • isBlue

        public static boolean isBlue​(double hue)
      • isYellow

        public static boolean isYellow​(double hue)
      • isCyan

        public static boolean isCyan​(double hue)
      • inViewingConditions

        public Hct inViewingConditions​(ViewingConditions vc)
        Translate a color into different ViewingConditions.

        Colors change appearance. They look different with lights on versus off, the same color, as in hex code, on white looks different when on black. This is called color relativity, most famously explicated by Josef Albers in Interaction of Color.

        In color science, color appearance models can account for this and calculate the appearance of a color in different settings. HCT is based on CAM16, a color appearance model, and uses it to make these calculations.

        See ViewingConditions.make for parameters affecting color appearance.

      • setInternalState

        private void setInternalState​(int argb)