#[repr(C)]pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}Expand description
A color in linear RGB with straight (not premultiplied) alpha: the space densa blends in.
Write colors the way designers specify them, as sRGB hex (Color::srgb); they are
converted to linear once, here. Render targets are sRGB, so the GPU converts back on
output and the hex value is what appears on screen.
Fields§
§r: f32Red, linear, 0 to 1.
g: f32Green, linear, 0 to 1.
b: f32Blue, linear, 0 to 1.
a: f32Opacity, 0 (transparent) to 1 (opaque).
Implementations§
Source§impl Color
impl Color
Sourcepub const TRANSPARENT: Color
pub const TRANSPARENT: Color
Fully transparent black (the default).
Sourcepub fn with_alpha(self, alpha: f32) -> Color
pub fn with_alpha(self, alpha: f32) -> Color
The same color with opacity alpha, clamped to 0..=1 (NaN becomes 0).
Sourcepub fn to_srgb_hex(self) -> u32
pub fn to_srgb_hex(self) -> u32
The nearest sRGB value 0xRRGGBB, ignoring alpha.
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