Skip to content

hslToHwb()

The hslToHwb function allows you to convert an HSL color value to its corresponding HWB value.

Usage

import { hslToHwb } from '@snipshot/spectrum';
const salmon = hslToHwb({ h: 6, s: 0.93, l: 0.71, a: 1 });
console.log(salmon); // { h: 6, w: 0.44, b: 0.02, a: 1 }

Parameters

hslToHwb(hslObj)

ParameterTypeRequiredDescription
hslObjHslObjtrueAn HSL object that represents a color in the HSLA (Hue, Saturation, Lightness, Alpha) color space.

Return Value

The hslToHwb function returns an HWB object of the color value.

Examples

With opacity

import { hslToHwb } from '@snipshot/spectrum';
const teal = hslToHwb({ h: 180, s: 1, l: 0.25, a: 0.75 });
console.log(teal); // { h: 180, w: 0, b: 0.5, a: 0.75 }
const violet = hslToHwb({ h: 300, s: 0.76, l: 0.72, a: 0.32 });
console.log(violet); // { h: 300, w: 0.51, b: 0.07, a: 0.32 }