Expand description
Fields
r: f32
Red component
g: f32
Green component
b: f32
Blue component
a: f32
Alpha component
Implementations
sourceimpl 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
sourceimpl<'de> Deserialize<'de> for Color
impl<'de> Deserialize<'de> for Color
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<Color> for CanvasLoadOp
impl From<Color> for CanvasLoadOp
sourceimpl From<Color> for LinearColor
impl From<Color> for LinearColor
sourcefn from(c: Color) -> Self
fn from(c: Color) -> Self
Convert an (sRGB) Color into a linear color, per https://en.wikipedia.org/wiki/Srgb#The_reverse_transformation
sourceimpl From<LinearColor> for Color
impl From<LinearColor> for Color
sourcefn from(c: LinearColor) -> Self
fn from(c: LinearColor) -> Self
Converts to this type from the input type.
impl Copy for Color
impl StructuralPartialEq for Color
Auto Trait Implementations
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> HasMut<T> for T
impl<T> HasMut<T> for T
sourcefn retrieve_mut(&mut self) -> &mut T
fn retrieve_mut(&mut self) -> &mut T
Method to retrieve the context type as mutable.