Skip to content

Commit

Permalink
Fix edge cases in Curve._getWinding()
Browse files Browse the repository at this point in the history
Use same rules for lines as for curves, exclude end points of lines. Closes paperjs#346.
  • Loading branch information
lehni committed Nov 30, 2013
1 parent dcad9d4 commit dfc0886
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/path/Curve.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit dfc0886

Please sign in to comment.