pub struct Color { /* private fields */ }Expand description
Linear RGBA color with channels in the 0.0..=1.0 range.
Constructors do not clamp so intermediate animation values can overshoot.
Use Color::clamp before sending untrusted colors to a renderer.
Implementations§
Source§impl Color
impl Color
Sourcepub const TRANSPARENT: Self
pub const TRANSPARENT: Self
Fully transparent black.
Sourcepub const fn rgb(r: f32, g: f32, b: f32) -> Self
pub const fn rgb(r: f32, g: f32, b: f32) -> Self
Builds an opaque color from floating-point RGB channels.
Sourcepub const fn rgba(r: f32, g: f32, b: f32, a: f32) -> Self
pub const fn rgba(r: f32, g: f32, b: f32, a: f32) -> Self
Builds a color from floating-point RGBA channels.
Sourcepub const fn alpha(self) -> f32
pub const fn alpha(self) -> f32
Returns alpha coverage, where 0.0 is transparent and 1.0 is opaque.
Sourcepub fn rgb8(r: u8, g: u8, b: u8) -> Self
pub fn rgb8(r: u8, g: u8, b: u8) -> Self
Builds an opaque linear color from 0..=255 sRGB channels.
Sourcepub fn rgba8(r: u8, g: u8, b: u8, a: u8) -> Self
pub fn rgba8(r: u8, g: u8, b: u8, a: u8) -> Self
Builds a linear color from 0..=255 sRGB and alpha channels.
RGB channels are converted from sRGB to linear light. Alpha is linear
coverage and is only normalized to 0.0..=1.0.
Sourcepub fn with_alpha(self, alpha: f32) -> Self
pub fn with_alpha(self, alpha: f32) -> Self
Returns the same RGB color with a replaced alpha channel.
Sourcepub fn scale_alpha(self, factor: f32) -> Self
pub fn scale_alpha(self, factor: f32) -> Self
Multiplies only the alpha channel by factor.
Sourcepub fn is_normalized(self) -> bool
pub fn is_normalized(self) -> bool
Returns true when every channel is finite and lies in 0.0..=1.0.
Trait Implementations§
impl Copy for Color
Source§impl Interpolate for Color
impl Interpolate for Color
Source§fn interpolate(self, end: Self, amount: f32) -> Self
fn interpolate(self, end: Self, amount: f32) -> Self
self and end.