diff options
author | Genny <gen@nyble.dev> | 2021-09-23 20:33:50 -0500 |
---|---|---|
committer | Genny <gen@nyble.dev> | 2021-09-23 20:33:50 -0500 |
commit | 637441239434fabedfe83f5abc1af4232c802f7a (patch) | |
tree | dbc84cd1a31686077fc046fd42d223f1ca08f890 /src/color.rs | |
parent | 7b8081a79fb3db4a76f9e4cca8f8a88e6e7f873c (diff) | |
download | gifed-637441239434fabedfe83f5abc1af4232c802f7a.tar.gz gifed-637441239434fabedfe83f5abc1af4232c802f7a.zip |
Improve API, monocommit, sorry
Diffstat (limited to 'src/color.rs')
-rw-r--r-- | src/color.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/color.rs b/src/color.rs index 764acaf..dd96280 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,4 +1,4 @@ -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, PartialEq)] pub struct Color { pub r: u8, pub g: u8, @@ -20,3 +20,19 @@ impl From<[u8; 3]> for Color { } } } + +impl From<(u8, u8, u8)> for Color { + fn from(t: (u8, u8, u8)) -> Self { + Self { + r: t.0, + g: t.1, + b: t.2, + } + } +} + +impl Into<[u8; 3]> for Color { + fn into(self) -> [u8; 3] { + [self.r, self.g, self.b] + } +} |