Struct glitter::image_data::Pixel [] [src]

#[repr(C)]
pub struct Pixel { pub r: u8, pub g: u8, pub b: u8, pub a: u8, }

A single OpenGL color value, with u8 components laid out as a C struct in RGBA order. This type is the simplest implementation of Image2d, which allows it to be uploaded to a texture.

Fields

The red component.

The green component.

The blue component.

The alpha component.

Methods

impl Pixel
[src]

[src]

Create an RGBA color, provided each color component.

Examples

let pixel = glitter::Pixel::r_g_b_a(0xAA, 0xBB, 0xCC, 0xDD);
assert_eq!(pixel.r, 0xAA);
assert_eq!(pixel.g, 0xBB);
assert_eq!(pixel.b, 0xCC);
assert_eq!(pixel.a, 0xDD);

[src]

Create an RGBA color, provided the RGB components and using 0xFF as the A value.

Examples

let pixel = glitter::Pixel::r_g_b(0xAA, 0xBB, 0xCC);
assert_eq!(pixel.r, 0xAA);
assert_eq!(pixel.g, 0xBB);
assert_eq!(pixel.b, 0xCC);
assert_eq!(pixel.a, 0xFF);

[src]

Create an RGBA color, provided the RGB components as a packed u32 value. The u32 value will be read as 0x00RRGGBB.

Examples

// The `0x55` component gets discared
let pixel = glitter::Pixel::rgb(0x55AABBCC);
assert_eq!(pixel.r, 0xAA);
assert_eq!(pixel.g, 0xBB);
assert_eq!(pixel.b, 0xCC);
assert_eq!(pixel.a, 0xFF);

[src]

Create an RGBA color value, provided the components as a packed u32 value. The u32 value will be read as 0xAARRGGBB.

Examples

let pixel = glitter::Pixel::argb(0xDDAABBCC);
assert_eq!(pixel.r, 0xAA);
assert_eq!(pixel.g, 0xBB);
assert_eq!(pixel.b, 0xCC);
assert_eq!(pixel.a, 0xDD);

[src]

Create an RGBA color, provided the RGB components as a packed u32 value. The u32 value will be read as 0xRRGGBBAA.

Examples

let pixel = glitter::Pixel::rgba(0xAABBCCDD);
assert_eq!(pixel.r, 0xAA);
assert_eq!(pixel.g, 0xBB);
assert_eq!(pixel.b, 0xCC);
assert_eq!(pixel.a, 0xDD);

[src]

Create an RGBA color, provided the RGB components as a packed u32 value, and a separate A component. The u32 value will be read as 0x00RRGGBB.

Examples

// The `0x55` component gets discarded
let pixel = glitter::Pixel::rgb_a(0x55AABBCC, 0xDD);
assert_eq!(pixel.r, 0xAA);
assert_eq!(pixel.g, 0xBB);
assert_eq!(pixel.b, 0xCC);
assert_eq!(pixel.a, 0xDD);

Trait Implementations

impl Debug for Pixel
[src]

[src]

Formats the value using the given formatter. Read more

impl Clone for Pixel
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for Pixel
[src]

impl Default for Pixel
[src]

[src]

Returns the "default value" for a type. Read more

impl<P: Pixel<Subpixel = u8>> From<P> for Pixel
[src]

[src]

Performs the conversion.