pub struct Rgba {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}Expand description
A 32-bit RGBA colour in linear-light floating-point space.
All channels are nominally in [0.0, 1.0]. Arithmetic operations may
produce out-of-range values; call Rgba::clamp to normalise.
Fields§
§r: f32§g: f32§b: f32§a: f32Implementations§
Source§impl Rgba
impl Rgba
Sourcepub fn from_u8(r: u8, g: u8, b: u8, a: u8) -> Self
pub fn from_u8(r: u8, g: u8, b: u8, a: u8) -> Self
Construct from 8-bit unsigned integer channels (sRGB transfer assumed by the caller; no gamma conversion is applied here).
Sourcepub fn premultiply(&self) -> Self
pub fn premultiply(&self) -> Self
Convert to premultiplied-alpha representation (RGB *= alpha).
Sourcepub fn unpremultiply(&self) -> Self
pub fn unpremultiply(&self) -> Self
Convert from premultiplied-alpha back to straight alpha.
If alpha == 0 the RGB channels are left as-is to avoid NaN.
Sourcepub fn transparent() -> Self
pub fn transparent() -> Self
Fully transparent black pixel.
Trait Implementations§
impl Copy for Rgba
impl StructuralPartialEq for Rgba
Auto Trait Implementations§
impl Freeze for Rgba
impl RefUnwindSafe for Rgba
impl Send for Rgba
impl Sync for Rgba
impl Unpin for Rgba
impl UnsafeUnpin for Rgba
impl UnwindSafe for Rgba
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