summaryrefslogtreecommitdiffstats
path: root/svgbob/src/buffer/fragment_buffer/fragment/rect.rs
diff options
context:
space:
mode:
authorJovansonlee Cesar <ivanceras@gmail.com>2021-07-12 20:37:56 +0800
committerJovansonlee Cesar <ivanceras@gmail.com>2021-07-12 20:37:56 +0800
commit039c74fefaab4c7226de57f258072fb6a5974722 (patch)
tree81c8d55990f7da6ea9c6398f247f767fce119845 /svgbob/src/buffer/fragment_buffer/fragment/rect.rs
parentd379b7fe9ae6fa79d553715329d638301600319f (diff)
Initial migration from ncollide2d to parry2d
Diffstat (limited to 'svgbob/src/buffer/fragment_buffer/fragment/rect.rs')
-rw-r--r--svgbob/src/buffer/fragment_buffer/fragment/rect.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/svgbob/src/buffer/fragment_buffer/fragment/rect.rs b/svgbob/src/buffer/fragment_buffer/fragment/rect.rs
index 27264a8..0978bf4 100644
--- a/svgbob/src/buffer/fragment_buffer/fragment/rect.rs
+++ b/svgbob/src/buffer/fragment_buffer/fragment/rect.rs
@@ -1,6 +1,5 @@
use crate::{fragment::Bounds, util, Cell, Point};
-use std::fmt;
-
+use ncollide2d::shape::ConvexPolygon;
use ncollide2d::shape::{Polyline, Segment, Shape};
use sauron::{
html::attributes::*,
@@ -8,6 +7,7 @@ use sauron::{
Node,
};
use std::cmp::Ordering;
+use std::fmt;
#[derive(Debug, Clone)]
pub struct Rect {
@@ -120,8 +120,8 @@ impl fmt::Display for Rect {
}
}
-impl Into<Polyline<f32>> for Rect {
- fn into(self) -> Polyline<f32> {
+impl Into<Polyline> for Rect {
+ fn into(self) -> Polyline {
Polyline::new(
vec![
*self.start,
@@ -135,6 +135,18 @@ impl Into<Polyline<f32>> for Rect {
}
}
+impl Into<ConvexPolygon> for Rect {
+ fn into(self) -> ConvexPolygon {
+ ConvexPolygon::from_convex_polyline(vec![
+ *self.start,
+ *Point::new(self.end.x, self.start.y),
+ *self.end,
+ *Point::new(self.start.x, self.end.y),
+ ])
+ .expect("must create a convex polygon")
+ }
+}
+
impl<MSG> Into<Node<MSG>> for Rect {
fn into(self) -> Node<MSG> {
rect(