pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}Expand description
An RGBA colour with components in 0.0..=1.0.
Every painter call takes impl Into<Color>, so a plain [r, g, b, a] array works as well
as a Color.
Components are sRGB, the values a color picker or CSS shows: Color::hex(0x2a3550) puts
exactly #2a3550 on screen, on sprites, shapes, circles, text, meshes and the clear color
alike. The renderer decodes them to linear for blending, so blends and the per-vertex
gradients of filled shapes mix in sRGB, as CSS does.
Fields§
§r: f32§g: f32§b: f32§a: f32Implementations§
Source§impl Color
impl Color
pub const TRANSPARENT: Color
pub const BLACK: Color
pub const WHITE: Color
pub const GRAY: Color
pub const RED: Color
pub const GREEN: Color
pub const BLUE: Color
pub const YELLOW: Color
pub const CYAN: Color
pub const MAGENTA: Color
pub const ORANGE: Color
pub const GOLD: Color
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
Colour from components in 0.0..=1.0.
Sourcepub const fn hex(rgb: u32) -> Color
pub const fn hex(rgb: u32) -> Color
Opaque colour from a 0xRRGGBB literal, as in CSS: Color::hex(0xff8800).
Sourcepub const fn hex_rgba(rgba: u32) -> Color
pub const fn hex_rgba(rgba: u32) -> Color
Colour from a 0xRRGGBBAA literal: Color::hex_rgba(0xff880080) is half-transparent.
Sourcepub const fn with_alpha(self, a: f32) -> Color
pub const fn with_alpha(self, a: f32) -> Color
This colour with alpha replaced by a.
Trait Implementations§
impl Copy 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
Mutably borrows from an owned value. Read more
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,
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.