API
@pbroom/color-kit/hct
Material HCT conversion, gamut limits and tonal helpers.
6 exports3 values3 types
@pbroom/color-kit/hct answers gamut questions in Material Design's HCT space: CAM16
hue and chroma with L* tone, the space Material's tonal palettes are built
in. The root @pbroom/color-kit entry re-exports the same functions.
Domains
- Chroma limits.
maxHctChromaAtTonereturns the largest chroma sRGB can realize at a hue and tone. - Hue peaks.
maxHctChromaForHuereturns the peak chroma of a hue and the tone where it occurs;maxHctPeakToneForHuereturns just the tone. Both interpolate a cached per-hue lookup table by default (method: 'lut') and search tone directly withmethod: 'direct'.
Conversion lives in the root entry: toHct and
fromHct convert between Color and
{ h, c, t, alpha }. fromHct uses Material's solver, which reduces chroma
to fit sRGB, so its results are always in sRGB and quantized to 8 bits.
import { maxHctChromaAtTone, maxHctChromaForHue } from '@pbroom/color-kit/hct';
maxHctChromaForHue(250); // → { c: ≈ 61.71, t: ≈ 64.22 }
maxHctChromaAtTone(250, 90); // → ≈ 21.00, light tones hold little chromaUse these limits to build HCT tonal ramps that ask only for chroma sRGB can
deliver, instead of letting fromHct reduce it silently.
HCT
- function
maxHctChromaForHueResolve the HCT hue peak: the maximum realized HCT chroma for a hue and the fractional tone where that peak occurs. - function
maxHctPeakToneForHueConvenience helper for the tone component of maxHctChromaForHue(...). - function
maxHctChromaAtToneReturns the maximum HCT chroma realizable at a given hue and tone. - interface
HctHuePeakThe chroma peak of an HCT hue, returned by maxHctChromaForHue. - type
MaxHctChromaForHueMethodHow maxHctChromaForHue resolves the peak: 'lut' interpolates a cached hue lookup table, 'direct' searches tone per call. - interface
MaxHctChromaForHueOptionsOptions for maxHctChromaForHue and maxHctPeakToneForHue.