Struct HSL
Source pub struct HSL {
pub h: f32,
pub s: f32,
pub l: f32,
}
Expand description
HSL color.
| Field | Range | Description |
h | 0..360 | Hue angle (wraps at 360) |
s | 0..1 | Saturation |
l | 0..1 | Lightness |
§Why no arithmetic?
Same reasoning as HSV: hue wraparound makes naive componentwise
operations incorrect. Convert to RGBA, manipulate there, convert back.
See HSV for details and alternatives.
Construct an HSL color with clamping.
Hue is clamped to 0..360, saturation and lightness to 0..1.
Convert to RGBA with a custom alpha.
Equivalent to self.to_rgba().with_alpha(alpha).
Performs copy-assignment from
source.
Read more
Formats the value using the given formatter.
Read more
Converts to this type from the input type.
Converts to this type from the input type.
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dest.
Read more
Relative luminance per ITU-R BT.709.
Read more
Returns true if the luminance is greater than 0.5.
Compute the WCAG contrast ratio against another color.
Read more
Encode as a hex string: #RRGGBBAA.
Convert to 8-bit byte channels: (r, g, b, a) in 0..255.
Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From<T> for U chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more
Uses borrowed data to replace owned data, usually by cloning.
Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.