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