#ratatui #tui #terminal #splash #console #file-integrity

ratatui-splash-screen

A Ratatui widget to turn any image to a splash screen in your terminal

8 releases

0.1.4 Aug 9, 2024
0.1.3 Mar 19, 2024

#138 in Command-line interface

Download history 42/week @ 2024-08-01 299/week @ 2024-08-08 154/week @ 2024-08-15 187/week @ 2024-08-22 161/week @ 2024-08-29 78/week @ 2024-09-05 394/week @ 2024-09-12 1201/week @ 2024-09-19 3716/week @ 2024-09-26 3676/week @ 2024-10-03 3672/week @ 2024-10-10 3655/week @ 2024-10-17 3654/week @ 2024-10-24 3660/week @ 2024-10-31 3678/week @ 2024-11-07 3072/week @ 2024-11-14

14,591 downloads per month
Used in gpg-tui

MIT/Apache

26KB
230 lines

ratatui-splash-screen

A Ratatui widget to turn any image to a splash screen in your terminal ✨

demo

crates.io badge docs.rs badge license badge codecov.io badge discord badge

See the demo of gpg-tui for a real world example.

Features

  • Turn any image (jpg, png) into a splash screen!
  • Verifies the file integrity via checking SHA checksum (optional)
  • Supports grayscaling

Installation

deps.rs badge

cargo add ratatui ratatui-splash-screen

Usage

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.

Examples

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.

Tips

  • Use small images (such as 200x200) for a better experience.
  • You can tweak the render_steps value for smoother rendering.
  • Run 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.

Contributing

See the contribution guidelines.

License

License: MIT License: Apache 2.0

Licensed under either of Apache License Version 2.0 or The MIT License at your option.

🦀 ノ( º _ º ノ) - respect crables!

Copyright © 2024, Orhun Parmaksız

Dependencies

~11–20MB
~305K SLoC