Struct ggez::graphics::Color [−][src]
A RGBA color in the sRGB
color space represented as f32
's in the range [0.0-1.0]
Fields
r: f32
Red component
g: f32
Green component
b: f32
Blue component
a: f32
Alpha component
Methods
impl Color
[src]
impl Color
pub fn new(r: f32, g: f32, b: f32, a: f32) -> Self
[src]
pub fn new(r: f32, g: f32, b: f32, a: f32) -> Self
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]
pub fn from_rgba(r: u8, g: u8, b: u8, a: u8) -> Color
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]
pub fn from_rgb(r: u8, g: u8, b: u8) -> Color
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]
pub fn to_rgba(self) -> (u8, u8, u8, u8)
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]
pub fn to_rgb(self) -> (u8, u8, u8)
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]
pub fn from_rgba_u32(c: u32) -> Color
Convert a packed u32 containing 0xRRGGBBAA into a Color.conf
pub fn from_rgb_u32(c: u32) -> Color
[src]
pub fn from_rgb_u32(c: u32) -> 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.
pub fn to_rgba_u32(self) -> u32
[src]
pub fn to_rgba_u32(self) -> u32
Convert a Color into a packed u32, containing 0xRRGGBBAA as bytes.
pub fn to_rgb_u32(self) -> u32
[src]
pub fn to_rgb_u32(self) -> u32
Convert a Color into a packed u32, containing 0x00RRGGBB as bytes.
Trait Implementations
impl Copy for Color
[src]
impl Copy for Color
impl Clone for Color
[src]
impl Clone for Color
fn clone(&self) -> Color
[src]
fn clone(&self) -> Color
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for Color
[src]
impl PartialEq for Color
fn eq(&self, other: &Color) -> bool
[src]
fn eq(&self, other: &Color) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Color) -> bool
[src]
fn ne(&self, other: &Color) -> bool
This method tests for !=
.
impl Debug for Color
[src]
impl Debug for Color
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl From<(u8, u8, u8, u8)> for Color
[src]
impl From<(u8, u8, u8, u8)> for Color
fn from(val: (u8, u8, u8, u8)) -> Self
[src]
fn from(val: (u8, u8, u8, u8)) -> Self
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]
impl From<(u8, u8, u8)> for Color
fn from(val: (u8, u8, u8)) -> Self
[src]
fn from(val: (u8, u8, u8)) -> Self
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 (ie, no transparency.)
impl From<[f32; 4]> for Color
[src]
impl From<[f32; 4]> for Color
fn from(val: [f32; 4]) -> Self
[src]
fn from(val: [f32; 4]) -> Self
Turns an [R, G, B, A] array of f32's into a Color with no format changes. All inputs should be in the range
[0.0-1.0]`.
impl From<Color> for (u8, u8, u8, u8)
[src]
impl From<Color> for (u8, u8, u8, u8)
fn from(color: Color) -> Self
[src]
fn from(color: Color) -> Self
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]
impl From<Color> for (u8, u8, u8)
fn from(color: Color) -> Self
[src]
fn from(color: Color) -> Self
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]
impl From<Color> for [f32; 4]