Skip to content

Commit

Permalink
Merge pull request #60 from mcharters/fix-clipping-infinite-loop
Browse files Browse the repository at this point in the history
Fix an infinite loop during clipping
  • Loading branch information
jazzido committed Feb 4, 2016
2 parents 5779163 + d33de6a commit 51561ed
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/technology/tabula/CohenSutherlandClipping.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,23 @@ public boolean clip(Line2D.Float line) {

if ((c & LEFT) != INSIDE) {
qx = xMin;
qy = (qx-p1x)*slope + p1y;
qy = (Utils.feq(qx, p1x) ? 0 : qx-p1x)*slope + p1y;
}
else if ((c & RIGHT) != INSIDE) {
qx = xMax;
qy = (qx-p1x)*slope + p1y;
qy = (Utils.feq(qx, p1x) ? 0 : qx-p1x)*slope + p1y;
}
else if ((c & BOTTOM) != INSIDE) {
qy = yMin;
qx = vertical
? p1x
: (qy-p1y)/slope + p1x;
: (Utils.feq(qy, p1y) ? 0 : qy-p1y)/slope + p1x;
}
else if ((c & TOP) != INSIDE) {
qy = yMax;
qx = vertical
? p1x
: (qy-p1y)/slope + p1x;
: (Utils.feq(qy, p1y) ? 0 : qy-p1y)/slope + p1x;
}

if (c == c1) {
Expand Down

0 comments on commit 51561ed

Please sign in to comment.