pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}Expand description
RGBA color with values 0-255.
Fields§
§r: u8§g: u8§b: u8§a: u8Implementations§
Source§impl Color
impl Color
pub const fn rgb(r: u8, g: u8, b: u8) -> Self
pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self
pub const fn transparent() -> Self
pub const fn black() -> Self
pub const fn white() -> Self
Sourcepub fn from_hex(hex: &str) -> Result<Self>
pub fn from_hex(hex: &str) -> Result<Self>
Parse a color from a hex string (with or without ‘#’).
§Examples
use icon_to_image::Color;
let red = Color::from_hex("#FF0000").unwrap();
let blue = Color::from_hex("0000FF").unwrap();
let semi_transparent = Color::from_hex("#FF000080").unwrap();pub const fn to_rgba(&self) -> [u8; 4]
pub const fn is_transparent(&self) -> bool
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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