Expand description
Struct for representing colors.
Fields
r: f32
Red component of color
g: f32
Green component of color
b: f32
Blue component of color
a: f32
Alpha component of color
Implementations
sourceimpl Color
impl Color
sourcepub fn rgb(r: u8, g: u8, b: u8) -> Self
pub fn rgb(r: u8, g: u8, b: u8) -> Self
Returns a color value from red, green, blue char values. Alpha will be set to 255.
sourcepub fn rgbf(r: f32, g: f32, b: f32) -> Self
pub fn rgbf(r: f32, g: f32, b: f32) -> Self
Returns a color value from red, green, blue float values. Alpha will be set to 1.0.
sourcepub fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self
pub fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self
Returns a color value from red, green, blue and alpha char values.
sourcepub fn rgbaf(r: f32, g: f32, b: f32, a: f32) -> Self
pub fn rgbaf(r: f32, g: f32, b: f32, a: f32) -> Self
Returns a color value from red, green, blue and alpha char values.
sourcepub fn hsl(h: f32, s: f32, l: f32) -> Self
pub fn hsl(h: f32, s: f32, l: f32) -> Self
Returns color value specified by hue, saturation and lightness. HSL values are all in range [0..1], alpha will be set to 1.0.
sourcepub fn hsla(h: f32, s: f32, l: f32, a: f32) -> Self
pub fn hsla(h: f32, s: f32, l: f32, a: f32) -> Self
Returns color value specified by hue, saturation, lightness and alpha. All values are in range [0..1]
sourcepub fn hex(raw_hex: &str) -> Self
pub fn hex(raw_hex: &str) -> Self
Returns color value for a 6-digit (RRGGBB
) or 8-digit (RRGGBBAA
)
HTML hexadecimal string. Any other length produces rgb(0,0,0)
.
The “#” is optional.
sourcepub fn set_alphaf(&mut self, a: f32)
pub fn set_alphaf(&mut self, a: f32)
Sets transparency of a color value.
sourcepub fn premultiplied(self) -> Self
pub fn premultiplied(self) -> Self
Create premultiplied version of color
Trait Implementations
sourceimpl PartialOrd<Color> for Color
impl PartialOrd<Color> for Color
sourcefn partial_cmp(&self, other: &Color) -> Option<Ordering>
fn partial_cmp(&self, other: &Color) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for Color
impl StructuralPartialEq for Color
Auto Trait Implementations
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more