diff options
| author | HampusM <hampus@hampusmat.com> | 2026-07-16 16:51:29 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-07-16 16:51:29 +0200 |
| commit | b6b4e4a8d14a4fb91af5169a8d1957b23a387ada (patch) | |
| tree | f2e6991e6f2b117059653e15b2eafa5744fd9107 /engine | |
| parent | 5be7004d96560b4a452b063c410637006083f34a (diff) | |
feat(engine): add Rgb, Rgba, Lumen & LumenA color structs
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 {} +} |
