complement
complement finds the hue opposite a color on the OKLCH wheel. It keeps lightness and fits chroma to the source gamut for an sRGB or Display P3 input.
Example
import { colore } from 'colore-js';
import { complement } from 'colore-js/fn';
colore('#7c3aed').complement().css(); // '#707600'
complement('#7c3aed'); // '#707600'
Syntax
colore(color).complement(): Color
complement(color: ColorInput): string
Parameters
Returns
The method returns a new Color. The function returns a CSS string. A partner may fit sRGB even when the input was written in Display P3.
Throws
A ColorError if the input color is invalid.
Find a partner for a brand color
Start with a brand hue and use its opposite as a candidate accent. A color wheel pairing can give you a palette direction. Check the accent against the background where it will appear.
import { colore } from 'colore-js';
const blue = colore('blue');
blue.complement().css(); // '#6e5000'
blue.complement().isInGamut('srgb'); // true
blue.adjustHue(180).isInGamut('srgb'); // false
adjustHue(180) keeps the original chroma through the rotation. Use it if you want to keep that chroma and choose an output gamut later.
Related
- adjustHue for an unfitted rotation
- triadic for three hues spaced evenly
- Gamut and CSS output to choose a display format