Red channel (0–255).
Green channel (0–255).
Blue channel (0–255).
Optionala: number = 1
Alpha channel (0–1).
StaticfromStaticfromThe hex color string.
StaticfromHue, 0–360.
Saturation, 0–100.
Lightness, 0–100.
Optionala: number = 1
Alpha, 0–1.
StaticfromStaticfromThe color to compare against.
Optionaltolerance: number = 0
Maximum allowed difference per channel.
StaticinterpolateStaticgradientStaticcontrastStaticluminanceStaticbestStaticrandomFunction
random
Optionalsaturation: number | [number, number] = ...
Saturation percentage, or a [min, max]
range to pick one from.
Optionallightness: number | [number, number] = ...
Lightness percentage, or a [min, max]
range to pick one from.
The generated color.
Color
Description
Unified color class. Parses any CSS color string (hex, rgb/rgba, hsl/hsla), stores the color internally as RGBA, and provides conversions, interpolation, luminance, and contrast utilities. All channels are kept in sync: setting any of r/g/b/a/h/s/l/hex updates the rest automatically.