This commit is contained in:
2026-01-27 12:00:34 +01:00
parent 61daa9d79d
commit 40c509e295
17 changed files with 277 additions and 833 deletions

View File

@@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
rand = "0.8"
ratatui = "0.29"
regex = "1"
tui-textarea = { version = "0.7", features = ["search"] }

View File

@@ -6,6 +6,7 @@ mod modal;
mod nav_minimap;
mod sample_browser;
mod scope;
mod sparkles;
mod spectrum;
mod text_input;
mod vu_meter;
@@ -18,6 +19,7 @@ pub use modal::ModalFrame;
pub use nav_minimap::{NavMinimap, NavTile};
pub use sample_browser::{SampleBrowser, TreeLine, TreeLineKind};
pub use scope::{Orientation, Scope};
pub use sparkles::Sparkles;
pub use spectrum::Spectrum;
pub use text_input::TextInputModal;
pub use vu_meter::VuMeter;

View File

@@ -0,0 +1,65 @@
use rand::Rng;
use ratatui::buffer::Buffer;
use ratatui::layout::Rect;
use ratatui::style::{Color, Style};
use ratatui::widgets::Widget;
const CHARS: &[char] = &['·', '✦', '✧', '°', '•', '+', '⋆', '*'];
const COLORS: &[(u8, u8, u8)] = &[
(200, 220, 255),
(255, 200, 150),
(150, 255, 200),
(255, 150, 200),
(200, 150, 255),
];
struct Sparkle {
x: u16,
y: u16,
char_idx: usize,
life: u8,
}
#[derive(Default)]
pub struct Sparkles {
sparkles: Vec<Sparkle>,
}
impl Sparkles {
pub fn tick(&mut self, area: Rect) {
let mut rng = rand::thread_rng();
for _ in 0..3 {
if rng.gen_bool(0.6) {
self.sparkles.push(Sparkle {
x: rng.gen_range(0..area.width),
y: rng.gen_range(0..area.height),
char_idx: rng.gen_range(0..CHARS.len()),
life: rng.gen_range(15..40),
});
}
}
self.sparkles
.iter_mut()
.for_each(|s| s.life = s.life.saturating_sub(1));
self.sparkles.retain(|s| s.life > 0);
}
}
impl Widget for &Sparkles {
fn render(self, area: Rect, buf: &mut Buffer) {
for sparkle in &self.sparkles {
let color = COLORS[sparkle.char_idx % COLORS.len()];
let intensity = (sparkle.life as f32 / 30.0).min(1.0);
let r = (color.0 as f32 * intensity) as u8;
let g = (color.1 as f32 * intensity) as u8;
let b = (color.2 as f32 * intensity) as u8;
if sparkle.x < area.width && sparkle.y < area.height {
let x = area.x + sparkle.x;
let y = area.y + sparkle.y;
let ch = CHARS[sparkle.char_idx];
buf[(x, y)].set_char(ch).set_style(Style::new().fg(Color::Rgb(r, g, b)));
}
}
}
}