pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}Expand description
A straight (non-premultiplied) 8-bit-per-channel sRGB color.
Matches oxideav-core’s Rgba model; Color::to_oxideav is a
zero-cost bridge used when building a scene.
Fields§
§r: u8§g: u8§b: u8§a: u8Implementations§
Source§impl Color
impl Color
pub const TRANSPARENT: Self
pub const BLACK: Self
pub const WHITE: Self
pub const fn rgb(r: u8, g: u8, b: u8) -> Self
pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self
Sourcepub fn from_hex(s: &str) -> Option<Self>
pub fn from_hex(s: &str) -> Option<Self>
Parse #RGB, #RGBA, #RRGGBB, or #RRGGBBAA (leading #
optional). Returns None on any malformed input.
Sourcepub const fn with_alpha(self, a: u8) -> Self
pub const fn with_alpha(self, a: u8) -> Self
Returns a copy with the alpha channel replaced.
Sourcepub fn mix(self, other: Color, t: f64) -> Color
pub fn mix(self, other: Color, t: f64) -> Color
Linear blend toward other by t (0.0 = self, 1.0 = other), per
channel including alpha. t is clamped to [0, 1].
Sourcepub fn lighten(self, amount: f64) -> Color
pub fn lighten(self, amount: f64) -> Color
Blend amount (0..=1) toward white — for hover/active tints.
Sourcepub fn luminance(self) -> f64
pub fn luminance(self) -> f64
Perceptual luminance in [0, 1] (ITU-R BT.709 weights), for picking a
readable on-color.
Sourcepub const fn to_oxideav(self) -> Rgba
pub const fn to_oxideav(self) -> Rgba
Bridge to the oxideav-core color used by the scene graph.
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