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

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, several colors are provided: WHITE BLACK RED GREEN BLUE CYAN MAGENTA YELLOW

Fields

r: f32

Red component

g: f32

Green component

b: f32

Blue component

a: f32

Alpha component

Implementations

impl Color[src]

pub const WHITE: Color[src]

White

pub const BLACK: Color[src]

Black

pub const 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 Clone for Color[src]

impl Copy for Color[src]

impl Debug for Color[src]

impl<'de> Deserialize<'de> for Color[src]

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

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

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

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<(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<(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 PartialEq<Color> for Color[src]

impl Serialize for Color[src]

impl StructuralPartialEq for Color[src]

Auto Trait Implementations

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

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

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

impl<T> Pointable for T

type Init = T

The type for initializers.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,