--- a/rust/landgen/src/outline.rs Fri Nov 02 21:30:48 2018 +0300
+++ b/rust/landgen/src/outline.rs Fri Nov 02 20:30:22 2018 +0100
@@ -191,6 +191,17 @@
index: 0,
}
}
+
+ pub fn mirror(&mut self) {
+ self.iter_mut()
+ .for_each(|p| p.x = self.size.width() - 1 - p.x);
+ }
+
+ pub fn flip(&mut self) {
+ points
+ .iter_mut()
+ .for_each(|p| p.y = self.size.height() - 1 - p.y);
+ }
}
struct OutlineSegmentsIterator<'a> {
--- a/rust/landgen/src/template_based.rs Fri Nov 02 21:30:48 2018 +0300
+++ b/rust/landgen/src/template_based.rs Fri Nov 02 20:30:22 2018 +0100
@@ -32,9 +32,7 @@
if self.outline_template.can_mirror {
if let Some(b) = random_numbers.next() {
if b & 1 != 0 {
- points
- .iter_mut()
- .for_each(|p| p.x = land.width() as i32 - 1 - p.x);
+ points.mirror();
}
}
}
@@ -43,9 +41,7 @@
if self.outline_template.can_flip {
if let Some(b) = random_numbers.next() {
if b & 1 != 0 {
- points
- .iter_mut()
- .for_each(|p| p.y = land.height() as i32 - 1 - p.y);
+ points.flip();
}
}
}