Add Color trait

This commit is contained in:
Joscha 2024-03-04 23:46:47 +01:00
parent fd1b337cd1
commit 59a1235b1d
4 changed files with 166 additions and 1 deletions

View file

@ -5,6 +5,7 @@ edition.workspace = true
[dependencies]
anyhow = "1.0.80"
palette = "0.7.5"
[lints]
workspace = true

View file

@ -0,0 +1,11 @@
use palette::Srgb;
pub trait Color: Copy {
/// Convert to an sRGB color.
///
/// Useful for debugging or dithering.
fn to_srgb(self) -> Srgb;
/// Combine two colors by putting one "over" the other.
fn over(self, below: Self) -> Self;
}

View file

@ -1,6 +1,7 @@
pub use crate::{buffer::*, rect::*, vec2::*, view::*, widget::*};
pub use crate::{buffer::*, color::*, rect::*, vec2::*, view::*, widget::*};
mod buffer;
mod color;
mod rect;
mod vec2;
mod view;