1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
pub mod line;
pub mod image;
pub mod point_path;
pub mod shape;
pub mod text;
use {Point, Range, Rect};
pub fn bounding_box_for_points<I>(mut points: I) -> Rect
where I: Iterator<Item=Point>,
{
points.next().map(|first| {
let start_rect = Rect {
x: Range { start: first[0], end: first[0] },
y: Range { start: first[1], end: first[1] },
};
points.fold(start_rect, Rect::stretch_to_point)
}).unwrap_or_else(|| Rect::from_xy_dim([0.0, 0.0], [0.0, 0.0]))
}