@pbroom/color-kitConversion

toHsv

Convert a Color to HSV/HSB (hue in degrees, saturation and value 0-100).

functionimport { toHsv } from '@pbroom/color-kit';index.ts:223
function toHsv(color: Color): Hsv;

Computed from the sRGB value clipped to the gamut like toRgb but not rounded to 8-bit, so channels are fractional. Grays get hue and saturation 0.

Parameters

colorColor
Color to convert

Returns

HsvA new Hsv

Example

TypeScript
import { parse, toHsv } from '@pbroom/color-kit';

toHsv(parse('#3b82f6')); // → ≈ { h: 217.22, s: 76.02, v: 96.47, alpha: 1 }

See also