From 82c0f78177b4e586daeb1e32a88a99b7d1762013 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Sun, 14 Nov 2021 18:01:31 +0000 Subject: [PATCH] Into impls for Colour (are these necessary?) --- src/colour.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/colour.rs b/src/colour.rs index 78652e0..1aac603 100644 --- a/src/colour.rs +++ b/src/colour.rs @@ -1,5 +1,7 @@ use std::fmt; +use image; +use image::Rgba; use serde_derive::{Serialize, Deserialize}; #[derive(Debug, Eq, PartialEq, Serialize, Deserialize)] @@ -37,6 +39,18 @@ impl Into> for Colour { } } +impl Into> for Colour { + fn into(self) -> Rgba { + Rgba::from([self.red, self.green, self.blue, 255]) + } +} + +impl Into<[u8; 4]> for Colour { + fn into(self) -> [u8; 4] { + [self.red, self.green, self.blue, 255] + } +} + #[cfg(test)] mod test { use crate::Colour;