pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}Expand description
An sRGB color with straight (not premultiplied) alpha.
Fields§
§r: u8Red, 0 to 255.
g: u8Green, 0 to 255.
b: u8Blue, 0 to 255.
a: u8Alpha: 0 is transparent, 255 is opaque.
Implementations§
Source§impl Color
impl Color
Sourcepub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Color
pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Color
A color with alpha: 0 is transparent, 255 is opaque.
Sourcepub const fn hsl(hue: f32, saturation: f32, lightness: f32) -> Color
pub const fn hsl(hue: f32, saturation: f32, lightness: f32) -> Color
An opaque color from a hue in degrees, a saturation and a lightness
from 0 to 1, as CSS’s hsl(): Color::hsl(210.0, 0.5, 0.4) is
hsl(210 50% 40%). The hue wraps around, the others clamp, and a
number that isn’t finite gives opaque black.
Sourcepub const fn hsla(
hue: f32,
saturation: f32,
lightness: f32,
alpha: f32,
) -> Color
pub const fn hsla( hue: f32, saturation: f32, lightness: f32, alpha: f32, ) -> Color
hsl with an alpha from 0 (transparent) to 1 (opaque).
Sourcepub const fn with_alpha(self, alpha: f32) -> Color
pub const fn with_alpha(self, alpha: f32) -> Color
The same color with an alpha from 0 (transparent) to 1 (opaque), clamped. NaN leaves it as it is.
Sourcepub const fn mix(self, other: Color, t: f32) -> Color
pub const fn mix(self, other: Color, t: f32) -> Color
t of the way from this color to other, from 0 to 1, clamped,
each sRGB channel and the alpha on their own, as a style fade
blends. NaN leaves this color as it is.
Trait Implementations§
impl Copy for Color
impl Eq for Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Forget for Color
impl Freeze for Color
impl Move 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