add alpha component

png-branch
an 2019-02-09 14:11:45 -05:00
parent 77bcbcd78d
commit f39d0dbed8
1 changed files with 15 additions and 4 deletions

View File

@ -62,6 +62,7 @@ pub trait Color
fn r(&self) -> Self::Output; fn r(&self) -> Self::Output;
fn g(&self) -> Self::Output; fn g(&self) -> Self::Output;
fn b(&self) -> Self::Output; fn b(&self) -> Self::Output;
fn a(&self) -> Self::Output;
} }
impl Image16 impl Image16
@ -126,7 +127,7 @@ impl Color16
{ {
pub const fn new(r: u16, g: u16, b: u16) -> Color16 pub const fn new(r: u16, g: u16, b: u16) -> Color16
{ {
Color16(r, g, b) Color16(r, g, b, u16::max_value())
} }
} }
@ -149,13 +150,18 @@ impl Color for Color16
{ {
self.2 self.2
} }
fn a(&self) -> u16
{
self.3
}
} }
impl Color8 impl Color8
{ {
pub const fn new(r: u8, g: u8, b: u8) -> Color8 pub const fn new(r: u8, g: u8, b: u8) -> Color8
{ {
Color8(r, g, b) Color8(r, g, b, u8::max_value())
} }
} }
@ -178,15 +184,20 @@ impl Color for Color8
{ {
self.2 self.2
} }
fn a(&self) -> u8
{
self.3
}
} }
/// A RGB16 color. /// A RGB16 color.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Color16(u16, u16, u16); pub struct Color16(u16, u16, u16, u16);
/// A RGB8 color. /// A RGB8 color.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Color8(u8, u8, u8); pub struct Color8(u8, u8, u8, u8);
/// RGB16 image. /// RGB16 image.
pub struct Image16 pub struct Image16