pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}Expand description
RGBA color value with alpha channel
Alpha channel: 0 = fully transparent, 255 = fully opaque. Default color has alpha=0 to indicate “unset” state.
Fields§
§r: u8Red component (0-255)
g: u8Green component (0-255)
b: u8Blue component (0-255)
a: u8Alpha component (0=transparent, 255=opaque)
Implementations§
Source§impl Color
impl Color
Sourcepub const TRANSPARENT: Color
pub const TRANSPARENT: Color
Transparent (fully transparent black)
Sourcepub fn is_default(&self) -> bool
pub fn is_default(&self) -> bool
Check if this is the default (unset) color
Sourcepub const fn is_transparent(&self) -> bool
pub const fn is_transparent(&self) -> bool
Check if color is fully transparent
Sourcepub const fn with_alpha(self, a: u8) -> Self
pub const fn with_alpha(self, a: u8) -> Self
Create a new color with modified alpha
Sourcepub const fn semi_transparent(self) -> Self
pub const fn semi_transparent(self) -> Self
Create a semi-transparent version (alpha = 128)
Sourcepub fn with_alpha_f32(self, alpha: f32) -> Self
pub fn with_alpha_f32(self, alpha: f32) -> Self
Create color with alpha from float (0.0 = transparent, 1.0 = opaque)
Sourcepub fn darken_pct(self, pct: f32) -> Self
pub fn darken_pct(self, pct: f32) -> Self
Sourcepub fn lighten_pct(self, pct: f32) -> Self
pub fn lighten_pct(self, pct: f32) -> Self
Sourcepub const fn with_interaction(
self,
pressed: bool,
hovered: bool,
focused: bool,
) -> Self
pub const fn with_interaction( self, pressed: bool, hovered: bool, focused: bool, ) -> Self
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 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().