From: Klaus Weidner <klausw@google.com>
Date: Sun, 26 Feb 2012 04:38:40 +0000 (-0800)
Subject: clean up closePath usage
X-Git-Tag: v1.0.0~314^2~16^2
X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=85ff97a2a45a31bd7bc73caa2ac92063c62a95b8;p=dygraphs.git

clean up closePath usage

I was confused by a wrong example I saw online, it's supposed to be used
before stroke() as it was in the original version. It's not needed
after fill() since that automatically closes the path.
---

diff --git a/dygraph-utils.js b/dygraph-utils.js
index 9185a0f..3827d91 100644
--- a/dygraph-utils.js
+++ b/dygraph-utils.js
@@ -844,9 +844,8 @@ Dygraph.regularShape_ = function(
     var coords = computeCoordinates();
     ctx.lineTo(coords[0], coords[1]);
   }
-  ctx.stroke();
   ctx.fill();
-  ctx.closePath();
+  ctx.stroke();
 }
 
 Dygraph.shapeFunction_ = function(sides, rotationRadians, delta) {
@@ -878,9 +877,8 @@ Dygraph.Circles = {
     ctx.strokeStyle = color;
     ctx.fillStyle = "white";
     ctx.arc(cx, cy, radius, 0, 2 * Math.PI, false);
-    ctx.stroke();
     ctx.fill();
-    ctx.closePath();
+    ctx.stroke();
   },
   STAR : Dygraph.shapeFunction_(5, 0, 4 * Math.PI / 5),
   PLUS : function(g, name, ctx, cx, cy, color, radius) {
@@ -889,14 +887,14 @@ Dygraph.Circles = {
     ctx.beginPath();
     ctx.moveTo(cx + radius, cy);
     ctx.lineTo(cx - radius, cy);
-    ctx.stroke();
     ctx.closePath();
+    ctx.stroke();
 
     ctx.beginPath();
     ctx.moveTo(cx, cy + radius);
     ctx.lineTo(cx, cy - radius);
-    ctx.stroke();
     ctx.closePath();
+    ctx.stroke();
   },
   EX : function(g, name, ctx, cx, cy, color, radius) {
     ctx.strokeStyle = color;
@@ -911,7 +909,6 @@ Dygraph.Circles = {
     ctx.moveTo(cx + radius, cy - radius);
     ctx.lineTo(cx - radius, cy + radius);
     ctx.closePath();
-
     ctx.stroke();
   }
 };