Struct tiny_skia::Color[][src]

pub struct Color { /* fields omitted */ }

An RGBA color value, holding four floating point components.

Guarantees

  • All values are in 0..=1 range.

Implementations

impl Color[src]

pub const TRANSPARENT: Color[src]

A transparent color.

pub const BLACK: Color[src]

A black color.

pub const WHITE: Color[src]

A white color.

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

Creates a new color from 4 components.

All values must be in 0..=1 range.

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

Creates a new color from 4 components.

u8 will be divided by 255 to get the float component.

pub fn red(&self) -> f32[src]

Returns color’s red component.

The value is guarantee to be in a 0..=1 range.

pub fn green(&self) -> f32[src]

Returns color’s green component.

The value is guarantee to be in a 0..=1 range.

pub fn blue(&self) -> f32[src]

Returns color’s blue component.

The value is guarantee to be in a 0..=1 range.

pub fn alpha(&self) -> f32[src]

Returns color’s alpha component.

The value is guarantee to be in a 0..=1 range.

pub fn set_red(&mut self, c: f32)[src]

Sets the red component value.

The new value will be clipped to the 0..=1 range.

pub fn set_green(&mut self, c: f32)[src]

Sets the green component value.

The new value will be clipped to the 0..=1 range.

pub fn set_blue(&mut self, c: f32)[src]

Sets the blue component value.

The new value will be clipped to the 0..=1 range.

pub fn set_alpha(&mut self, c: f32)[src]

Sets the alpha component value.

The new value will be clipped to the 0..=1 range.

pub fn apply_opacity(&mut self, opacity: f32)[src]

Shifts color’s opacity.

Essentially, multiplies color’s alpha by opacity.

opacity will be clamped to the 0..=1 range first. The final alpha will also be clamped.

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

Check that color is opaque.

Alpha == 1.0

pub fn premultiply(&self) -> PremultipliedColor[src]

Converts into a premultiplied color.

pub fn to_color_u8(&self) -> ColorU8[src]

Converts into ColorU8.

Trait Implementations

impl Clone for Color[src]

impl Copy for Color[src]

impl Debug for Color[src]

impl PartialEq<Color> 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]

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.