Feat: add tachyonFX animations
This commit is contained in:
16
src/main.rs
16
src/main.rs
@@ -16,7 +16,7 @@ use std::io;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::atomic::{AtomicBool, AtomicI64, AtomicU32, AtomicU64, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use clap::Parser;
|
||||
use crossterm::event::{self, DisableBracketedPaste, EnableBracketedPaste, Event};
|
||||
@@ -213,6 +213,8 @@ fn main() -> io::Result<()> {
|
||||
let mut terminal = Terminal::new(backend)?;
|
||||
terminal.clear()?;
|
||||
|
||||
let mut last_frame = Instant::now();
|
||||
|
||||
loop {
|
||||
if app.audio.restart_pending {
|
||||
app.audio.restart_pending = false;
|
||||
@@ -369,11 +371,19 @@ fn main() -> io::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
if app.playback.playing || had_event || app.ui.show_title {
|
||||
state::effects::tick_effects(&mut app.ui, app.page);
|
||||
|
||||
let elapsed = last_frame.elapsed();
|
||||
last_frame = Instant::now();
|
||||
|
||||
let effects_active = app.ui.effects.borrow().is_running()
|
||||
|| app.ui.modal_fx.borrow().is_some()
|
||||
|| app.ui.title_fx.borrow().is_some();
|
||||
if app.playback.playing || had_event || app.ui.show_title || effects_active {
|
||||
if app.ui.show_title {
|
||||
app.ui.sparkles.tick(terminal.get_frame().area());
|
||||
}
|
||||
terminal.draw(|frame| views::render(frame, &app, &link, &seq_snapshot))?;
|
||||
terminal.draw(|frame| views::render(frame, &app, &link, &seq_snapshot, elapsed))?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user