This commit is contained in:
2026-01-27 12:00:34 +01:00
parent 5456c9414a
commit 324d1feda1
17 changed files with 277 additions and 833 deletions

View File

@@ -1,4 +1,3 @@
use rand::Rng;
use ratatui::layout::{Alignment, Constraint, Layout, Rect};
use ratatui::style::{Color, Style, Stylize};
use ratatui::text::{Line, Span};
@@ -6,56 +5,11 @@ use ratatui::widgets::Paragraph;
use ratatui::Frame;
use tui_big_text::{BigText, PixelSize};
use crate::state::ui::{Sparkle, UiState};
use crate::state::ui::UiState;
const SPARKLE_CHARS: &[char] = &['·', '✦', '✧', '°', '•', '+', '⋆', '*'];
const SPARKLE_COLORS: &[(u8, u8, u8)] = &[
(200, 220, 255),
(255, 200, 150),
(150, 255, 200),
(255, 150, 200),
(200, 150, 255),
];
pub fn render(frame: &mut Frame, area: Rect, ui: &UiState) {
frame.render_widget(&ui.sparkles, area);
pub fn render(frame: &mut Frame, area: Rect, ui: &mut UiState) {
let mut rng = rand::thread_rng();
// Spawn new sparkles
for _ in 0..3 {
if rng.gen_bool(0.6) {
let x = rng.gen_range(0..area.width);
let y = rng.gen_range(0..area.height);
ui.sparkles.push(Sparkle {
x,
y,
char_idx: rng.gen_range(0..SPARKLE_CHARS.len()),
life: rng.gen_range(15..40),
});
}
}
// Age and remove dead sparkles
ui.sparkles.iter_mut().for_each(|s| s.life = s.life.saturating_sub(1));
ui.sparkles.retain(|s| s.life > 0);
// Render sparkles
for sparkle in &ui.sparkles {
let color = SPARKLE_COLORS[sparkle.char_idx % SPARKLE_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;
let ch = SPARKLE_CHARS[sparkle.char_idx];
let span = Span::styled(ch.to_string(), Style::new().fg(Color::Rgb(r, g, b)));
let para = Paragraph::new(Line::from(span));
let sparkle_area = Rect::new(sparkle.x, sparkle.y, 1, 1);
if sparkle_area.x < area.width && sparkle_area.y < area.height {
frame.render_widget(para, sparkle_area);
}
}
// Main content
let author_style = Style::new().fg(Color::Rgb(180, 140, 200));
let link_style = Style::new().fg(Color::Rgb(120, 200, 180));
let license_style = Style::new().fg(Color::Rgb(200, 160, 100));