#[repr(transparent)]pub struct PackedRgba(pub u32);Expand description
A compact RGBA color.
- Size: 4 bytes (fits within the
Cell16-byte budget). - Layout:
0xRRGGBBAA(R in bits 31..24, A in bits 7..0).
§Notes
This is straight alpha storage (RGB channels are not pre-multiplied).
Compositing uses Porter-Duff SourceOver (src over dst).
Tuple Fields§
§0: u32Implementations§
Source§impl PackedRgba
impl PackedRgba
Sourcepub const TRANSPARENT: Self
pub const TRANSPARENT: Self
Fully transparent (alpha = 0).
Sourcepub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self
pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self
Create an RGBA color with explicit alpha.
Sourcepub fn over(self, dst: Self) -> Self
pub fn over(self, dst: Self) -> Self
Porter-Duff SourceOver: src over dst.
Stored as straight alpha, so we compute the exact rational form and round at the end (avoids accumulating rounding error across intermediate steps).
Sourcepub fn with_opacity(self, opacity: f32) -> Self
pub fn with_opacity(self, opacity: f32) -> Self
Apply uniform opacity in [0.0, 1.0] by scaling alpha.
Trait Implementations§
Source§impl Clone for PackedRgba
impl Clone for PackedRgba
Source§fn clone(&self) -> PackedRgba
fn clone(&self) -> PackedRgba
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PackedRgba
impl Debug for PackedRgba
Source§impl Default for PackedRgba
impl Default for PackedRgba
Source§fn default() -> PackedRgba
fn default() -> PackedRgba
Returns the “default value” for a type. Read more
Source§impl Hash for PackedRgba
impl Hash for PackedRgba
Source§impl PartialEq for PackedRgba
impl PartialEq for PackedRgba
impl Copy for PackedRgba
impl Eq for PackedRgba
impl StructuralPartialEq for PackedRgba
Auto Trait Implementations§
impl Freeze for PackedRgba
impl RefUnwindSafe for PackedRgba
impl Send for PackedRgba
impl Sync for PackedRgba
impl Unpin for PackedRgba
impl UnsafeUnpin for PackedRgba
impl UnwindSafe for PackedRgba
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