Struct Color

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

Implementations§

Source§

impl Color

Source

pub fn new() -> Color

Creates a new (empty) color

§Returns

a newly-allocated Color. Use Color::free to free the allocated resources

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn init_from_4f(&mut self, red: f32, green: f32, blue: f32, alpha: f32)

Sets the values of the passed channels into a Color

§red

value of the red channel, between 0 and 1.0

§green

value of the green channel, between 0 and 1.0

§blue

value of the blue channel, between 0 and 1.0

§alpha

value of the alpha channel, between 0 and 1.0

Source

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

Source

pub fn init_from_4ub(&mut self, red: u8, green: u8, blue: u8, alpha: u8)

Sets the values of the passed channels into a Color.

§red

value of the red channel, between 0 and 255

§green

value of the green channel, between 0 and 255

§blue

value of the blue channel, between 0 and 255

§alpha

value of the alpha channel, between 0 and 255

Source

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.

Source

pub fn set_alpha(&mut self, alpha: f32)

Sets the alpha channel of self to alpha.

§alpha

a float value between 0.0f and 1.0f

Source

pub fn set_alpha_byte(&mut self, alpha: u8)

Sets the alpha channel of self to alpha.

§alpha

a byte value between 0 and 255

Source

pub fn set_alpha_float(&mut self, alpha: f32)

Sets the alpha channel of self to alpha.

§alpha

a float value between 0.0f and 1.0f

Source

pub fn set_blue(&mut self, blue: f32)

Sets the blue channel of self to blue.

§blue

a float value between 0.0f and 1.0f

Source

pub fn set_blue_byte(&mut self, blue: u8)

Sets the blue channel of self to blue.

§blue

a byte value between 0 and 255

Source

pub fn set_blue_float(&mut self, blue: f32)

Sets the blue channel of self to blue.

§blue

a float value between 0.0f and 1.0f

Source

pub fn set_green(&mut self, green: f32)

Sets the green channel of self to green.

§green

a float value between 0.0f and 1.0f

Source

pub fn set_green_byte(&mut self, green: u8)

Sets the green channel of self to green.

§green

a byte value between 0 and 255

Source

pub fn set_green_float(&mut self, green: f32)

Sets the green channel of self to green.

§green

a float value between 0.0f and 1.0f

Source

pub fn set_red(&mut self, red: f32)

Sets the red channel of self to red.

§red

a float value between 0.0f and 1.0f

Source

pub fn set_red_byte(&mut self, red: u8)

Sets the red channel of self to red.

§red

a byte value between 0 and 255

Source

pub fn set_red_float(&mut self, red: f32)

Sets the red channel of self to red.

§red

a float value between 0.0f and 1.0f

Source

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

Source

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.

Source

pub fn init_from_hsl(hue: f32, saturation: f32, luminance: 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

§saturation

saturation value, in the 0 .. 1 range

§luminance

luminance value, in the 0 .. 1 range

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 Default for Color

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Ord for Color

Source§

fn cmp(&self, other: &Color) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Color

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Color

Source§

fn partial_cmp(&self, other: &Color) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StaticType for Color

Source§

fn static_type() -> Type

Returns the type identifier of Self.
Source§

impl Eq 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> 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> 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.