Class TonalPalette
java.lang.Object
org.pushingpixels.ephemeral.chroma.palettes.TonalPalette
- All Implemented Interfaces:
BaseTonalPalette
A convenience class for retrieving colors that are constant in hue and chroma, but vary in tone.
TonalPalette is intended for use in a single thread due to its stateful caching.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classKey color is a color that represents the hue and chroma of a tonal palette. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate intaverageArgb(int argb1, int argb2) static TonalPaletteCreate tones using a HCT color.static TonalPalettefromHueAndChroma(double hue, double chroma) Create tones from a defined HCT hue and chroma.static TonalPalettefromInt(int argb) Create tones using the HCT hue and chroma from a color.doubleThe chroma of the Tonal Palette, in HCT.getHct(double tone) Given a tone, use hue and chroma of palette to create a color, and return it as HCT.doublegetHue()The hue of the Tonal Palette, in HCT.The key color is the first tone, starting from T50, that matches the palette's chroma.inttone(int tone) Create an ARGB color with HCT hue and chroma of this Tones instance, and the provided HCT tone.
-
Field Details
-
cache
-
keyColor
-
hue
private final double hue -
chroma
private final double chroma
-
-
Constructor Details
-
TonalPalette
-
-
Method Details
-
fromInt
Create tones using the HCT hue and chroma from a color.- Parameters:
argb- ARGB representation of a color- Returns:
- Tones matching that color's hue and chroma.
-
fromHct
Create tones using a HCT color.- Parameters:
hct- HCT representation of a color.- Returns:
- Tones matching that color's hue and chroma.
-
fromHueAndChroma
Create tones from a defined HCT hue and chroma.- Parameters:
hue- HCT huechroma- HCT chroma- Returns:
- Tones matching hue and chroma.
-
tone
public int tone(int tone) Create an ARGB color with HCT hue and chroma of this Tones instance, and the provided HCT tone.- Specified by:
tonein interfaceBaseTonalPalette- Parameters:
tone- HCT tone, measured from 0 to 100.- Returns:
- ARGB representation of a color with that tone.
-
averageArgb
private int averageArgb(int argb1, int argb2) -
getHct
Given a tone, use hue and chroma of palette to create a color, and return it as HCT.- Specified by:
getHctin interfaceBaseTonalPalette
-
getChroma
public double getChroma()The chroma of the Tonal Palette, in HCT. Ranges from 0 to ~130 (for sRGB gamut). -
getHue
public double getHue()The hue of the Tonal Palette, in HCT. Ranges from 0 to 360. -
getKeyColor
The key color is the first tone, starting from T50, that matches the palette's chroma.
-