mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-02 00:59:41 -04:00
Handle edge case in crossing number algorithm where the beam in right x-direction is touching a tip where the curves change y-direction but do not interesect with the shape, by checking for slope changes.
This commit is contained in:
parent
24d77c1ece
commit
6cc7417201
2 changed files with 20 additions and 9 deletions
src/path
|
@ -1164,14 +1164,19 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
|||
|
||||
contains: function(point) {
|
||||
point = Point.read(arguments);
|
||||
if (!this.getBounds().contains(point))
|
||||
if (!this._closed || !this.getBounds().contains(point))
|
||||
return false;
|
||||
var curves = this.getCurves(),
|
||||
prevCurve = this.getLastCurve(),
|
||||
crossings = 0;
|
||||
for (var i = 0, l = curves.length; i < l; i++)
|
||||
crossings += curves[i].getCrossingsFor(point);
|
||||
for (var i = 0, l = curves.length; i < l; i++) {
|
||||
var curve = curves[i];
|
||||
crossings += curve.getCrossingsFor(point,
|
||||
prevCurve.getTangent(1).y);
|
||||
prevCurve = curve;
|
||||
}
|
||||
return (crossings & 1) == 1;
|
||||
},
|
||||
}
|
||||
|
||||
// TODO: intersects(item)
|
||||
// TODO: contains(item)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue