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

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

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

White (#FFFFFFFF)

Black (#000000FF)

Red

Green

Blue

Cyan

Magenta

Yellow

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

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

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

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

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

Convert a packed u32 containing 0xRRGGBBAA into a Color

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

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

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

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]`.

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

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.)

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

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.)

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

Does the Wrong Thing if the Color’s values are not in the range [0.0,1.0]

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

Does the Wrong Thing if the Color’s values are not in the range [0.0,1.0]

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

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

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

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

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

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.