mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Fix issue with hit-testing filled paths that are not closed.
This commit is contained in:
parent
07688a685e
commit
d0cc8b6c16
1 changed files with 5 additions and 2 deletions
|
@ -1261,12 +1261,15 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
|||
|
||||
contains: function(point) {
|
||||
point = Point.read(arguments);
|
||||
// If the path is not closed, it we should not bail out in case it has
|
||||
// a fill color!
|
||||
if (!this._closed && !this._style._fillColor
|
||||
|| !this.getRoughBounds()._containsPoint(point))
|
||||
return false;
|
||||
// Note: This only works correctly with even-odd fill rule, or paths
|
||||
// that do not overlap with themselves.
|
||||
// TODO: Find out how to implement the "Point In Polygon" problem for
|
||||
// non-zero fill rule.
|
||||
if (!this._closed || !this.getRoughBounds()._containsPoint(point))
|
||||
return false;
|
||||
// Use the crossing number algorithm, by counting the crossings of the
|
||||
// beam in right y-direction with the shape, and see if it's an odd
|
||||
// number, meaning the starting point is inside the shape.
|
||||
|
|
Loading…
Reference in a new issue