diff options
Diffstat (limited to 'svgbob/src/buffer/fragment_buffer/fragment.rs')
-rw-r--r-- | svgbob/src/buffer/fragment_buffer/fragment.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/svgbob/src/buffer/fragment_buffer/fragment.rs b/svgbob/src/buffer/fragment_buffer/fragment.rs index f938b04..8eeacac 100644 --- a/svgbob/src/buffer/fragment_buffer/fragment.rs +++ b/svgbob/src/buffer/fragment_buffer/fragment.rs @@ -297,7 +297,7 @@ impl Fragment { } /// check if this fragment is intersecting with this bounding box - fn is_intersecting(&self, bbox: AABB<f32>) -> bool { + pub fn is_intersecting(&self, bbox: AABB<f32>) -> bool { let bbox: Polyline<f32> = Polyline::new( vec![ *bbox.mins(), @@ -319,6 +319,11 @@ impl Fragment { proximity(&identity, &polyline, &identity, &bbox, 0.0) == Proximity::Intersecting } + Fragment::Circle(circle) => { + let polyline: Polyline<f32> = circle.clone().into(); + proximity(&identity, &polyline, &identity, &bbox, 0.0) + == Proximity::Intersecting + } _ => false, } } @@ -414,6 +419,13 @@ impl Fragment { } } + pub fn as_rect(&self) -> Option<&Rect> { + match self { + Fragment::Rect(ref rect) => Some(rect), + _ => None, + } + } + pub fn as_polygon(&self) -> Option<&Polygon> { match self { Fragment::Polygon(polygon) => Some(polygon), |