diff options
author | Arjun Satarkar <me@arjunsatarkar.net> | 2023-06-01 19:07:04 +0000 |
---|---|---|
committer | Arjun Satarkar <me@arjunsatarkar.net> | 2023-06-01 19:07:04 +0000 |
commit | eecb04dcc4348af5fd9161c4ee92d59f23885924 (patch) | |
tree | caddab9b8d38be14edb74d63b6ad7d585dad13bd /libhitomezashi/src/lib.rs | |
parent | 3a2fef94230f35d948634ffef83660afdffa0bad (diff) | |
download | hitomezashi-eecb04dcc4348af5fd9161c4ee92d59f23885924.tar hitomezashi-eecb04dcc4348af5fd9161c4ee92d59f23885924.tar.gz hitomezashi-eecb04dcc4348af5fd9161c4ee92d59f23885924.zip |
Add improved CLI (written in Rust)
Diffstat (limited to 'libhitomezashi/src/lib.rs')
-rw-r--r-- | libhitomezashi/src/lib.rs | 14 |
1 files changed, 6 insertions, 8 deletions
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") } } |