pub trait Lighten {
type Scalar;
// Required methods
fn lighten(self, factor: Self::Scalar) -> Self;
fn lighten_fixed(self, amount: Self::Scalar) -> Self;
}Expand description
Operators for lightening a color.
The trait’s functions are split into two groups of functions: relative and fixed/absolute.
The relative function, lighten, scales the lightness
towards the maximum lightness value. This means that for a color with 50%
lightness, if lighten(0.5) is applied to it, the color will scale halfway
to the maximum value of 100% resulting in a new lightness value of 75%.
The fixed or absolute function, lighten_fixed,
increase the lightness value by an amount that is independent of the current
lightness of the color. So for a color with 50% lightness, if
lighten_fixed(0.5) is applied to it, the color will have 50% lightness
added to its lightness value resulting in a new value of 100%.
See also LightenAssign, Darken and DarkenAssign.
Required Associated Types§
Required Methods§
Sourcefn lighten(self, factor: Self::Scalar) -> Self
fn lighten(self, factor: Self::Scalar) -> Self
Scale the color towards the maximum lightness by factor, a value
ranging from 0.0 to 1.0.
use approx::assert_relative_eq;
use palette::{Hsl, Lighten};
let color = Hsl::new_srgb(0.0, 1.0, 0.5);
assert_relative_eq!(color.lighten(0.5).lightness, 0.75);Sourcefn lighten_fixed(self, amount: Self::Scalar) -> Self
fn lighten_fixed(self, amount: Self::Scalar) -> Self
Lighten the color by amount, a value ranging from 0.0 to 1.0.
use approx::assert_relative_eq;
use palette::{Hsl, Lighten};
let color = Hsl::new_srgb(0.0, 1.0, 0.4);
assert_relative_eq!(color.lighten_fixed(0.2).lightness, 0.6);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.