TERMINAL GRAPHICS BBS v1.1.0 - CONNECTED 64000 BAUD
TERMINAL GRAPHICS
zero dependencies | 100% Rust | 16 ANSI colours
$ cargo add terminal_graphics_
> PLAY SNAKE
Everything on this screen is drawn by the library: each frame a Rust
program fills a Display with Container,
Rect, Text and Graphics, and this page
only paints the cells. Click the screen, then use the arrow keys or WASD.
ENTER starts.
loading game.wasm ...
> WHAT IT IS GOOD AT
+--------------------------------------------------------------+ | A Display is a grid of Pixels: a char, a fg and a bg colour. | | Draw into it, then print it. Output is plain ANSI codes. | +--------------------------------------------------------------+
- No dependencies. The crate and its tests are 100% Rust, nothing else is pulled in.
- Small API.
Display,Graphic,Graphics,Container,Text,RectandBall. ImplementGraphicto draw your own shapes. - Flicker free animation. Each frame is redrawn in place.
Graphicskeeps named graphics and draws them in order. - Colour. The 16 ANSI colours, plus
Colour::from_rgbto pick the nearest one for gradients. - Safe by design. Anything off screen is clipped, and nothing panics or hangs on bad coordinates.
- Easy to test.
Display::renderandwrite_togive you the output as a string or on any writer.
> HELLO, TERMINAL
use terminal_graphics::{Colour, Container, Display, Graphic, Text};
fn main() -> std::io::Result<()> {
// A 40 column by 10 row display.
let mut display = Display::new(40, 10);
display.reserve_space()?;
// A bordered box holding some text.
let container = Container::new(5, 2, 24, 5, Colour::BrightGreen, Colour::Blue)
.with_content(Text::new(1, 1, "Hello, terminal!", Colour::BrightYellow, Colour::Blue));
container.draw(&mut display);
display.print()
}
Run the full animated tour yourself with
cargo run --example demo.
> THE PALETTE
Black
Red
Green
Yellow
Blue
Magenta
Cyan
White
BrightBlack
BrightRed
BrightGreen
BrightYellow
BrightBlue
BrightMagenta
BrightCyan
BrightWhite
> LINKS
- GitHub repository - source, issues, changelog
- crates.io/crates/terminal_graphics
- docs.rs/terminal_graphics - API documentation