diff --git a/src/color.rs b/src/color.rs index 0c5c73f..41d5f6e 100644 --- a/src/color.rs +++ b/src/color.rs @@ -6,19 +6,20 @@ pub struct Color { r: u8, g: u8, b: u8, + a: u8, } impl Color { /// Constructor. /// /// The color channels must be between 0 and 255. - pub fn from(r: u8, g: u8, b: u8) -> Color { - Color { r, g, b } + pub fn from(r: u8, g: u8, b: u8, a: u8) -> Color { + Color { r, g, b, a} } /// Get a hexadecimal representation of the color, /// such as `FFFFFF` for white and `FF0000` for red. pub fn as_hex(self) -> String { - format!("{:02X}{:02X}{:02X}", self.r, self.g, self.b) + format!("{:02X}{:02X}{:02X}{:02X}", self.r, self.g, self.b, self.a) } } diff --git a/src/painter/painter.rs b/src/painter/painter.rs index 870c4d8..16292c1 100644 --- a/src/painter/painter.rs +++ b/src/painter/painter.rs @@ -51,7 +51,7 @@ impl Painter { } // Get an RGB image - let image = self.image.as_mut().unwrap().to_rgb(); + let image = self.image.as_mut().unwrap().to_rgba(); // Loop through all the pixels, and set their color for x in 0..self.area.w { @@ -68,7 +68,8 @@ impl Painter { let channels = pixel.channels(); // Define the color - let color = Color::from(channels[0], channels[1], channels[2]); + let color = Color::from(channels[0], channels[1], channels[2], channels[3]); + // Set the pixel if let Some(client) = &mut self.client {