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

Overview

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

Copyright © 2024, Orhun Parmaksız

You might also like...
Slippy map (openstreetmap) widget for egui
Slippy map (openstreetmap) widget for egui

Slippy maps widget for egui. Limitations There are couple of limitations when using this library. Some of them will might probably be lifted at some p

Hotkey widget for egui!
Hotkey widget for egui!

egui-keybind, a hotkey library for egui crates.io | docs.rs | examples | changelogs This library provides a simple egui widget for keybindings (hotkey

A widget library built on top of bevy_ui.
A widget library built on top of bevy_ui.

Sickle UI A widget library built on top of bevy's internal bevy_ui. Example If you clone the repository, you can simply build and run the main example

Conference Monitoring Project based on Image Recognition that uses Rust Language and AWS Rekognition service to get the level of image similarity.

Conference Monitoring System based on Image Recognition in Rust This is a Conference Monitoring Project based on Image Recognition that uses Rust Lang

Adapt the screen's color spectrum according to the hour of the day in order to improve your sleep

circadianlight What It Is Circadian Light is a program, currently only working on Linux with X, that controls the color spectrum of your screen accord

on-screen keyboard display for your coding streams.

⌨ OSKD (On-screen key display) OSKD is an on-screen keyboard display that can be used during streams. It provides an intuitive and easy-to-use interfa

Quickly setup your development environment on your Chromebook/ChromeOS  or any Linux distribution 🐧 ❄️ 💻 🚀 ✨
Quickly setup your development environment on your Chromebook/ChromeOS or any Linux distribution 🐧 ❄️ 💻 🚀 ✨

Crosup 🐧 💻 🚀 ✨ Crosup is a CLI tool to help you quickly setup your development environment on a new Chromebook (ChromeOS) or any Linux distribution

Turn static CLI commands into TUIs with ease
Turn static CLI commands into TUIs with ease

lazycli Turn static CLI commands into TUIs with ease Demo: Usage Pick a command that spits out either a list or table of content, like ls, docker ps,

By mirroring traffic to and from your machine, mirrord surrounds your local service with a mirror image of its cloud environment.
By mirroring traffic to and from your machine, mirrord surrounds your local service with a mirror image of its cloud environment.

mirrord lets you easily mirror traffic from your Kubernetes cluster to your development environment. It comes as both Visual Studio Code extension and

Comments
  • Image for demo

    Image for demo

    The image used for the logo is a bit blurry due to several factors:

    • the resize from the main logo into the png in this lib is using (cubic?) interpolation, which makes all the pixels blurred.
    • the mapping of screen pixels to image pixels isn't on an integer amount, so they leave random gaps between pixels

    These can both be fixed to make a higher fidelity image (but it's a bit of work to get it perfect).

    Here's a half baked attempt that works ok 160x40. I mainly just resized the logo using linear interpolation and redid the text as 30 pt size (the font is Silkscreen)) with a offset shadow layer that is the width of the character cell.

    splash

    image

    To get this perfect, you'd need to align the text so that the outlines of each letter start and end at a multiple of the braille character sizing (x = 2, y = 4) and aim to ensure that only a single color is in each 2x4 area. For the logo, it would probably require some pixel editing. The colors for things rendered in braille need to be a bit brighter also to avoid the background washing them out.

    I noticed that rendering at double this pixel density (e.g. a 320x160 image instead of 160x40 here renders pretty slowly).

    Also, there's a bug that causes a panic if the render area > buffer size (this is something in a lot of widgets, which I try to generally stamp out when possible).

    If you want to start with something higher fidelity than the existing png, then take a look at the gimp xcf file in the website repo.

    opened by joshka 3
Releases(v0.1.3)
  • v0.1.3(Mar 19, 2024)

    ratatui-splash-screen

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

    demo

    Add it to your Ratatui project! ⬇️

    cargo add ratatui-splash-screen
    

    See the documentation for more information.

    [0.1.3] - 2024-03-19

    🐛 Bug Fixes

    • (render) Do not panic when render area is bigger than buffer size by @orhun

    ⚙️ Miscellaneous Tasks

    • (lib) Bump version by @orhun

    Full Changelog: https://github.com/orhun/ratatui-splash-screen/compare/v0.1.2...v0.1.3

    Source code(tar.gz)
    Source code(zip)
  • v0.1.2(Mar 16, 2024)

    ratatui-splash-screen

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

    demo

    Add it to your Ratatui project! ⬇️

    cargo add ratatui-splash-screen
    

    See the documentation for more information.

    [0.1.2] - 2024-03-16

    🐛 Bug Fixes

    • (test) Update the sha256sum in tests by @orhun

    ⚙️ Miscellaneous Tasks

    • (lib) Bump version by @orhun

    Full Changelog: https://github.com/orhun/ratatui-splash-screen /compare/v0.1.1...v0.1.2

    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(Mar 16, 2024)

    ratatui-splash-screen

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

    demo

    Add it to your Ratatui project! ⬇️

    cargo add ratatui-splash-screen
    

    See the documentation for more information.

    [0.1.1] - 2024-03-16

    🎨 Styling

    • (demo) Update the demo image by @orhun

    ⚙️ Miscellaneous Tasks

    • (lib) Bump version by @orhun

    Full Changelog: https://github.com/orhun/ratatui-splash-screen /compare/v0.1.0...v0.1.1

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Mar 16, 2024)

    ratatui-splash-screen

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

    demo

    Add it to your Ratatui project! ⬇️

    cargo add ratatui-splash-screen
    

    See the documentation for more information.

    [0.1.0] - 2024-03-16

    ⚙️ Miscellaneous Tasks

    • (render) Avoid decrementing step if already rendered by @orhun
    • (lib) Implement Clone for SplashScreen by @orhun
    • (lib) Bump version by @orhun

    Full Changelog: https://github.com/orhun/ratatui-splash-screen /compare/v0.1.0-alpha.3...v0.1.0

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0-alpha.3(Mar 15, 2024)

  • v0.1.0-alpha.2(Mar 14, 2024)

  • v0.1.0-alpha.1(Mar 14, 2024)

Owner
Orhun Parmaksız
Building the future of the terminal 🦀 @ratatui-org, creator of @git-cliff ⛰, >_ I package stuff for @archlinux btw 📦
Orhun Parmaksız
Standard Graphics is a command-line tool for printing 2D graphics from any language to any screen.

2D graphics in any programming language with just print statements!

Caleb Winston 123 Nov 20, 2022
A simple and efficient terminal UI implementation with ratatui.rs for getting quick insights from csv files right on the terminal

CSV-GREP csv-grep is an intuitive TUI application writting with ratatui.rs for reading, viewing and quickly analysing csv files right on the terminal.

Anthony Ezeabasili 16 Mar 10, 2024
`ls` alternative with useful info and a splash of color 🎨

?? Natls ?? Why Natls? Showing file permissions Showing file size Showing the date that the file was modified last Showing the user that the file belo

Will 1.2k Dec 19, 2022
A rust crate for rendering large text to the terminal using font8x8 and ratatui.

tui-big-text tui-big-text is a rust crate that renders large pixel text as a ratatui widget using the glyphs from the font8x8 crate. Installation carg

Josh McKinney 7 Sep 7, 2023
Save image from your clipboard 📋 as an image file directly from your command line! 🔥

Clpy ?? Save copied image from clipboard as an image file directly from your command line! Note It works only on windows as of now. I'll be adding sup

Piyush Suthar 13 Nov 28, 2022
A simple library fot creating file explorer for the ratatui crate.

ratatui-explorer ratatui-explorer is a simple library for creating file explorers for ratatui. Features: File explorer functionality. Input handling (

null 5 Feb 29, 2024
A TUI for exploring crates.io using Ratatui

crates-tui crates-tui is a simple terminal user interface explorer for crates.io based on Ratatui. crates-tui.mov It supports features like: copy carg

Ratatui 28 Mar 11, 2024
Cross-platform terminal screen clearing library

ClearScreen Cross-platform terminal screen clearing library. API documentation. Dual-licensed with Apache 2.0 and MIT. Uses Caretaker Maintainership.

null 23 Dec 30, 2022
A screen saver for the terminal 🌃

tnap - Let's take a nap ?? tnap is a screen saver for the terminal. You can rest the terminal in a secure. Features Display images in the terminal and

pigeon-sable 4 Feb 27, 2024
A menu widget for tui-rs ecosystem

tui-menu A menu widget for tui-rs ecosystem. Features Sub menu groups. Intuitive movement. Item's data is generic as long as it Cloneable. Try cargo r

shuo 3 Nov 30, 2022