pub trait Colorize: Sized {
Show 13 methods
// Required methods
fn opacity(&self, opacity: f32) -> Self;
fn divide(&self, divisor: f32) -> Self;
fn invert(&self) -> Self;
fn invert_l(&self) -> Self;
fn lighten(&self, amount: f32) -> Self;
fn darken(&self, amount: f32) -> Self;
fn apply(&self, base_color: Self) -> Self;
fn mix(&self, other: Self, factor: f32) -> Self;
fn hue(&self, hue: f32) -> Self;
fn saturation(&self, saturation: f32) -> Self;
fn lightness(&self, lightness: f32) -> Self;
fn to_hex(&self) -> String;
fn parse_hex(hex: &str) -> Result<Self>;
}
Required Methods§
Sourcefn opacity(&self, opacity: f32) -> Self
fn opacity(&self, opacity: f32) -> Self
Returns a new color with the given opacity.
The opacity is a value between 0.0 and 1.0, where 0.0 is fully transparent and 1.0 is fully opaque.
Sourcefn divide(&self, divisor: f32) -> Self
fn divide(&self, divisor: f32) -> Self
Returns a new color with each channel divided by the given divisor.
The divisor in range of 0.0 .. 1.0
Sourcefn lighten(&self, amount: f32) -> Self
fn lighten(&self, amount: f32) -> Self
Return a new color with the lightness increased by the given factor.
factor range: 0.0 .. 1.0
Sourcefn darken(&self, amount: f32) -> Self
fn darken(&self, amount: f32) -> Self
Return a new color with the darkness increased by the given factor.
factor range: 0.0 .. 1.0
Sourcefn apply(&self, base_color: Self) -> Self
fn apply(&self, base_color: Self) -> Self
Return a new color with the same lightness and alpha but different hue and saturation.
Sourcefn mix(&self, other: Self, factor: f32) -> Self
fn mix(&self, other: Self, factor: f32) -> Self
Mix two colors together, the factor
is a value between 0.0 and 1.0 for first color.
Sourcefn saturation(&self, saturation: f32) -> Self
fn saturation(&self, saturation: f32) -> Self
Change the Saturation
of the color by the given value in range: 0.0 .. 1.0
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.
Implementations on Foreign Types§
Source§impl Colorize for Hsla
impl Colorize for Hsla
Source§fn mix(&self, other: Self, factor: f32) -> Self
fn mix(&self, other: Self, factor: f32) -> Self
Reference: https://github.com/bevyengine/bevy/blob/85eceb022da0326b47ac2b0d9202c9c9f01835bb/crates/bevy_color/src/hsla.rs#L112