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
r: u8
The red component.
g: u8
The green component.
b: u8
The blue component.
a: u8
The alpha component.
Methods
impl Pixel
[src]
pub fn r_g_b_a(r: u8, g: u8, b: u8, a: u8) -> Self
[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);
pub fn r_g_b(r: u8, g: u8, b: u8) -> Self
[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);
pub fn rgb(rgb: u32) -> Self
[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);
pub fn argb(argb: u32) -> Self
[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);
pub fn rgba(rgba: u32) -> Self
[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);
pub fn rgb_a(rgb: u32, a: u8) -> Self
[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]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Clone for Pixel
[src]
fn clone(&self) -> Pixel
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more