Skip to content
color-kitnext
StartAPI
color-kit on GitHub
Start

Concepts

  • OKLCH-canonical
  • Requested vs displayed
  • Planes and queries
  • Gamut and tolerance
  • Contrast

Guides

  • Headless picker
  • React
  • Contrast-aware palettes
  • GPU and three.js
  • Performance

API

  • Overview
  • @pbroom/color-kit
      • ffunctiontoRgb
      • ffunctionfromRgb
      • ffunctiontoHex
      • ffunctionfromHex
      • ffunctiontoHsl
      • ffunctionfromHsl
      • ffunctiontoHsv
      • ffunctionfromHsv
      • ffunctiontoHct
      • ffunctionfromHct
      • ffunctiontoOklab
      • ffunctionfromOklab
      • ffunctiontoOklch
      • ffunctionfromOklch
      • ffunctiontoP3
      • ffunctionfromP3
      • ffunctiontoCss
      • ffunctionparse
      • ffunctiontryParse
      • ffunctionsrgbToLinear
      • ffunctionlinearToSrgb
      • ffunctionrgbToHex
      • ffunctionhexToRgb
      • ffunctionrgbToHsl
      • ffunctionhslToRgb
      • ffunctionrgbToHsv
      • ffunctionhsvToRgb
      • ffunctionlinearRgbToOklab
      • ffunctionoklabToLinearRgb
      • ffunctionoklabToOklch
      • ffunctionoklchToOklab
      • ffunctionoklchToColor
      • ffunctioncolorToOklch
      • ffunctionlinearSrgbToLinearP3
      • ffunctionlinearP3ToLinearSrgb
      • ffunctionlinearP3ToP3
      • ffunctionp3ToLinearP3
      • ffunctiontoOklabInto
      • ffunctionfromOklabInto
      • ffunctiontoLinearSrgbInto
      • ffunctionfromLinearSrgbInto
      • ffunctiontoRgbInto
      • ffunctionfromRgbInto
      • ffunctiontoP3Into
      • ffunctionfromP3Into
      • ffunctionsrgbToLinearInto
      • ffunctionlinearToSrgbInto
      • ffunctionlinearRgbToOklabInto
      • ffunctionoklabToLinearRgbInto
      • ffunctionoklabToOklchInto
      • ffunctionoklchToOklabInto
      • ffunctionlinearSrgbToLinearP3Into
      • ffunctionlinearP3ToLinearSrgbInto
      • ffunctionlinearP3ToP3Into
      • ffunctionp3ToLinearP3Into
      • KconstLINEAR_SRGB_TO_LINEAR_P3
      • KconstLMS_TO_LINEAR_SRGB
      • KconstOKLAB_TO_LMS
      • TtypeCssColorFormat
      • TtypeMatrix3
  • @pbroom/color-kit/plane
  • @pbroom/color-kit/interop
  • @pbroom/color-kit/compute
  • @pbroom/color-kit/hct
  • @pbroom/color-kit/driver
  • @pbroom/color-kit/react
Map

@pbroom/color-kit/Conversion

rgbToHsl

Convert sRGB (0-255, fractional values allowed) to HSL (hue in degrees [0, 360), saturation and lightness 0-100). Grays get hue and saturation 0.

functionimport { rgbToHsl } from '@pbroom/color-kit';hsl.ts:30
function rgbToHsl(rgb: Rgb): Hsl;

Parameters

rgbRgb
sRGB color

Returns

HslA new Hsl

Example

TypeScript
import { rgbToHsl } from '@pbroom/color-kit';

rgbToHsl({ r: 0, g: 0, b: 255, alpha: 1 }); // → { h: 240, s: 100, l: 50, alpha: 1 }

See also

  • hslToRgb
  • toHsl

Your display: detecting

MIT licensedSource