pub struct LinearRgba { /* private fields */ }Expand description
A straight-alpha color in linear light. RGB are linear (already gamma-decoded) and may
exceed 1.0 (HDR over-bright); alpha is coverage in [0, 1] (never gamma-encoded). The
blur convolution runs in linear light, so a tint authored in sRGB must be decoded first —
that is exactly what Self::from_srgb_unmultiplied does, so callers never hand the
backend gamma-encoded tint values (DESIGN §4.2).
Fields are private so the “already linear” invariant is only ever established through a
named constructor (matching the other newtypes), and both constructors are total:
non-finite channels (NaN/±∞) are scrubbed to 0.0 so a malformed tint can never reach
the GPU as undebuggable garbage.
Implementations§
Source§impl LinearRgba
impl LinearRgba
Sourcepub fn new(r: f32, g: f32, b: f32, a: f32) -> Self
pub fn new(r: f32, g: f32, b: f32, a: f32) -> Self
Build from channels that are already linear. Non-finite channels are scrubbed to
0.0 and alpha is clamped to [0, 1]; RGB keep their (possibly > 1, HDR) magnitude.
Sourcepub fn from_srgb_unmultiplied(rgba: [u8; 4]) -> Self
pub fn from_srgb_unmultiplied(rgba: [u8; 4]) -> Self
Decode straight-alpha sRGB bytes to linear light: RGB through the sRGB EOTF, alpha
linearly. This is the gamma decode the linear-space convolution requires. The result is
finite by construction (u8 / 255 and the EOTF never produce NaN/∞).
Trait Implementations§
Source§impl Clone for LinearRgba
impl Clone for LinearRgba
Source§fn clone(&self) -> LinearRgba
fn clone(&self) -> LinearRgba
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for LinearRgba
Source§impl Debug for LinearRgba
impl Debug for LinearRgba
Source§impl PartialEq for LinearRgba
impl PartialEq for LinearRgba
Source§fn eq(&self, other: &LinearRgba) -> bool
fn eq(&self, other: &LinearRgba) -> bool
self and other values to be equal, and is used by ==.