Trait 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> Lighten for Alpha<C, C::Scalar>

§

type Scalar = <C as Lighten>::Scalar

source§

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

§

type Scalar = T

source§

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

§

type Scalar = T

source§

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

§

type Scalar = T

source§

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

§

type Scalar = T

source§

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

§

type Scalar = T

source§

impl<T> Lighten for Cam16UcsJab<T>

§

type Scalar = T

source§

impl<T> Lighten for Cam16UcsJmh<T>

§

type Scalar = T

source§

impl<T> Lighten for Okhsl<T>

§

type Scalar = T

source§

impl<T> Lighten for Okhsv<T>

§

type Scalar = T

source§

impl<T> Lighten for Okhwb<T>

§

type Scalar = T

source§

impl<T> Lighten for Oklab<T>

§

type Scalar = T

source§

impl<T> Lighten for Oklch<T>
where T: Real + Zero + MinMax + Clamp + Arithmetics + PartialCmp + Clone + Zero + One, T::Mask: LazySelect<T>,

§

type Scalar = T

source§

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

§

type Scalar = T

source§

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

§

type Scalar = T

source§

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

§

type Scalar = T

source§

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

§

type Scalar = T

source§

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

§

type Scalar = T

source§

impl<Wp, T> Lighten for Xyz<Wp, T>
where T: Real + Zero + MinMax + Clamp + Arithmetics + PartialCmp + Clone, T::Mask: LazySelect<T>, Wp: WhitePoint<T>,

§

type Scalar = T

source§

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

§

type Scalar = T