Struct buffer_graphics_lib::color::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) -> Self
pub fn new(r: f32, g: f32, b: f32, a: f32) -> Self
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) -> Self
sourcepub const fn gray(value: u8) -> Self
pub const fn gray(value: u8) -> Self
Create a new color with red
, green
and blue
set to value
and alpha
set to 255
sourcepub const fn from_i32(value: i32) -> Self
pub const fn from_i32(value: i32) -> Self
Convert an i32 into a Color
where bytes match the format [R,G,B,A]
sourcepub fn from_f32_array(array: [f32; 4]) -> Self
pub fn from_f32_array(array: [f32; 4]) -> Self
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more