triadic
triadic gives you three colors placed evenly around the OKLCH hue wheel. Colore fits the two partners into the starting gamut when the input fits sRGB or Display P3.
Example
import { colore } from 'colore-js';
import { triadic } from 'colore-js/fn';
colore('#7c3aed').triadic().map((color) => color.css()); // ["#7c3aed", "#ab5300", "#008269"]
triadic('#7c3aed'); // ["#7c3aed", "#ab5300", "#008269"]
Syntax
colore(color).triadic(): [Color, Color, Color]
triadic(color: ColorInput): [string, string, string]
Parameters
Returns
The tuple contains the input color first, then the colors at +120° and +240°. The method returns Color objects. The function returns CSS strings in the appropriate gamut.
Throws
A ColorError if the input color is invalid.
Build three accents from a Display P3 color
Give the brand the first slot and use its partners as accent candidates. Read the hue before formatting it as hex if the exact spacing matters.
import { colore } from 'colore-js';
const accents = colore('color(display-p3 1 0 0)').triadic();
accents.map((color) => Number(color.toOklch().h.toFixed(1))); // [29, 149, 269]
accents.every((color) => color.isInGamut('p3')); // true
Triadic hues give you a palette direction. For chart series with measured separation against a background, start with categoricalColors.
Related
- complement for a two-color pairing
- adjustHue to choose your own angle
- categoricalColors for chart series