Skip to content

Commit

Permalink
Fix arcto sweep flag when a transformation matrix is applied
Browse files Browse the repository at this point in the history
When a transformation matrix flips the coordinates horizontally or vertically (but not both) clockwise arcs need to become counterclockwise and vice-versa.

Fixes #708
  • Loading branch information
JoshyPHP committed Jun 30, 2017
1 parent bc3c8a6 commit 40bcb7f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugins/_transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ exports.transformArc = function(arc, transform) {
arc[2] = ((major ? term2 < 0 : term1 > 0) ? -1 : 1) *
Math.acos((major ? term1 : term2) / Math.sqrt(term1 * term1 + term2 * term2)) * 180 / Math.PI;
}

if ((transform[0] < 0) !== (transform[3] < 0)) {
// Flip the sweep flag if coordinates are being flipped horizontally XOR vertically
arc[4] = 1 - arc[4];
}

return arc;

};
Expand Down
9 changes: 9 additions & 0 deletions test/plugins/convertPathData.18.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 40bcb7f

Please sign in to comment.