From eecb04dcc4348af5fd9161c4ee92d59f23885924 Mon Sep 17 00:00:00 2001 From: Arjun Satarkar Date: Fri, 2 Jun 2023 00:37:04 +0530 Subject: Add improved CLI (written in Rust) --- libhitomezashi/src/pixel_buffer.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libhitomezashi/src/pixel_buffer.rs') diff --git a/libhitomezashi/src/pixel_buffer.rs b/libhitomezashi/src/pixel_buffer.rs index b151906..9b27059 100644 --- a/libhitomezashi/src/pixel_buffer.rs +++ b/libhitomezashi/src/pixel_buffer.rs @@ -4,7 +4,7 @@ use std::ops::{Index, IndexMut}; /// 2D buffer of monochrome (white/black i.e. true/false) pixels pub struct PixelBuffer { - buffer: BitVec, + pub buffer: BitVec, pub width: usize, pub height: usize, } @@ -47,7 +47,7 @@ impl fmt::Display for PixelBuffer { let mut result = String::new(); for y in 0..self.height { for x in 0..self.width { - result.push(if self[x][y] { '1' } else { '0' }) + result.push(if self[x][y] { '█' } else { ' ' }) } result.push('\n') } @@ -81,13 +81,13 @@ mod tests { let mut pixel_buffer = PixelBuffer::new(3, 3); pixel_buffer[1].set(1, true); let result = format!("{}", pixel_buffer); - assert!(result == "000\n010\n000\n"); + assert!(result == " \n █ \n \n"); } #[test] fn rect() { let mut pixel_buffer = PixelBuffer::new(5, 3); pixel_buffer.fill_rect(1, 0, 2, 2); let result = format!("{}", pixel_buffer); - assert!(result == "01100\n01100\n00000\n"); + assert!(result == " ██ \n ██ \n \n"); } } -- cgit v1.2.3-57-g22cb