mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-02-21 18:49:04 +01:00
This commit is contained in:
parent
f3fcf663a8
commit
501782f8fe
18 changed files with 841 additions and 908 deletions
|
|
@ -40,16 +40,12 @@ pub trait HasColor { fn color (&self) -> ItemColor; }
|
|||
pub okhsl: Okhsl<f32>,
|
||||
pub rgb: Color,
|
||||
}
|
||||
|
||||
from!(|okhsl: Okhsl<f32>|ItemColor = Self { okhsl, rgb: okhsl_to_rgb(okhsl) });
|
||||
|
||||
from!(ItemColor: |okhsl: Okhsl<f32>|Self { okhsl, rgb: okhsl_to_rgb(okhsl) });
|
||||
from!(ItemColor: |rgb: Color|Self { rgb, okhsl: rgb_to_okhsl(rgb) });
|
||||
pub fn okhsl_to_rgb (color: Okhsl<f32>) -> Color {
|
||||
let Srgb { red, green, blue, .. }: Srgb<f32> = Srgb::from_color_unclamped(color);
|
||||
Color::Rgb((red * 255.0) as u8, (green * 255.0) as u8, (blue * 255.0) as u8,)
|
||||
}
|
||||
|
||||
from!(|rgb: Color|ItemColor = Self { rgb, okhsl: rgb_to_okhsl(rgb) });
|
||||
|
||||
pub fn rgb_to_okhsl (color: Color) -> Okhsl<f32> {
|
||||
if let Color::Rgb(r, g, b) = color {
|
||||
Okhsl::from_color(Srgb::new(r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0))
|
||||
|
|
@ -98,6 +94,8 @@ impl ItemColor {
|
|||
pub darkest: ItemColor,
|
||||
}
|
||||
|
||||
from!(ItemTheme: |base: Color| Self::from_tui_color(base));
|
||||
from!(ItemTheme: |base: ItemColor|Self::from_item_color(base));
|
||||
impl ItemTheme {
|
||||
pub const G: [Self;256] = {
|
||||
let mut builder = konst::array::ArrayBuilder::new();
|
||||
|
|
@ -170,6 +168,3 @@ impl ItemTheme {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
from!(|base: Color| ItemTheme = Self::from_tui_color(base));
|
||||
from!(|base: ItemColor|ItemTheme = Self::from_item_color(base));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue