[−][src]Struct ggez::graphics::Color
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]
pub 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 PartialEq<Color> for Color
[src]
impl Clone for Color
[src]
fn clone(&self) -> Color
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
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 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)> 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<(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<Color> for (u8, u8, u8, u8)
[src]
fn from(color: Color) -> Self
[src]
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]
fn from(color: Color) -> Self
[src]
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]
fn from(color: Color) -> Self
[src]
Convert a Color
into an [R, G, B, A]
array of f32
's in the range of [0.0-1.0]
.
impl Copy for Color
[src]
impl Debug for Color
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Scalar for T where
T: Copy + PartialEq<T> + Any + Debug,
[src]
T: Copy + PartialEq<T> + Any + Debug,
impl<T> Same for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<T> Erased for T
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
Sets value
as a parameter of self
.