diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/canvas2svg.js b/canvas2svg.js index f4645af..a45c68d 100644 --- a/canvas2svg.js +++ b/canvas2svg.js @@ -1,5 +1,5 @@ /*!! - * Canvas 2 Svg v1.0.2 + * Canvas 2 Svg v1.0.3 * A low level canvas to SVG converter. Uses a mock canvas context to build an SVG document. * * Licensed under the MIT license: @@ -190,7 +190,7 @@ /** * The mock canvas context - * @param options - options include: + * @param o - options include: * width - width of your canvas (defaults to 500) * height - height of your canvas (defaults to 500) * enableMirroring - enables canvas mirroring (get image data) (defaults to false) @@ -799,11 +799,18 @@ startX = x+radius*Math.cos(startAngle), startY = y+radius*Math.sin(startAngle), sweepFlag = counterClockwise ? 0 : 1, - largeArcFlag; + largeArcFlag = 0, + diff = endAngle - startAngle; + + // https://github.com/gliffy/canvas2svg/issues/4 + if(diff < 0) { + diff += 2*Math.PI; + } + if(counterClockwise) { - largeArcFlag = Math.abs(endAngle - startAngle) > Math.PI ? 0 : 1; + largeArcFlag = diff > Math.PI ? 0 : 1; } else { - largeArcFlag = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0; + largeArcFlag = diff > Math.PI ? 1 : 0; } this.moveTo(startX, startY); diff --git a/jasmine-tests/canvassvg.html b/jasmine-tests/canvassvg.html new file mode 100644 index 0000000..8a9778c --- /dev/null +++ b/jasmine-tests/canvassvg.html @@ -0,0 +1,57 @@ + + +
+ +