Expand description
A simple library to visualize 2D matrixes in rust.
- Supports 256 terminal colours using AnsiTerm
- Multiple unicode box character sets supported (plain, retro, thin, rounded, thick, double)
#Example use cases: chess-rs: a chess game
palette-rs: a 256 colors palette
#Example: visualising a chess board
extern crate matrix_display;
use matrix_display::*;
fn main() {
let format = Format::new(7, 3);
let board = vec!['♜', '♞', '♝', '♛', '♚', '♝', '♞', '♜',
'♟', '♟', '♟', '♟', '♟', '♟', '♟', '♟',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
'♖', '♘', '♗', '♕', '♔', '♗', '♘', '♖',
'♙', '♙', '♙', '♙', '♙', '♙', '♙', '♙']
.iter()
.enumerate()
.map(|(i, x)| {
let ansi_fg = 33;
let mut ansi_bg = 0;
if i % 2 + (i / 8) % 2 == 1 {
ansi_bg = 7;
}
cell::Cell::new(x.clone(), ansi_fg, ansi_bg)
})
.collect::<Vec<_>>();
let mut data = matrix::Matrix::new(8, board);
let mut display = MatrixDisplay::new(&format, &mut data);
display.cell_at_cursor_position((13, 6)).color.bg = 10;
display.print(&mut std::io::stdout(), &style::BordersStyle::None);
}
Modules§
- cell
- Stores data to be printed by MatrixDisplay plus colour metada
- matrix
- Provides
Matrix
which stores a matrix of arbitrary data - style
- Personalise the border style of your matric display
Structs§
- Format
- Format of a cell in a matrix
- Matrix
Display - Stores a matrix of data and offers a way to pretty print it