Colore JS

Search documentation

Find a function or jump to a section.
v2.0.1

adjustHue

adjustHue rotates a color around the OKLCH hue wheel. Lightness and chroma are kept before output, so you can explore another hue at the same starting intensity.

Example

import { colore } from 'colore-js';
import { adjustHue } from 'colore-js/fn';

colore('#0f766e').adjustHue(30).css(); // '#137286'
adjustHue('#0f766e', 30); // '#137286'

Syntax

colore(color).adjustHue(degrees: number): Color
adjustHue(color: ColorInput, degrees: number): string

Parameters

NameTypeDescription
colorColorInputAny supported CSS color, tagged color object, Color instance or packed RGB number.
degreesnumberAngle to add to the current hue. Negative values rotate the other way. Angles wrap into one turn.

Returns

The method returns a new Color. The standalone function returns a CSS string in hex, Display P3 or OKLCH according to the result’s gamut.

Throws

A ColorError if the color is invalid or the angle is nonfinite.

Rotate a hue through the start of the wheel

An angle can cross zero in either direction. A hue of 350° with a 30° rotation becomes 20°. Read OKLCH output to see the new angle directly.

import { colore } from 'colore-js';

colore('oklch(0.62 0.12 350)').adjustHue(30).oklch(); // 'oklch(0.62000 0.12000 20.00)'
colore('oklch(0.62 0.12 20)').adjustHue(-30).oklch(); // 'oklch(0.62000 0.12000 350.00)'

A rotation can put the new color outside the starting gamut. Use complement for a 180° partner fitted to the source sRGB or Display P3 gamut.