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/lib.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'libhitomezashi/src/lib.rs') diff --git a/libhitomezashi/src/lib.rs b/libhitomezashi/src/lib.rs index b07057a..c2f302e 100644 --- a/libhitomezashi/src/lib.rs +++ b/libhitomezashi/src/lib.rs @@ -1,5 +1,5 @@ mod pixel_buffer; -pub use bitvec::vec::BitVec; +use bitvec::prelude::*; use pixel_buffer::PixelBuffer; pub fn get_hitomezashi_pattern( @@ -52,12 +52,10 @@ mod tests { #[test] fn test() { - let mut x_pattern = BitVec::new(); - x_pattern.resize(40, false); - x_pattern.set(1, true); - let mut y_pattern = BitVec::new(); - y_pattern.resize(40, false); - y_pattern.set(1, true); - println!("{}", get_hitomezashi_pattern(x_pattern, y_pattern, 3, 1)); + let x_pattern = bitvec![1, 1, 0, 1, 1, 1]; + let y_pattern = bitvec![0, 1, 1, 0, 0, 0]; + let result = format!("{}", get_hitomezashi_pattern(x_pattern, y_pattern, 3, 1)); + println!("{}", result); + assert!(result == "███ ███ ███ \n █ \n █ \n█ ████ ████ ███\n█ █ █ █ █ \n█ █ █ █ █ \n ████ ████ ███\n █ \n █ \n████ ████ ████ \n█ █ █ █ █ \n█ █ █ █ █ \n████ ████ ████ \n █ \n █ \n████ ████ ████ \n█ █ █ █ █ \n█ █ █ █ █ \n") } } -- cgit v1.2.3-57-g22cb