Crates.io | ascii-forge |
lib.rs | ascii-forge |
version | 0.3.0 |
source | src |
created_at | 2024-02-20 00:41:32.178865 |
updated_at | 2024-10-21 20:35:42.966735 |
description | A Minimal TUI Ascii Application Engine that simplifies the use of crossterm |
homepage | |
repository | https://github.com/TheEmeraldBee/ascii-forge |
max_upload_size | |
id | 1145826 |
size | 105,192 |
An oppinionated terminal canvas rendering engine built off of crossterm with the goal of improving terminal UI/Games without adding any un-needed elements.
Although other terminal UI Engines already exist, like Ratatui, I felt there was a lot of extra elements that wasn't needed for a small application or game.
As well, there aren't many bare-bones terminal canvas engines with as much flexability as would be needed to make a fun game. In order to acomplish this, all elements of the engine are available, at all times.
As said before, Ascii-Forge is oppinionated, you don't have a choice of the backend, crossterm is what you get, but it is the best, and one of the only fully cross-platform terminal engines.
To list off some big differences:
io()
method!Most of the examples will be found in the examples directory
Simplest Example Included Here.
use std::{io, time::Duration};
use ascii_forge::prelude::*;
fn main() -> io::Result<()> {
// Will init the window for you, handling all required procedures.
let mut window = Window::init()?;
// Ask the system to handle panics for us.
handle_panics();
loop {
// Ask the window to draw, handle events, and fix sizing issues.
// Duration is the time for which to poll events before re-rendering.
window.update(Duration::from_millis(200))?;
// Render elements to the window
render!(window,
vec2(0, 0) => [ "Hello World!" ],
vec2(0, 1) => [ "Press `Enter` to exit!".red() ],
vec2(0, 2) => [
"Render ".red(),
"Multiple ".yellow(),
"Elements ",
"In one go!".to_string()
]
);
// Check if the Enter Key was pressed, and exit the app if it was.
if event!(window, Event::Key(e) => e.code == KeyCode::Enter) {
break;
}
}
}