mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
addressed review
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
This commit is contained in:
parent
e8577efb56
commit
be3a6444ec
2 changed files with 7 additions and 0 deletions
|
@ -207,6 +207,7 @@ impl Area {
|
|||
|
||||
Area::Polygon { ref points } => {
|
||||
// Ray-casting algorithm to determine if point is inside polygon
|
||||
// https://en.wikipedia.org/wiki/Point_in_polygon#Ray_casting_algorithm
|
||||
let mut inside = false;
|
||||
|
||||
debug_assert!(points.len() % 2 == 0);
|
||||
|
|
|
@ -196,4 +196,10 @@ fn test_hit_test_polygon() {
|
|||
assert!(!poly3.hit_test(&Point2D::new(6.0, 0.0)));
|
||||
assert!(!poly3.hit_test(&Point2D::new(0.0, 6.0)));
|
||||
assert!(!poly3.hit_test(&Point2D::new(6.0, 6.0)));
|
||||
// Concave polygon test
|
||||
let poly4 = Area::Polygon {
|
||||
points: vec![0.0, 0.0, 1.0, 1.0, 2.0, 0.0, 2.0, 2.0, 0.0, 2.0],
|
||||
};
|
||||
assert!(poly4.hit_test(&Point2D::new(1.5, 1.5)));
|
||||
assert!(!poly4.hit_test(&Point2D::new(1.0, 0.0)));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue