Skip to content

hslToHSV

Converts HSL to HSV by routing through RGB. Useful when adapting between APIs that prefer one or the other.

Importing

ts
import { hslToHSV } from '@basmilius/utils';

Usage

ts
import { hslToHSV } from '@basmilius/utils';

hslToHSV(212, 100, 47.6);
// => [h, s, v] with h in 0..1, s and v in 0..1

Parameters

NameTypeDescription
hnumberHue in degrees, 0..360.
snumberSaturation as a percentage, 0..100.
vnumberLightness as a percentage, 0..100.

Returns

[number, number, number][h, s, v] with all components in 0..1, identical to the rgbToHSV output range.

Type signature

ts
declare function hslToHSV(h: number, s: number, v: number): [number, number, number];

See also