pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}Expand description
Color is a straight-alpha sRGB color.
Components conventionally range from zero to one but are not clamped by the constructors. Valo premultiplies at the GPU boundary and blends in sRGB space.
Fields§
§r: f32r is the straight red component.
g: f32g is the straight green component.
b: f32b is the straight blue component.
a: f32a is the alpha component.
Implementations§
Source§impl Color
impl Color
Sourcepub const TRANSPARENT: Color
pub const TRANSPARENT: Color
TRANSPARENT is transparent black.
Sourcepub const fn rgba(r: f32, g: f32, b: f32, a: f32) -> Self
pub const fn rgba(r: f32, g: f32, b: f32, a: f32) -> Self
rgba creates a color without clamping its components.
Sourcepub const fn rgb(r: f32, g: f32, b: f32) -> Self
pub const fn rgb(r: f32, g: f32, b: f32) -> Self
rgb creates an opaque color without clamping its components.
Sourcepub fn from_rgba8(r: u8, g: u8, b: u8, a: u8) -> Self
pub fn from_rgba8(r: u8, g: u8, b: u8, a: u8) -> Self
from_rgba8 converts 8-bit sRGB components to floating point.
Sourcepub fn with_alpha(self, a: f32) -> Self
pub fn with_alpha(self, a: f32) -> Self
with_alpha replaces the alpha component without changing RGB.
Sourcepub fn components(self) -> [f32; 4]
pub fn components(self) -> [f32; 4]
components returns straight components as [r, g, b, a].
Sourcepub fn premultiplied(self) -> [f32; 4]
pub fn premultiplied(self) -> [f32; 4]
premultiplied returns [r × a, g × a, b × a, a].
Trait Implementations§
impl Copy 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