pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
Expand description
Struct for representing colors.
Fields§
§r: f32
§g: f32
§b: f32
§a: f32
Implementations§
source§impl 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 const fn rgbf(r: f32, g: f32, b: f32) -> Self
pub const 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 const fn rgbaf(r: f32, g: f32, b: f32, a: f32) -> Self
pub const 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.
pub fn premultiplied(self) -> Self
pub const fn to_array(self) -> [f32; 4]
pub fn is_black(&self) -> bool
Trait Implementations§
source§impl PartialEq for Color
impl PartialEq for Color
source§impl PartialOrd for Color
impl PartialOrd for Color
1.0.0 · source§fn 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 moreimpl 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 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