Colorize

Trait Colorize 

Source
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§

Source

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.

Source

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

Source

fn invert(&self) -> Self

Return inverted color

Source

fn invert_l(&self) -> Self

Return inverted lightness

Source

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

Return a new color with the lightness increased by the given factor.

factor range: 0.0 .. 1.0

Source

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

Return a new color with the darkness increased by the given factor.

factor range: 0.0 .. 1.0

Source

fn apply(&self, base_color: Self) -> Self

Return a new color with the same lightness and alpha but different hue and saturation.

Source

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.

Source

fn hue(&self, hue: f32) -> Self

Change the Hue of the color by the given in range: 0.0 .. 1.0

Source

fn saturation(&self, saturation: f32) -> Self

Change the Saturation of the color by the given value in range: 0.0 .. 1.0

Source

fn lightness(&self, lightness: f32) -> Self

Change the Lightness of the color by the given value in range: 0.0 .. 1.0

Source

fn to_hex(&self) -> String

Convert the color to a hex string. For example, “#F8FAFC”.

Source

fn parse_hex(hex: &str) -> Result<Self>

Parse a hex string to a color.

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

Source§

fn mix(&self, other: Self, factor: f32) -> Self

Reference: https://github.com/bevyengine/bevy/blob/85eceb022da0326b47ac2b0d9202c9c9f01835bb/crates/bevy_color/src/hsla.rs#L112

Source§

fn opacity(&self, factor: f32) -> Self

Source§

fn divide(&self, divisor: f32) -> Self

Source§

fn invert(&self) -> Self

Source§

fn invert_l(&self) -> Self

Source§

fn lighten(&self, factor: f32) -> Self

Source§

fn darken(&self, factor: f32) -> Self

Source§

fn apply(&self, new_color: Self) -> Self

Source§

fn to_hex(&self) -> String

Source§

fn parse_hex(hex: &str) -> Result<Self>

Source§

fn hue(&self, hue: f32) -> Self

Source§

fn saturation(&self, saturation: f32) -> Self

Source§

fn lightness(&self, lightness: f32) -> Self

Implementors§