Crates.io | ratatui-splash-screen |
lib.rs | ratatui-splash-screen |
version | 0.1.4 |
source | src |
created_at | 2024-03-14 19:06:23.371143 |
updated_at | 2024-08-09 18:52:38.687941 |
description | A Ratatui widget to turn any image to a splash screen in your terminal |
homepage | |
repository | https://github.com/orhun/ratatui-splash-screen |
max_upload_size | |
id | 1173697 |
size | 70,701 |
ratatui-splash-screen
A Ratatui widget to turn any image to a splash screen in your terminal ✨
See the demo of gpg-tui for a real world example.
jpg
, png
) into a splash screen!cargo add ratatui ratatui-splash-screen
Create a SplashConfig
and construct a SplashScreen
widget with it.
Then render the widget in a loop using the render
function.
You can check if the splash screen is done rendering by calling is_rendered
.
use std::error::Error;
use std::io::stdout;
use std::time::Duration;
use ratatui::prelude::*;
use ratatui_splash_screen::{SplashConfig, SplashScreen, SplashError};
static SPLASH_CONFIG: SplashConfig = SplashConfig {
image_data: include_bytes!("../assets/splash.png"),
sha256sum: Some("c692ae1f9bd4a03cb6fc74a71cb585a8d70c2eacda8ec95e26aa0d6a0670cffd"),
render_steps: 12,
use_colors: true,
};
fn main() -> Result<(), Box<dyn Error>> {
// create a terminal
let backend = CrosstermBackend::new(stdout());
let mut terminal = Terminal::new(backend)?;
// render splash screen
let mut splash_screen = SplashScreen::new(SPLASH_CONFIG)?;
while !splash_screen.is_rendered() {
terminal.draw(|frame| {
frame.render_widget(&mut splash_screen, frame.size());
})?;
std::thread::sleep(Duration::from_millis(100));
}
Ok(())
}
See the full example here.
render_steps
value for smoother rendering.sha256sum(1)
command on your system to find out the SHA value. You can set it to None
if you don't want to check integrity.See the contribution guidelines.
Licensed under either of Apache License Version 2.0 or The MIT License at your option.
🦀 ノ( º _ º ノ) - respect crables!
Copyright © 2024, Orhun Parmaksız