pre generate grayscale palettes

This commit is contained in:
🪞👃🪞 2025-01-19 22:16:39 +01:00
parent cfa3cad5cb
commit ee28d431bd
7 changed files with 16 additions and 12 deletions

View file

@ -9,6 +9,7 @@ rand = "0.8.5"
crossterm = "0.28.1"
ratatui = { version = "0.29.0", features = [ "unstable-widget-ref", "underline-color" ] }
better-panic = "0.3.0"
konst = { version = "0.3.16", features = [ "rust_1_83" ] }
tek_edn = { path = "../edn" }
tek_input = { path = "../input" }

View file

@ -73,6 +73,14 @@ impl ItemColor {
pub darkest: ItemColor,
}
impl ItemPalette {
pub const G: [Self;256] = {
let mut builder = konst::ArrayBuilder::new();
let mut index = 0;
while !builder.is_full() {
builder.push(ItemPalette::G[index]);
index++;
}
};
pub fn random () -> Self { ItemColor::random().into() }
pub fn random_near (color: Self, distance: f32) -> Self {
color.base.mix(ItemColor::random(), distance).into()