cosmic::cosmic_theme::palette

Trait LightenAssign

source
pub trait LightenAssign {
    type Scalar;

    // Required methods
    fn lighten_assign(&mut self, factor: Self::Scalar);
    fn lighten_fixed_assign(&mut self, amount: Self::Scalar);
}
Expand description

Assigning operators for lightening a color.

The trait’s functions are split into two groups of functions: relative and fixed/absolute.

The relative function, lighten_assign, scales the lightness towards the maximum lightness value. This means that for a color with 50% lightness, if lighten_assign(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_assign, 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_assign(0.5) is applied to it, the color will have 50% lightness added to its lightness value resulting in a new value of 100%.

LightenAssign is also implemented for [T]:

use palette::{Hsl, LightenAssign};

let mut my_vec = vec![Hsl::new_srgb(104.0, 0.3, 0.8), Hsl::new_srgb(113.0, 0.5, 0.8)];
let mut my_array = [Hsl::new_srgb(104.0, 0.3, 0.8), Hsl::new_srgb(113.0, 0.5, 0.8)];
let mut my_slice = &mut [Hsl::new_srgb(104.0, 0.3, 0.8), Hsl::new_srgb(112.0, 0.5, 0.8)];

my_vec.lighten_assign(0.5);
my_array.lighten_assign(0.5);
my_slice.lighten_assign(0.5);

See also Lighten, Darken and DarkenAssign.

Required Associated Types§

source

type Scalar

The type of the lighten modifier.

Required Methods§

source

fn lighten_assign(&mut self, factor: Self::Scalar)

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, LightenAssign};

let mut color = Hsl::new_srgb(0.0, 1.0, 0.5);
color.lighten_assign(0.5);
assert_relative_eq!(color.lightness, 0.75);
source

fn lighten_fixed_assign(&mut self, amount: Self::Scalar)

Lighten the color by amount, a value ranging from 0.0 to 1.0.

use approx::assert_relative_eq;
use palette::{Hsl, LightenAssign};

let mut color = Hsl::new_srgb(0.0, 1.0, 0.4);
color.lighten_fixed_assign(0.2);
assert_relative_eq!(color.lightness, 0.6);

Implementations on Foreign Types§

source§

impl<T> LightenAssign for [T]

Implementors§

source§

impl<C> LightenAssign for Alpha<C, <C as LightenAssign>::Scalar>
where C: LightenAssign,

source§

impl<S, T> LightenAssign for Luma<S, T>

source§

impl<S, T> LightenAssign for Rgb<S, T>

source§

impl<S, T> LightenAssign for Hsl<S, T>

source§

impl<S, T> LightenAssign for Hsv<S, T>

source§

impl<S, T> LightenAssign for Hwb<S, T>

source§

impl<T> LightenAssign for Cam16UcsJab<T>

source§

impl<T> LightenAssign for Cam16UcsJmh<T>

source§

impl<T> LightenAssign for Okhsl<T>

source§

impl<T> LightenAssign for Okhsv<T>

source§

impl<T> LightenAssign for Okhwb<T>

source§

impl<T> LightenAssign for Oklab<T>

source§

impl<T> LightenAssign for Oklch<T>

source§

impl<Wp, T> LightenAssign for Hsluv<Wp, T>

source§

impl<Wp, T> LightenAssign for Lab<Wp, T>

source§

impl<Wp, T> LightenAssign for Lch<Wp, T>

source§

impl<Wp, T> LightenAssign for Lchuv<Wp, T>

source§

impl<Wp, T> LightenAssign for Luv<Wp, T>

source§

impl<Wp, T> LightenAssign for Xyz<Wp, T>

source§

impl<Wp, T> LightenAssign for Yxy<Wp, T>