From 8d5249760a9f58dcd374322e02a891f059bf2851 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Sat, 5 Sep 2015 00:03:43 -0700 Subject: [PATCH 1/2] Don't draw invisible circles --- canvas2svg.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/canvas2svg.js b/canvas2svg.js index ff09f8a..826bb11 100644 --- a/canvas2svg.js +++ b/canvas2svg.js @@ -926,6 +926,10 @@ * Arc command! */ ctx.prototype.arc = function(x, y, radius, startAngle, endAngle, counterClockwise) { + // in canvas no circle is drawn if no angle is provided. + if (startAngle === endAngle) { + return; + } startAngle = startAngle % (2*Math.PI); endAngle = endAngle % (2*Math.PI); if(startAngle === endAngle) { From 2a8c0625882e402edea42af118470eb565a466a5 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 9 Sep 2015 00:19:54 -0700 Subject: [PATCH 2/2] Add a test for empty arcs --- test/example/emptyArc.js | 12 ++++++++++++ test/playground.html | 4 ++-- test/testrunner.html | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 test/example/emptyArc.js diff --git a/test/example/emptyArc.js b/test/example/emptyArc.js new file mode 100644 index 0000000..0ad71f9 --- /dev/null +++ b/test/example/emptyArc.js @@ -0,0 +1,12 @@ +window.C2S_EXAMPLES['emptyArc'] = function(ctx) { + + // Draw shapes + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + ctx.beginPath(); + ctx.arc(100, 100, 100, Math.PI, Math.PI); + ctx.fill(); + } + } + +}; diff --git a/test/playground.html b/test/playground.html index 6ccf53c..ab1cad2 100644 --- a/test/playground.html +++ b/test/playground.html @@ -20,7 +20,7 @@
- +
@@ -64,7 +64,7 @@ -
+
-
+