pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
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§
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 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