mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-07-18 00:07:00 +02:00
This commit is contained in:
parent
30d378a6ee
commit
bea88ac58d
5 changed files with 27 additions and 15 deletions
12
src/color.rs
12
src/color.rs
|
|
@ -6,7 +6,10 @@ pub(crate) use ::palette::{
|
|||
};
|
||||
use rand::distributions::uniform::UniformSampler;
|
||||
|
||||
pub fn rgb (r: u8, g: u8, b: u8) -> ItemColor { todo!(); }
|
||||
pub fn rgb (r: u8, g: u8, b: u8) -> ItemColor {
|
||||
let term = Color::Rgb(r, g, b);
|
||||
ItemColor { okhsl: rgb_to_okhsl(term), term }
|
||||
}
|
||||
|
||||
pub fn okhsl_to_rgb (color: Okhsl<f32>) -> Color {
|
||||
let Srgb { red, green, blue, .. }: Srgb<f32> = Srgb::from_color_unclamped(color);
|
||||
|
|
@ -30,10 +33,10 @@ pub trait HasColor { fn color (&self) -> ItemColor; }
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq)]
|
||||
pub struct ItemColor {
|
||||
term: Color,
|
||||
okhsl: Okhsl<f32>
|
||||
pub term: Color,
|
||||
pub okhsl: Okhsl<f32>
|
||||
}
|
||||
impl_from!(ItemColor: |term: Color| Self { term, okhsl: rgb_to_okhsl(term) });
|
||||
impl_from!(ItemColor: |okhsl: Okhsl<f32>| Self { okhsl, term: okhsl_to_rgb(okhsl) });
|
||||
|
|
@ -63,6 +66,7 @@ impl ItemColor {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq)]
|
||||
pub struct ItemTheme {
|
||||
pub base: ItemColor,
|
||||
pub light: ItemColor,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue