diff options
author | Jovansonlee Cesar <ivanceras@gmail.com> | 2021-07-06 07:11:04 +0800 |
---|---|---|
committer | Jovansonlee Cesar <ivanceras@gmail.com> | 2021-07-06 07:11:04 +0800 |
commit | 0963aea5052ae8d4905cf0abb51dfe601c12b7e6 (patch) | |
tree | 37c751adf2706cfb4134a40ad806c5961a545e95 /svgbob/src/buffer/fragment_buffer/fragment.rs | |
parent | acad7ac5c46de8c4f39c1f1cf1e073ee08e78604 (diff) |
Include circle in intersection test
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), |