Fix edge cases in Curve._getWinding()

Use same rules for lines as for curves, exclude end points of lines. Closes #346.
This commit is contained in:
Jürg Lehni 2013-11-30 14:21:47 +01:00
parent dcad9d44ed
commit dfc0886a8b

View file

@ -704,16 +704,14 @@ statics: {
function getOrientation(v) {
var y0 = v[1],
y1 = v[7],
dir = 1;
if (y0 > y1) {
var tmp = y0;
y0 = y1;
y1 = tmp;
dir = -1;
}
if (y < y0 || y > y1)
dir = 0;
return dir;
dir = y0 <= y1 ? 1 : -1;
// Bounds check: Reverse y0 and y1 if direction is -1, and exclude
// end points of curves / lines (y1), to not count corners / joints
// twice.
return dir === 1 && (y < y0 || y >= y1)
|| dir === -1 && (y <= y1 || y > y0)
? 0
: dir;
}
if (Curve.isLinear(v)) {