Trait cosmic::cosmic_theme::palette::Lighten

source ·
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§

source

type Scalar

The type of the lighten modifier.

Required Methods§

source

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);
source

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);

Object Safety§

This trait is not object safe.

Implementors§

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<T> Lighten for Cam16UcsJab<T>

source§

impl<T> Lighten for Cam16UcsJmh<T>

source§

impl<T> Lighten for Okhsl<T>

source§

impl<T> Lighten for Okhsv<T>

source§

impl<T> Lighten for Okhwb<T>

source§

impl<T> Lighten for Oklab<T>

source§

impl<T> Lighten for Oklch<T>

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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