pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}Expand description
Fields§
§r: f32Red component
g: f32Green component
b: f32Blue component
a: f32Alpha component
Implementations§
Source§impl Color
impl Color
Sourcepub const fn new(r: f32, g: f32, b: f32, a: f32) -> Self
pub const fn new(r: f32, g: f32, b: f32, a: f32) -> Self
Create a new Color from four f32’s in the range [0.0-1.0]
Sourcepub fn from_rgba(r: u8, g: u8, b: u8, a: u8) -> Color
pub fn from_rgba(r: u8, g: u8, b: u8, a: u8) -> Color
Create a new Color from four u8’s in the range [0-255]
Sourcepub fn from_rgb(r: u8, g: u8, b: u8) -> Color
pub fn from_rgb(r: u8, g: u8, b: u8) -> Color
Create a new Color from three u8’s in the range [0-255],
with the alpha component fixed to 255 (opaque)
Sourcepub fn to_rgba(self) -> (u8, u8, u8, u8)
pub fn to_rgba(self) -> (u8, u8, u8, u8)
Return a tuple of four u8’s in the range [0-255] with the Color’s
components.
Sourcepub fn to_rgb(self) -> (u8, u8, u8)
pub fn to_rgb(self) -> (u8, u8, u8)
Return a tuple of three u8’s in the range [0-255] with the Color’s
components.
Sourcepub fn from_rgba_u32(c: u32) -> Color
pub fn from_rgba_u32(c: u32) -> Color
Convert a packed u32 containing 0xRRGGBBAA into a Color
Sourcepub fn from_rgb_u32(c: u32) -> Color
pub fn from_rgb_u32(c: u32) -> Color
Convert a packed u32 containing 0x00RRGGBB into a Color.
This lets you do things like Color::from_rgb_u32(0xCD09AA) easily if you want.
Sourcepub fn to_rgba_u32(self) -> u32
pub fn to_rgba_u32(self) -> u32
Convert a Color into a packed u32, containing 0xRRGGBBAA as bytes.
Sourcepub fn to_rgb_u32(self) -> u32
pub fn to_rgb_u32(self) -> u32
Convert a Color into a packed u32, containing 0x00RRGGBB as bytes.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more