diff options
Diffstat (limited to 'svgbob/src/buffer/fragment_buffer/fragment/polygon.rs')
-rw-r--r-- | svgbob/src/buffer/fragment_buffer/fragment/polygon.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/svgbob/src/buffer/fragment_buffer/fragment/polygon.rs b/svgbob/src/buffer/fragment_buffer/fragment/polygon.rs index b255aad..46d751f 100644 --- a/svgbob/src/buffer/fragment_buffer/fragment/polygon.rs +++ b/svgbob/src/buffer/fragment_buffer/fragment/polygon.rs @@ -175,9 +175,8 @@ impl Polygon { impl Bounds for Polygon { fn bounds(&self) -> (Point, Point) { - let points: Vec<Point2<f32>> = - self.points.iter().map(|p| **p).collect(); - let aabb = Polyline::new(points, None).local_aabb(); + let pl: Polyline<f32> = self.clone().into(); + let aabb = pl.local_aabb(); (Point::from(*aabb.mins()), Point::from(*aabb.maxs())) } } @@ -196,6 +195,14 @@ impl fmt::Display for Polygon { } } +impl Into<Polyline<f32>> for Polygon { + fn into(self) -> Polyline<f32> { + let points: Vec<Point2<f32>> = + self.points.iter().map(|p| **p).collect(); + Polyline::new(points, None) + } +} + impl<MSG> Into<Node<MSG>> for Polygon { fn into(self) -> Node<MSG> { polygon( |