From 85ff97a2a45a31bd7bc73caa2ac92063c62a95b8 Mon Sep 17 00:00:00 2001 From: Klaus Weidner Date: Sat, 25 Feb 2012 20:38:40 -0800 Subject: [PATCH] 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. --- dygraph-utils.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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(); } }; -- 2.7.4