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: Color
pub const TRANSPARENT: Color
Fully transparent black.
Sourcepub const fn rgb(r: f32, g: f32, b: f32) -> Color
pub const fn rgb(r: f32, g: f32, b: f32) -> Color
Builds an opaque color from floating-point RGB channels.
Sourcepub const fn rgba(r: f32, g: f32, b: f32, a: f32) -> Color
pub const fn rgba(r: f32, g: f32, b: f32, a: f32) -> Color
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) -> Color
pub fn rgb8(r: u8, g: u8, b: u8) -> Color
Builds an opaque linear color from 0..=255 sRGB channels.
Sourcepub fn rgba8(r: u8, g: u8, b: u8, a: u8) -> Color
pub fn rgba8(r: u8, g: u8, b: u8, a: u8) -> Color
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) -> Color
pub fn with_alpha(self, alpha: f32) -> Color
Returns the same RGB color with a replaced alpha channel.
Sourcepub fn scale_alpha(self, factor: f32) -> Color
pub fn scale_alpha(self, factor: f32) -> Color
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
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin for Color
impl UnwindSafe for Color
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.