pub trait Colorize: Sized {
Show 14 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 mix_oklab(&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>;
}Expand description
颜色运算扩展 trait,为颜色类型提供透明度、明暗等变换能力。
Required Methods§
Sourcefn opacity(&self, opacity: f32) -> Self
fn opacity(&self, opacity: f32) -> Self
返回具有给定不透明度的新颜色。
不透明度是 0.0 到 1.0 之间的值,0.0 为完全透明,1.0 为完全不透明。
Sourcefn mix_oklab(&self, other: Self, factor: f32) -> Self
fn mix_oklab(&self, other: Self, factor: f32) -> Self
在 Oklab 颜色空间中混合两种颜色,factor 是第一种颜色的值,范围 0.0 到 1.0。
类似于 CSS color-mix(in oklab, color1 factor%, color2)。
Sourcefn saturation(&self, saturation: f32) -> Self
fn saturation(&self, saturation: f32) -> Self
将颜色的 饱和度 改为给定值,范围:0.0 .. 1.0
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".