summaryrefslogtreecommitdiff
path: root/src/hitomezashi.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/hitomezashi.rs')
-rw-r--r--src/hitomezashi.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/hitomezashi.rs b/src/hitomezashi.rs
index 155f0b7..b39cace 100644
--- a/src/hitomezashi.rs
+++ b/src/hitomezashi.rs
@@ -43,19 +43,19 @@ pub fn hitomezashi(width: usize, height: usize, skew: Option<f64>) {
let mut row_bits: Vec<bool> = Vec::with_capacity(height - 1);
- for _ in 0..(height - 1) {
+ for _ in 0..row_bits.capacity() {
row_bits.push(brn.sample(&mut rng));
}
let mut col_bits: Vec<bool> = Vec::with_capacity(width - 1);
- for _ in 0..(width - 1) {
+ for _ in 0..col_bits.capacity() {
col_bits.push(brn.sample(&mut rng));
}
let mut alt_bits: Vec<bool> = Vec::with_capacity(width);
- for col in 0..width {
+ for col in 0..alt_bits.capacity() {
alt_bits.push(col % 2 == 1);
}
@@ -64,7 +64,7 @@ pub fn hitomezashi(width: usize, height: usize, skew: Option<f64>) {
above_bits.push(init_bit);
- for col in 0..(width - 1) {
+ for col in 0..(above_bits.capacity() - 1) {
/* each square in the first row is derived from the square to its left. the column bits
* represent whether there's a stitch between the two squares. if there's a stitch, the squares
* are different, otherwise they are the same. */
@@ -72,7 +72,7 @@ pub fn hitomezashi(width: usize, height: usize, skew: Option<f64>) {
above_bits.push(above_bits[col] ^ col_bits[col]);
}
- print_square(above_bits[width - 1]);
+ print_square(above_bits[above_bits.capacity() - 1]);
println!();
// height-1 because the first row has already been printed