rgbToHsb
Converts an RGB(A) color into HSB(A), the model design tools (Figma, Sketch, XD) show in their
color pickers. Unlike HSL lightness, brightness 100 is the pure color, not white.
h/s/b are rounded to 1 decimal place to avoid floating-point noise.
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
color | RgbColor | The color to convert. `r`/`g`/`b` are expected in 0-255, `a` defaults to 1 (opaque) when omitted. |
Returns
Section titled “Returns”HsbColor — The equivalent HSB(A) color: h in 0-360, s/b in 0-100
Examples
Section titled “Examples”Show a color like a design tool picker
Section titled “Show a color like a design tool picker”Pure colors have a brightness of 100.
White versus HSL
Section titled “White versus HSL”White is saturation 0 and brightness 100 (HSL would say lightness 100).
Related Types
Section titled “Related Types”HsbColor
Section titled “HsbColor”An HSB(A) color (also called HSV), the model of design tool color pickers.
RgbColor
Section titled “RgbColor”An RGB(A) color with channels expressed as plain numbers, convenient for further conversion or manipulation.
