Struct Color

Source
pub struct Color(/* private fields */);

Implementations§

Source§

impl Color

Source

pub fn alloc() -> Color

Allocates a new, transparent black Color.

§Returns

the newly allocated Color; use Color::free to free its resources

Source

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

Source

pub fn add(&self, b: &Color) -> Color

Adds self to b and saves the resulting color inside result.

The alpha channel of result is set as as the maximum value between the alpha channels of self and b.

§b

a Color

§result

return location for the result

Source

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

Source

pub fn init(&mut self, red: u8, green: u8, blue: u8, alpha: u8) -> Option<Color>

Initializes self with the given values.

§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 initialized Color

Source

pub fn interpolate(&self, final_: &Color, progress: f64) -> Color

Interpolates between self and final_ Colors using progress

§final_

the final Color

§progress

the interpolation progress

§result

return location for the interpolation

Source

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

Source

pub fn shade(&self, factor: f64) -> Color

Shades self by factor and saves the modified color into result.

§factor

the shade factor to apply

§result

return location for the shaded color

Source

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

Source

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

Source

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

Source

pub fn from_hls(hue: f32, luminance: f32, saturation: f32) -> Color

Converts a color expressed in HLS (hue, luminance and saturation) values into a Color.

§color

return location for a Color

§hue

hue value, in the 0 .. 360 range

§luminance

luminance value, in the 0 .. 1 range

§saturation

saturation value, in the 0 .. 1 range

Source

pub fn from_pixel(pixel: u32) -> Color

Converts pixel from the packed representation of a four 8 bit channel color to a Color.

§color

return location for a Color

§pixel

a 32 bit packed integer containing a color

Source

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

Source

pub fn get_static(color: StaticColor) -> Option<Color>

Retrieves a static color for the given color name

Static colors are created by Clutter and are guaranteed to always be available and valid

§color

the named global color

§Returns

a pointer to a static color; the returned pointer is owned by Clutter and it should never be modified or freed

Trait Implementations§

Source§

impl Clone for Color

Source§

fn clone(&self) -> Color

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Color

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Color

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StaticType for Color

Source§

fn static_type() -> Type

Returns the type identifier of Self.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToValue for T
where T: SetValue + ?Sized,

Source§

fn to_value(&self) -> Value

Returns a Value clone of self.
Source§

fn to_value_type(&self) -> Type

Returns the type identifer of self. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.