@pbroom/color-kitConversion

fromHsl

Convert HSL (hue in degrees, saturation and lightness 0-100) to a Color.

functionimport { fromHsl } from '@pbroom/color-kit';index.ts:201
function fromHsl(hsl: Hsl): Color;

The intermediate sRGB value is not quantized to 8-bit, so fractional HSL inputs keep full precision. Any finite hue is accepted and wrapped.

Parameters

hslHsl
HSL color

Returns

ColorA new OKLCH Color

Example

TypeScript
import { fromHsl, toHex } from '@pbroom/color-kit';

toHex(fromHsl({ h: 200, s: 80, l: 40, alpha: 1 })); // → '#1481b8'

See also