bevy_color::prelude

Trait Luminance

Source
pub trait Luminance: Sized {
    // Required methods
    fn luminance(&self) -> f32;
    fn with_luminance(&self, value: f32) -> Self;
    fn darker(&self, amount: f32) -> Self;
    fn lighter(&self, amount: f32) -> Self;
}
Expand description

Methods for changing the luminance of a color. Note that these methods are not guaranteed to produce consistent results across color spaces, but will be within a given space.

Required Methods§

Source

fn luminance(&self) -> f32

Return the luminance of this color (0.0 - 1.0).

Source

fn with_luminance(&self, value: f32) -> Self

Return a new version of this color with the given luminance. The resulting color will be clamped to the valid range for the color space; for some color spaces, clamping may cause the hue or chroma to change.

Source

fn darker(&self, amount: f32) -> Self

Return a darker version of this color. The amount should be between 0.0 and 1.0. The amount represents an absolute decrease in luminance, and is distributive: color.darker(a).darker(b) == color.darker(a + b). Colors are clamped to black if the amount would cause them to go below black.

For a relative decrease in luminance, you can simply mix() with black.

Source

fn lighter(&self, amount: f32) -> Self

Return a lighter version of this color. The amount should be between 0.0 and 1.0. The amount represents an absolute increase in luminance, and is distributive: color.lighter(a).lighter(b) == color.lighter(a + b). Colors are clamped to white if the amount would cause them to go above white.

For a relative increase in luminance, you can simply mix() with white.

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.

Implementors§