pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}Expand description
An 8-bit-per-channel color with alpha.
Fields§
§r: u8Red.
g: u8Green.
b: u8Blue.
a: u8Alpha. Zero is fully transparent.
Implementations§
Source§impl Color
impl Color
Sourcepub fn from_hex(hex: &str) -> Result<Self, ColorError>
pub fn from_hex(hex: &str) -> Result<Self, ColorError>
Parse #RRGGBB or #RRGGBBAA.
Six digits means fully opaque. That is the CSS convention and the one a theme author will expect; defaulting to transparent instead would make every color written the short way invisible.
Case-insensitive, because a hand-written theme file mixes both and refusing lowercase would be a rule with nothing behind it.
§Errors
ColorError::Malformed for anything else — a missing #, a wrong
length, or a non-hex digit.
Sourcepub const fn packed_argb(self) -> u32
pub const fn packed_argb(self) -> u32
Pack as 0xAARRGGBB.
The layout a 32-bit ARGB8888 framebuffer word takes on a
little-endian host, which is what the renderer writes into.
Trait Implementations§
impl Copy for Color
impl Eq 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