pub struct Color(/* private fields */);Implementations§
Source§impl Color
impl Color
Sourcepub fn alloc() -> Color
pub fn alloc() -> Color
Allocates a new, transparent black Color.
§Returns
the newly allocated Color; use
Color::free to free its resources
Sourcepub fn new(red: u8, green: u8, blue: u8, alpha: u8) -> Color
pub fn new(red: u8, green: u8, blue: u8, alpha: u8) -> Color
Creates a new Color with the given values.
This function is the equivalent of:
clutter_color_init (clutter_color_alloc (), red, green, blue, alpha);§red
red component of the color, between 0 and 255
§green
green component of the color, between 0 and 255
§blue
blue component of the color, between 0 and 255
§alpha
alpha component of the color, between 0 and 255
§Returns
the newly allocated color.
Use Color::free when done
Sourcepub fn darken(&self) -> Color
pub fn darken(&self) -> Color
Darkens self by a fixed amount, and saves the changed color
in result.
§result
return location for the darker color
Sourcepub fn interpolate(&self, final_: &Color, progress: f64) -> Color
pub fn interpolate(&self, final_: &Color, progress: f64) -> Color
Sourcepub fn lighten(&self) -> Color
pub fn lighten(&self) -> Color
Lightens self by a fixed amount, and saves the changed color
in result.
§result
return location for the lighter color
Sourcepub fn subtract(&self, b: &Color) -> Color
pub fn subtract(&self, b: &Color) -> Color
Subtracts b from self and saves the resulting color inside result.
This function assumes that the components of self are greater than the
components of b; the result is, otherwise, undefined.
The alpha channel of result is set as the minimum value
between the alpha channels of self and b.
§b
a Color
§result
return location for the result
Sourcepub fn to_hls(&self) -> (f32, f32, f32)
pub fn to_hls(&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
§luminance
return location for the luminance value or None
§saturation
return location for the saturation value or None
Sourcepub fn to_pixel(&self) -> u32
pub fn to_pixel(&self) -> u32
Converts self into a packed 32 bit integer, containing
all the four 8 bit channels used by Color.
§Returns
a packed color
Sourcepub fn from_pixel(pixel: u32) -> Color
pub fn from_pixel(pixel: u32) -> Color
Sourcepub fn from_string(str: &str) -> Option<Color>
pub fn from_string(str: &str) -> Option<Color>
Parses a string definition of a color, filling the Color.red,
Color.green, Color.blue and Color.alpha fields
of color.
The color is not allocated.
The format of str can be either one of:
- a standard name (as taken from the X11 rgb.txt file)
- an hexadecimal value in the form:
#rgb,#rrggbb,#rgba, or#rrggbbaa - a RGB color in the form:
rgb(r, g, b) - a RGB color in the form:
rgba(r, g, b, a) - a HSL color in the form:
hsl(h, s, l)-a HSL color in the form:hsla(h, s, l, a)
where ‘r’, ‘g’, ‘b’ and ‘a’ are (respectively) the red, green, blue color intensities and the opacity. The ‘h’, ‘s’ and ‘l’ are (respectively) the hue, saturation and luminance values.
In the rgb and rgba formats, the ‘r’, ‘g’, and ‘b’ values are either
integers between 0 and 255, or percentage values in the range between 0%
and 100%; the percentages require the ‘%’ character. The ‘a’ value, if
specified, can only be a floating point value between 0.0 and 1.0.
In the hls and hlsa formats, the ‘h’ value (hue) is an angle between
0 and 360.0 degrees; the ‘l’ and ‘s’ values (luminance and saturation) are
percentage values in the range between 0% and 100%. The ‘a’ value, if specified,
can only be a floating point value between 0.0 and 1.0.
Whitespace inside the definitions is ignored; no leading whitespace is allowed.
If the alpha component is not specified then it is assumed to be set to be fully opaque.
§color
return location for a Color
§str
a string specifiying a color
§Returns
true if parsing succeeded, and false otherwise
Sourcepub fn get_static(color: StaticColor) -> Option<Color>
pub fn get_static(color: StaticColor) -> Option<Color>
Trait Implementations§
Source§impl StaticType for Color
impl StaticType for Color
Source§fn static_type() -> Type
fn static_type() -> Type
Self.