Struct femtovg::Color[][src]

pub struct Color {
    pub r: f32,
    pub g: f32,
    pub b: f32,
    pub a: f32,
}
Expand description

Struct for representing colors.

Fields

r: f32g: f32b: f32a: f32

Implementations

impl Color[src]

pub fn rgb(r: u8, g: u8, b: u8) -> Self[src]

Returns a color value from red, green, blue char values. Alpha will be set to 255.

pub fn rgbf(r: f32, g: f32, b: f32) -> Self[src]

Returns a color value from red, green, blue float values. Alpha will be set to 1.0.

pub fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self[src]

Returns a color value from red, green, blue and alpha char values.

pub fn rgbaf(r: f32, g: f32, b: f32, a: f32) -> Self[src]

Returns a color value from red, green, blue and alpha char values.

pub fn hsl(h: f32, s: f32, l: f32) -> Self[src]

Returns color value specified by hue, saturation and lightness. HSL values are all in range [0..1], alpha will be set to 1.0.

pub fn hsla(h: f32, s: f32, l: f32, a: f32) -> Self[src]

Returns color value specified by hue, saturation, lightness and alpha. All values are in range [0..1]

pub fn hex(raw_hex: &str) -> Self[src]

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.

pub fn white() -> Self[src]

Returns a white color

pub fn black() -> Self[src]

Returns a black color

pub fn set_alpha(&mut self, a: u8)[src]

Sets transparency of a color value.

pub fn set_alphaf(&mut self, a: f32)[src]

Sets transparency of a color value.

pub fn premultiplied(self) -> Self[src]

pub fn to_array(self) -> [f32; 4][src]

pub fn is_black(&self) -> bool[src]

Trait Implementations

impl Clone for Color[src]

fn clone(&self) -> Color[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Color[src]

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

Formats the value using the given formatter. Read more

impl Default for Color[src]

fn default() -> Self[src]

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

impl PartialEq<Color> for Color[src]

fn eq(&self, other: &Color) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Color) -> bool[src]

This method tests for !=.

impl PartialOrd<Color> for Color[src]

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

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

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Copy for Color[src]

impl StructuralPartialEq for Color[src]

Auto Trait Implementations

impl RefUnwindSafe for Color

impl Send for Color

impl Sync for Color

impl Unpin for Color

impl UnwindSafe for Color

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.