Struct pixels_graphics_lib::prelude::Color
source · pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
Expand description
This represents an RGBA color and is used to store a pixel by Image
and PixelsWrapper
Fields§
§r: u8
§g: u8
§b: u8
§a: u8
Implementations§
source§impl Color
impl Color
sourcepub fn new(r: f32, g: f32, b: f32, a: f32) -> Color
pub fn new(r: f32, g: f32, b: f32, a: f32) -> Color
Converts 0.0..=1.0 to 0..=255 Values outside 0.0..=1.0 are clamped
pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Color
sourcepub const fn gray(value: u8) -> Color
pub const fn gray(value: u8) -> Color
Create a new color with red
, green
and blue
set to value
and alpha
set to 255
sourcepub const fn from_i32(value: i32) -> Color
pub const fn from_i32(value: i32) -> Color
Convert an i32 into a Color
where bytes match the format [R,G,B,A]
sourcepub fn from_f32_array(array: [f32; 4]) -> Color
pub fn from_f32_array(array: [f32; 4]) -> Color
Convert f32 array in the format [R,G,B,A] to color where 0.0 = 0, and 1.0 = 255
Trait Implementations§
source§impl<'de> Deserialize<'de> for Color
impl<'de> Deserialize<'de> for Color
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<Color, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Color, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<Color> for TextFormat
impl From<Color> for TextFormat
source§fn from(color: Color) -> TextFormat
fn from(color: Color) -> TextFormat
Converts to this type from the input type.
source§impl PartialEq<Color> for Color
impl PartialEq<Color> for Color
source§impl Serialize for Color
impl Serialize for Color
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for Color
impl Eq for Color
impl StructuralEq for Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for Pwhere
R: Read + ReadEndian<P>,
P: Default,
impl<R, P> ReadPrimitive<R> for Pwhere
R: Read + ReadEndian<P>,
P: Default,
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian()
.