Hsb
A color as hue, saturation and brightness (also called HSV), the model of design tool color
pickers. Unlike Hsl lightness, brightness 1.0 is the pure color, not white.
The hue is in degrees, 0.0..360.0; saturation and brightness are fractions from 0.0 to
1.0. Hsb::new brings any input into those ranges. Get one from Rgb::to_hsb and go
back with Hsb::to_rgb.
Import
Section titled “Import”Cargo feature color (enabled by default). To compile only this module:
or in Cargo.toml:
Definition
Section titled “Definition”Examples
Section titled “Examples”Methods
Section titled “Methods”Builds a color, normalizing the values: the hue wraps around 360 degrees, saturation and
brightness are clamped to 0.0..=1.0, and a NaN counts as 0.0.
Parameters
| Parameter | Type | Description |
|---|---|---|
h | f64 | The hue in degrees. |
s | f64 | The saturation, 0.0 (grey) to 1.0 (vivid). |
b | f64 | The brightness, 0.0 (black) to 1.0 (the pure color). |
Returns
Self — The normalized color.
The hue in degrees.
Returns
f64 — A value in 0.0..360.0.
The saturation.
Returns
f64 — A value from 0.0 to 1.0.
The brightness.
Returns
f64 — A value from 0.0 to 1.0.
to_rgb
Section titled “to_rgb”The nearest 8-bit sRGB color.
Returns
Rgb — The Rgb color, each channel rounded to the nearest integer.
