Hsl
A color as hue, saturation and lightness.
The hue is in degrees, 0.0..360.0; saturation and lightness are fractions from 0.0 to 1.0.
Hsl::new brings any input into those ranges. Get one from Rgb::to_hsl and go back with
Hsl::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
lightness 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). |
l | f64 | The lightness, 0.0 (black) to 1.0 (white). |
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 lightness.
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.
