Browse Source

Minor refactor

Kevin Lee 1 month ago
parent
commit
21228ffce4
1 changed files with 28 additions and 28 deletions
  1. 28 28
      src/config/object.rs

+ 28 - 28
src/config/object.rs

@@ -305,6 +305,29 @@ impl ObjectOperation {
                 let pattern_y: bool =
                     array.pattern_hatch_y.is_some() || array.pattern_pen_y.is_some();
 
+                if let Some(pen_x) = &array.pattern_pen_x {
+                    if pattern_y {
+                        for y in 0..array.rows {
+                            pen_x.pattern(
+                                &mut pens
+                                    .iter_mut()
+                                    .enumerate()
+                                    .skip(array.starting_pen)
+                                    .skip(y * array.columns)
+                                    .take(array.columns),
+                            )
+                        }
+                    } else {
+                        pen_x.pattern(
+                            &mut pens
+                                .iter_mut()
+                                .enumerate()
+                                .skip(array.starting_pen)
+                                .take(array.columns * array.rows),
+                        );
+                    }
+                }
+
                 if let Some(pen_y) = &array.pattern_pen_y {
                     if pattern_x {
                         for x in 0..array.columns {
@@ -331,24 +354,22 @@ impl ObjectOperation {
                     }
                 }
 
-                if let Some(pen_x) = &array.pattern_pen_x {
+                if let Some(hatch_x) = &array.pattern_hatch_x {
                     if pattern_y {
                         for y in 0..array.rows {
-                            pen_x.pattern(
-                                &mut pens
+                            hatch_x.pattern(
+                                &mut new_obj
                                     .iter_mut()
                                     .enumerate()
-                                    .skip(array.starting_pen)
                                     .skip(y * array.columns)
                                     .take(array.columns),
                             )
                         }
                     } else {
-                        pen_x.pattern(
-                            &mut pens
+                        hatch_x.pattern(
+                            &mut new_obj
                                 .iter_mut()
                                 .enumerate()
-                                .skip(array.starting_pen)
                                 .take(array.columns * array.rows),
                         );
                     }
@@ -380,27 +401,6 @@ impl ObjectOperation {
                     }
                 }
 
-                if let Some(hatch_x) = &array.pattern_hatch_x {
-                    if pattern_y {
-                        for y in 0..array.rows {
-                            hatch_x.pattern(
-                                &mut new_obj
-                                    .iter_mut()
-                                    .enumerate()
-                                    .skip(y * array.columns)
-                                    .take(array.columns),
-                            )
-                        }
-                    } else {
-                        hatch_x.pattern(
-                            &mut new_obj
-                                .iter_mut()
-                                .enumerate()
-                                .take(array.columns * array.rows),
-                        );
-                    }
-                }
-
                 if array.randomize_order {
                     debug!("Randomizing draw order of array objects");
                     new_obj.shuffle(&mut thread_rng());