pub struct Color(/* private fields */);
Implementations§
Source§impl Color
impl Color
Sourcepub fn new() -> Color
pub fn new() -> Color
Creates a new (empty) color
§Returns
a newly-allocated Color
. Use Color::free
to free the allocated resources
Sourcepub fn get_alpha(&self) -> f32
pub fn get_alpha(&self) -> f32
Retrieves the alpha channel of self
as a fixed point
value between 0 and 1.0.
§Returns
the alpha channel of the passed color
Sourcepub fn get_alpha_byte(&self) -> u8
pub fn get_alpha_byte(&self) -> u8
Retrieves the alpha channel of self
as a byte value
between 0 and 255
§Returns
the alpha channel of the passed color
Sourcepub fn get_alpha_float(&self) -> f32
pub fn get_alpha_float(&self) -> f32
Retrieves the alpha channel of self
as a floating point
value between 0.0 and 1.0
§Returns
the alpha channel of the passed color
Sourcepub fn get_blue(&self) -> f32
pub fn get_blue(&self) -> f32
Retrieves the blue channel of self
as a fixed point
value between 0 and 1.0.
§Returns
the blue channel of the passed color
Sourcepub fn get_blue_byte(&self) -> u8
pub fn get_blue_byte(&self) -> u8
Retrieves the blue channel of self
as a byte value
between 0 and 255
§Returns
the blue channel of the passed color
Sourcepub fn get_blue_float(&self) -> f32
pub fn get_blue_float(&self) -> f32
Retrieves the blue channel of self
as a floating point
value between 0.0 and 1.0
§Returns
the blue channel of the passed color
Sourcepub fn get_green(&self) -> f32
pub fn get_green(&self) -> f32
Retrieves the green channel of self
as a fixed point
value between 0 and 1.0.
§Returns
the green channel of the passed color
Sourcepub fn get_green_byte(&self) -> u8
pub fn get_green_byte(&self) -> u8
Retrieves the green channel of self
as a byte value
between 0 and 255
§Returns
the green channel of the passed color
Sourcepub fn get_green_float(&self) -> f32
pub fn get_green_float(&self) -> f32
Retrieves the green channel of self
as a floating point
value between 0.0 and 1.0
§Returns
the green channel of the passed color
Sourcepub fn get_red(&self) -> f32
pub fn get_red(&self) -> f32
Retrieves the red channel of self
as a fixed point
value between 0 and 1.0.
§Returns
the red channel of the passed color
Sourcepub fn get_red_byte(&self) -> u8
pub fn get_red_byte(&self) -> u8
Retrieves the red channel of self
as a byte value
between 0 and 255
§Returns
the red channel of the passed color
Sourcepub fn get_red_float(&self) -> f32
pub fn get_red_float(&self) -> f32
Retrieves the red channel of self
as a floating point
value between 0.0 and 1.0
§Returns
the red channel of the passed color
Sourcepub fn init_from_4fv(&mut self, color_array: &[f32])
pub fn init_from_4fv(&mut self, color_array: &[f32])
Sets the values of the passed channels into a Color
§color_array
a pointer to an array of 4 float color components
Sourcepub fn premultiply(&mut self)
pub fn premultiply(&mut self)
Converts a non-premultiplied color to a pre-multiplied color. For example, semi-transparent red is (1.0, 0, 0, 0.5) when non-premultiplied and (0.5, 0, 0, 0.5) when premultiplied.
Sourcepub fn set_alpha_byte(&mut self, alpha: u8)
pub fn set_alpha_byte(&mut self, alpha: u8)
Sourcepub fn set_alpha_float(&mut self, alpha: f32)
pub fn set_alpha_float(&mut self, alpha: f32)
Sourcepub fn set_blue_byte(&mut self, blue: u8)
pub fn set_blue_byte(&mut self, blue: u8)
Sourcepub fn set_blue_float(&mut self, blue: f32)
pub fn set_blue_float(&mut self, blue: f32)
Sourcepub fn set_green_byte(&mut self, green: u8)
pub fn set_green_byte(&mut self, green: u8)
Sourcepub fn set_green_float(&mut self, green: f32)
pub fn set_green_float(&mut self, green: f32)
Sourcepub fn set_red_byte(&mut self, red: u8)
pub fn set_red_byte(&mut self, red: u8)
Sourcepub fn set_red_float(&mut self, red: f32)
pub fn set_red_float(&mut self, red: f32)
Sourcepub fn to_hsl(&self) -> (f32, f32, f32)
pub fn to_hsl(&self) -> (f32, f32, f32)
Converts self
to the HLS format.
The hue
value is in the 0 .. 360 range. The luminance
and
saturation
values are in the 0 .. 1 range.
§hue
return location for the hue value or None
§saturation
return location for the saturation value or None
§luminance
return location for the luminance value or None
Sourcepub fn unpremultiply(&mut self)
pub fn unpremultiply(&mut self)
Converts a pre-multiplied color to a non-premultiplied color. For example, semi-transparent red is (0.5, 0, 0, 0.5) when premultiplied and (1.0, 0, 0, 0.5) when non-premultiplied.
Trait Implementations§
Source§impl Ord for Color
impl Ord for Color
Source§impl PartialOrd for Color
impl PartialOrd for Color
Source§impl StaticType for Color
impl StaticType for Color
Source§fn static_type() -> Type
fn static_type() -> Type
Self
.