pub struct Color {
pub red: u8,
pub green: u8,
pub blue: u8,
pub alpha: u8,
}Expand description
A color with red, green, blue, and alpha components, in a byte each.
Fields§
§red: u8The red component.
green: u8The green component.
blue: u8The blue component.
alpha: u8The alpha component.
Implementations§
Source§impl Color
impl Color
Sourcepub fn from_floats(red: f32, green: f32, blue: f32, alpha: f32) -> Self
pub fn from_floats(red: f32, green: f32, blue: f32, alpha: f32) -> Self
Constructs a new Color value from float components. It expects the red, green, blue and alpha channels in that order, and all values will be clamped to the 0.0 … 1.0 range.
Sourcepub fn transparent() -> Self
pub fn transparent() -> Self
Returns a transparent color.
Sourcepub fn new(red: u8, green: u8, blue: u8, alpha: u8) -> Self
pub fn new(red: u8, green: u8, blue: u8, alpha: u8) -> Self
Same thing, but with u8 values instead of floats in the 0 to 1 range.
Sourcepub fn red_f32(&self) -> f32
pub fn red_f32(&self) -> f32
Returns the red channel in a floating point number form, from 0 to 1.
Sourcepub fn green_f32(&self) -> f32
pub fn green_f32(&self) -> f32
Returns the green channel in a floating point number form, from 0 to 1.
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 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