Merge pull request #1112 from iconexperience/getWinding-patch

Change winding calculation if point on path
This commit is contained in:
Jürg Lehni 2016-07-20 10:50:33 +02:00 committed by GitHub
commit cb6eab7b0e

View file

@ -492,11 +492,15 @@ PathItem.inject(new function() {
vClose = null; vClose = null;
} }
if (!pathWindingL && !pathWindingR && isOnPath) { if (!pathWindingL && !pathWindingR && isOnPath) {
// Use the on-path windings if no other intersections // If the point is on the path and the windings canceled
// were found or if they canceled each other. // each other, we treat the point as if it was inside the
var add = path.isClockwise() ? 1 : -1; // path. A point inside a path has a winding of [+1,-1]
// windingL += add; // for clockwise and [-1,+1] for counter-clockwise paths.
// windingR -= add; // If the ray is cast in y direction (dir == 1), the
// windings always have opposite sign.
var add = path.isClockwise() ^ dir ? 1 : -1;
windingL += add;
windingR -= add;
onPathWinding += add; onPathWinding += add;
} else { } else {
windingL += pathWindingL; windingL += pathWindingL;