[][src]Struct ggez::graphics::Color

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

A RGBA color in the sRGB color space represented as f32's in the range [0.0-1.0]

For convenience, WHITE and BLACK are provided.

Fields

r: f32

Red component

g: f32

Green component

b: f32

Blue component

a: f32

Alpha component

Methods

impl Color[src]

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

Create a new Color from four f32's in the range [0.0-1.0]

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

Create a new Color from four u8's in the range [0-255]

pub fn from_rgb(r: u8, g: u8, b: u8) -> Color[src]

Create a new Color from three u8's in the range [0-255], with the alpha component fixed to 255 (opaque)

pub fn to_rgba(self) -> (u8, u8, u8, u8)[src]

Return a tuple of four u8's in the range [0-255] with the Color's components.

pub fn to_rgb(self) -> (u8, u8, u8)[src]

Return a tuple of three u8's in the range [0-255] with the Color's components.

pub fn from_rgba_u32(c: u32) -> Color[src]

Convert a packed u32 containing 0xRRGGBBAA into a Color

pub fn from_rgb_u32(c: u32) -> Color[src]

Convert a packed u32 containing 0x00RRGGBB into a Color. This lets you do things like Color::from_rgb_u32(0xCD09AA) easily if you want.

pub fn to_rgba_u32(self) -> u32[src]

Convert a Color into a packed u32, containing 0xRRGGBBAA as bytes.

pub fn to_rgb_u32(self) -> u32[src]

Convert a Color into a packed u32, containing 0x00RRGGBB as bytes.

Trait Implementations

impl PartialEq<Color> for Color[src]

impl Clone for Color[src]

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

Performs copy-assignment from source. Read more

impl From<(u8, u8, u8, u8)> for Color[src]

fn from(val: (u8, u8, u8, u8)) -> Self[src]

Convert a (R, G, B, A) tuple of u8's in the range [0-255] into a Color

impl From<(u8, u8, u8)> for Color[src]

fn from(val: (u8, u8, u8)) -> Self[src]

Convert a (R, G, B) tuple of u8's in the range [0-255] into a Color, with a value of 255 for the alpha element (i.e., no transparency.)

impl From<[f32; 4]> for Color[src]

fn from(val: [f32; 4]) -> Self[src]

Turns an [R, G, B, A] array off32's into aColorwith no format changes. All inputs should be in the range[0.0-1.0]`.

impl From<(f32, f32, f32)> for Color[src]

fn from(val: (f32, f32, f32)) -> Self[src]

Convert a (R, G, B) tuple of f32's in the range [0.0-1.0] into a Color, with a value of 1.0 to for the alpha element (ie, no transparency.)

impl From<(f32, f32, f32, f32)> for Color[src]

fn from(val: (f32, f32, f32, f32)) -> Self[src]

Convert a (R, G, B, A) tuple of f32's in the range [0.0-1.0] into a Color

impl From<Color> for (u8, u8, u8, u8)[src]

fn from(color: Color) -> Self[src]

Convert a Color into a (R, G, B, A) tuple of u8's in the range of [0-255].

impl From<Color> for (u8, u8, u8)[src]

fn from(color: Color) -> Self[src]

Convert a Color into a (R, G, B) tuple of u8's in the range of [0-255], ignoring the alpha term.

impl From<Color> for [f32; 4][src]

fn from(color: Color) -> Self[src]

Convert a Color into an [R, G, B, A] array of f32's in the range of [0.0-1.0].

impl Copy for Color[src]

impl Debug for Color[src]

Auto Trait Implementations

impl Send for Color

impl Sync for Color

Blanket Implementations

impl<T> From for T[src]

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

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

type Owned = T

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

type Error = !

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

The type returned in the event of a conversion error.

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

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

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

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

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

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

The type returned in the event of a conversion error.

impl<T> Scalar for T where
    T: Copy + PartialEq<T> + Any + Debug
[src]

fn is<T>() -> bool where
    T: Scalar
[src]

Tests if Self the same as the type T Read more

impl<T> Same for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf for SP where
    SS: SubsetOf<SP>, 

impl<T> Erased for T

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.