Skip to content

Commit

Permalink
Expand zero-radius arcs to line segments
Browse files Browse the repository at this point in the history
close #18
  • Loading branch information
rlidwka committed Dec 30, 2015
1 parent ee7c988 commit 7577383
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/svgpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,11 @@ SvgPath.prototype.unarc = function () {
nextY = s[7];
}

// one of the radii is zero, treating it as a line segment instead
if (s[1] === 0 || s[2] === 0) {
return [ [ 'L', nextX, nextY ] ];
}

new_segments = a2c(x, y, nextX, nextY, s[4], s[5], s[1], s[2], s[3]);

new_segments.forEach(function (s) {
Expand Down
4 changes: 2 additions & 2 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,13 @@ describe('API', function () {
// both rx and ry are zero
assert.equal(
svgpath('M100 100A0 0 0 0 1 110 110').unarc().round(0).toString(),
'M100 100'
'M100 100L110 110'
);

// rx is zero
assert.equal(
svgpath('M100 100A0 100 0 0 1 110 110').unarc().round(0).toString(),
'M100 100'
'M100 100L110 110'
);
});
});
Expand Down

0 comments on commit 7577383

Please sign in to comment.