diff options
Diffstat (limited to 'engine')
| -rw-r--r-- | engine/src/data_types/color.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/engine/src/data_types/color.rs b/engine/src/data_types/color.rs index c5316e6..06df450 100644 --- a/engine/src/data_types/color.rs +++ b/engine/src/data_types/color.rs @@ -1,5 +1,32 @@ use std::ops::{Add, Div, Mul, Neg, Sub}; +pub trait Pixel: sealed::Sealed +{ + type Component; +} + +macro_rules! gen_color { + ($ident: ident, components=($($component: ident),+)) => { + #[derive(Debug, Clone)] + pub struct $ident<Component> + { + $(pub $component: Component),+ + } + + impl<Component> Pixel for $ident<Component> + { + type Component = Component; + } + + impl<Component> sealed::Sealed for $ident<Component> {} + }; +} + +gen_color!(Rgb, components = (r, g, b)); +gen_color!(Rgba, components = (r, g, b, a)); +gen_color!(Luma, components = (l)); +gen_color!(LumaA, components = (l, a)); + #[derive(Debug, Clone, Default)] pub struct Color<Value> { @@ -95,3 +122,8 @@ where } } } + +mod sealed +{ + pub trait Sealed {} +} |
