use crate::*;
pub trait IntoArray <T, const N : usize> {
fn into_array (self) -> [T; N];
}
pub trait Normalize {
type Target;
fn normalize (self) -> Self::Target;
}
pub trait Normalized {
fn normalized_rgb (self) -> [f32; 3];
fn normalized_rgba (self) -> [f32; 4];
}
pub trait Quantize {
type Target;
fn quantize (self) -> Self::Target;
}
pub trait WithAlphaOpaque {
type Target;
fn rgba (self) -> Self::Target;
}
impl Normalized for Rgb <u8> {
fn normalized_rgb (self) -> [f32; 3] {
self.normalize().into()
}
fn normalized_rgba (self) -> [f32; 4] {
self.normalize().rgba().into()
}
}
impl Normalized for Rgba <u8> {
fn normalized_rgb (self) -> [f32; 3] {
self.rgb().normalize().into()
}
fn normalized_rgba (self) -> [f32; 4] {
self.normalize().into()
}
}
impl IntoArray <u8, 3> for Rgb <u8> {
fn into_array (self) -> [u8; 3] {
self.into()
}
}
impl IntoArray <u8, 4> for Rgba <u8> {
fn into_array (self) -> [u8; 4] {
self.into()
}
}
impl IntoArray <f32, 3> for Rgb <f32> {
fn into_array (self) -> [f32; 3] {
self.into()
}
}
impl IntoArray <f32, 4> for Rgba <f32> {
fn into_array (self) -> [f32; 4] {
self.into()
}
}
impl Normalize for Rgb <u8> {
type Target = Rgb <f32>;
fn normalize (self) -> Self::Target {
normalize_rgb (self)
}
}
impl Normalize for Rgba <u8> {
type Target = Rgba <f32>;
fn normalize (self) -> Self::Target {
normalize_rgba (self)
}
}
impl Quantize for Rgb <f32> {
type Target = Rgb <u8>;
fn quantize (self) -> Self::Target {
quantize_rgb (self)
}
}
impl Quantize for Rgba <f32> {
type Target = Rgba <u8>;
fn quantize (self) -> Self::Target {
quantize_rgba (self)
}
}
impl WithAlphaOpaque for Rgb <u8> {
type Target = Rgba <u8>;
fn rgba (self) -> Self::Target {
self.with_alpha (255)
}
}
impl WithAlphaOpaque for Rgb <f32> {
type Target = Rgba <f32>;
fn rgba (self) -> Self::Target {
self.with_alpha (1.0)
}
}