Expand description
A struct to represent how much hue, saturation, and luminosity should be added to create a color. Also handles alpha specifications.
A valid value for h
must range between 0-360
.
The saturation ranges between 0-100
, where 0
is completely desaturated, and 100
is full saturation.
The luminosity ranges between 0-100
, where 0
is no light (black), and 100
is full light (white).
For more, see the CSS Color Spec.
Fields
h: Angle
s: Ratio
l: Ratio
a: Ratio
Trait Implementations
sourceimpl Color for HSLA
impl Color for HSLA
type Alpha = HSLA
sourcefn to_hex(self) -> String
fn to_hex(self) -> String
Converts
self
to a hex string in the format #rrggbb without
alpha, and #rrggbbaa with alpha. Read moresourcefn to_rgb(self) -> RGB
fn to_rgb(self) -> RGB
Converts
self
into its RGB representation.
When converting from a color model that supports an alpha channel
(e.g. RGBA), the alpha value will not be preserved. Read moresourcefn to_rgba(self) -> RGBA
fn to_rgba(self) -> RGBA
Converts
self
into its RGBA representation.
When converting from a color model that does not supports an alpha channel
(e.g. RGB), it will be treated as fully opaque. Read moresourcefn to_hsl(self) -> HSL
fn to_hsl(self) -> HSL
Converts
self
into its HSL representation.
When converting from a color model that supports an alpha channel
(e.g. RGBA), the alpha value will not be preserved. Read moresourcefn to_hsla(self) -> HSLA
fn to_hsla(self) -> HSLA
Converts
self
into its HSLA representation.
When converting from a color model that does not supports an alpha channel
(e.g. RGB), it will be treated as fully opaque. Read moresourcefn saturate(self, amount: Ratio) -> Self
fn saturate(self, amount: Ratio) -> Self
Increases the saturation of
self
by an absolute amount.
Operates on the color within its HSL representation and preserves any existing alpha channel.
For more, see Less’ Color Operations. Read moresourcefn desaturate(self, amount: Ratio) -> Self
fn desaturate(self, amount: Ratio) -> Self
Decreases the saturation of
self
by an absolute amount.
Operates on the color within its HSL representation and preserves any existing alpha channel.
For more, see Less’ Color Operations. Read moresourcefn lighten(self, amount: Ratio) -> Self
fn lighten(self, amount: Ratio) -> Self
Increases the lightness of
self
by an absolute amount.
Operates on the color within its HSL representation and preserves any existing alpha channel.
For more, see Less’ Color Operations. Read moresourcefn darken(self, amount: Ratio) -> Self
fn darken(self, amount: Ratio) -> Self
Decreases the lightness of
self
by an absolute amount.
Operates on the color within its HSL representation and preserves any existing alpha channel.
For more, see Less’ Color Operations. Read moresourcefn fadein(self, amount: Ratio) -> Self
fn fadein(self, amount: Ratio) -> Self
Decreases the transparency (or increase the opacity) of
self
, making it more opaque.
For opqaue colors, converts into the alpha equivalent of self
, and then increases the opacity.
For more, see Less’ Color Operations. Read moresourcefn fadeout(self, amount: Ratio) -> Self
fn fadeout(self, amount: Ratio) -> Self
Increases the transparency (or decrease the opacity) of
self
, making it less opaque.
For opqaue colors, converts into the alpha equivalent of self
, and then decreases the opacity.
For more, see Less’ Color Operations. Read moresourcefn fade(self, amount: Ratio) -> Self::Alpha
fn fade(self, amount: Ratio) -> Self::Alpha
Sets the absolute opacity of
self
, and returns the alpha equivalent.
Can be applied to colors whether they already have an opacity value or not.
For more, see Less’ Color Operations. Read moresourcefn spin(self, amount: Angle) -> Self
fn spin(self, amount: Angle) -> Self
Rotate the hue angle of
self
in either direction.
Returns the appropriate RGB
representation of the color once it has been spun.
For more, see Less’ Color Operations. Read moresourcefn mix<T: Color>(self, other: T, weight: Ratio) -> Self::Alpha
fn mix<T: Color>(self, other: T, weight: Ratio) -> Self::Alpha
Mixes two colors (
self
and any other Color
) together in variable proportion.
Takes opacity into account in the calculations.
For more, see Less’ Color Operations. Read moresourcefn tint(self, weight: Ratio) -> Self
fn tint(self, weight: Ratio) -> Self
Mixes
self
with white in variable proportion.
Equivalent to calling mix()
with white
(rgb(255, 255, 255)
).
For more, see Less’ Color Operations. Read moresourcefn shade(self, weight: Ratio) -> Self
fn shade(self, weight: Ratio) -> Self
Mixes
self
with white in variable proportion.
Equivalent to calling mix()
with black
(rgb(0, 0, 0)
).
For more, see Less’ Color Operations. Read moresourcefn greyscale(self) -> Self
fn greyscale(self) -> Self
Remove all saturation from
self
in the HSL color space.
Equivalent to calling desaturate(0)
on a color.
For more, see Less’ Color Operations. Read moreimpl Copy for HSLA
impl Eq for HSLA
impl StructuralEq for HSLA
impl StructuralPartialEq for HSLA
Auto Trait Implementations
impl RefUnwindSafe for HSLA
impl Send for HSLA
impl Sync for HSLA
impl Unpin for HSLA
impl UnwindSafe for HSLA
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more