pub struct RgbaUnit {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}Expand description
A straight-alpha RGBA pixel as floats in [0, 1].
Conversions to/from the framebuffer 0xAARRGGBB format use the helpers
at the bottom of this file (to_unit / from_unit).
Fields§
§r: f32Red channel, [0, 1].
g: f32Green channel, [0, 1].
b: f32Blue channel, [0, 1].
a: f32Alpha channel, [0, 1].
Implementations§
Source§impl RgbaUnit
impl RgbaUnit
Sourcepub fn new(r: f32, g: f32, b: f32, a: f32) -> Self
pub fn new(r: f32, g: f32, b: f32, a: f32) -> Self
Construct a pixel from raw float components (clamped to [0, 1]).
Sourcepub fn from_bytes(r: u8, g: u8, b: u8, a: u8) -> Self
pub fn from_bytes(r: u8, g: u8, b: u8, a: u8) -> Self
Construct from an unsigned-byte (r, g, b, a) tuple.
Sourcepub fn premultiply(self) -> Self
pub fn premultiply(self) -> Self
Multiply RGB by alpha — produces premultiplied form for fast bulk maths.
Sourcepub fn unpremultiply(self) -> Self
pub fn unpremultiply(self) -> Self
Inverse of premultiply; safe when a == 0
(returns transparent black rather than NaN).
Trait Implementations§
impl Copy for RgbaUnit
impl StructuralPartialEq for RgbaUnit
Auto Trait Implementations§
impl Freeze for RgbaUnit
impl RefUnwindSafe for RgbaUnit
impl Send for RgbaUnit
impl Sync for RgbaUnit
impl Unpin for RgbaUnit
impl UnsafeUnpin for RgbaUnit
impl UnwindSafe for RgbaUnit
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