rust/landgen/src/outline.rs
changeset 14140 7f5a591e1c43
parent 14139 09f62bb046ef
child 14142 3119d665d3c6
--- a/rust/landgen/src/outline.rs	Mon Nov 05 21:21:53 2018 +0300
+++ b/rust/landgen/src/outline.rs	Mon Nov 05 22:43:58 2018 +0300
@@ -1,7 +1,7 @@
 use itertools::Itertools;
 use std::cmp::min;
 
-use integral_geometry::{Line, Ray, Point, Polygon, Rect, Size};
+use integral_geometry::{Line, Ray, Point, Polygon, Rect, RectInclusive, Size};
 use land2d::Land2D;
 
 use outline_template::OutlineTemplate;
@@ -10,14 +10,14 @@
     pub islands: Vec<Polygon>,
     pub fill_points: Vec<Point>,
     pub size: Size,
-    pub play_box: Rect,
-    intersections_box: Rect,
+    pub play_box: RectInclusive,
+    intersections_box: RectInclusive,
 }
 
 impl OutlinePoints {
     pub fn from_outline_template<I: Iterator<Item = u32>>(
         outline_template: &OutlineTemplate,
-        play_box: Rect,
+        play_box: RectInclusive,
         size: Size,
         random_numbers: &mut I,
     ) -> Self {
@@ -38,7 +38,7 @@
                 })
                 .collect(),
             fill_points: outline_template.fill_points.clone(),
-            intersections_box: Rect::at_origin(size)
+            intersections_box: RectInclusive::at_origin(size)
                 .with_margin(size.to_square().width as i32 * -2),
         }
     }
@@ -73,7 +73,11 @@
         }
 
         #[inline]
-        fn solve_intersection(intersections_box: &Rect, ray: &Ray, edge: &Line) -> Option<(i32, u32)>
+        fn solve_intersection(
+            intersections_box: &RectInclusive,
+            ray: &Ray,
+            edge: &Line
+        ) -> Option<(i32, u32)>
         {
             let edge_dir = edge.scaled_direction();
             let aqpb = ray.direction.cross(edge_dir) as i64;
@@ -302,15 +306,16 @@
 
 #[test()]
 fn points_test() {
+    let size = Size::square(100);
     let mut points = OutlinePoints {
         islands: vec![
             Polygon::new(&[Point::new(0, 0), Point::new(20, 0), Point::new(30, 30)]),
             Polygon::new(&[Point::new(10, 15), Point::new(15, 20), Point::new(20, 15)]),
         ],
         fill_points: vec![Point::new(1, 1)],
-        play_box: Rect::from_box(0, 100, 0, 100).with_margin(10),
+        play_box: RectInclusive::at_origin(size).with_margin(10),
         size: Size::square(100),
-        intersections_box: Rect::from_box(0, 0, 100, 100),
+        intersections_box: RectInclusive::at_origin(size),
     };
 
     let segments: Vec<Line> = points.segments_iter().collect();