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

rgbToHsv

Convert sRGB (0-255, fractional values allowed) to HSV/HSB (hue in degrees [0, 360), saturation and value 0-100). Grays get hue and saturation 0.

functionimport { rgbToHsv } from '@pbroom/color-kit';hsv.ts:22
function rgbToHsv(rgb: Rgb): Hsv;

Parameters

rgbRgb
sRGB color

Returns

HsvA new Hsv

Example

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

rgbToHsv({ r: 255, g: 0, b: 0, alpha: 1 }); // → { h: 0, s: 100, v: 100, alpha: 1 }

See also

  • hsvToRgb
  • toHsv

Your display: detecting

MIT licensedSource