Class Hct
- java.lang.Object
-
- org.pushingpixels.ephemeral.chroma.hct.Hct
-
public final class Hct extends java.lang.ObjectHCT, 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.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateHct(int argb)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Hctfrom(double hue, double chroma, double tone)Create an HCT color from hue, chroma, and tone.static HctfromInt(int argb)Create an HCT color from a color.doublegetChroma()doublegetHue()doublegetTone()HctinViewingConditions(ViewingConditions vc)Translate a color into different ViewingConditions.static booleanisBlue(double hue)static booleanisCyan(double hue)static booleanisYellow(double hue)voidsetChroma(double newChroma)Set the chroma of this color.voidsetHue(double newHue)Set the hue of this color.private voidsetInternalState(int argb)voidsetTone(double newTone)Set the tone of this color.inttoInt()
-
-
-
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)
-
-