X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dashed-canvas.js;h=0fc687450ac4b65cc778cd336b2f0eb701c76b78;hb=f9b5a82c0e67c25b47cc5a40b46ca2f1056c35f5;hp=853d67b8e9b1d39d83035bac8b0cdbc5b9db6a5c;hpb=ddc5f0ee53bd5579b1bbd228ce8ce80a2f5d237c;p=dygraphs.git diff --git a/dashed-canvas.js b/dashed-canvas.js index 853d67b..0fc6874 100644 --- a/dashed-canvas.js +++ b/dashed-canvas.js @@ -4,6 +4,9 @@ * MIT-licensed (http://opensource.org/licenses/MIT) */ +(function() { +'use strict'; + /** * @fileoverview Adds support for dashed lines to the HTML5 canvas. * @@ -40,14 +43,12 @@ * property and "uninstallPattern" method to this particular canvas context. * You must call uninstallPattern() before calling installPattern() again. * - * @param {pattern | Array} A description of the stroke pattern. Even + * @param {Array.} pattern A description of the stroke pattern. Even * indices indicate a draw and odd indices indicate a gap (in pixels). The * array should have a even length as any odd lengthed array could be expressed * as a smaller even length array. */ CanvasRenderingContext2D.prototype.installPattern = function(pattern) { - "use strict"; - if (typeof(this.isPatternInstalled) !== 'undefined') { throw "Must un-install old line pattern before installing a new one."; } @@ -65,6 +66,7 @@ CanvasRenderingContext2D.prototype.installPattern = function(pattern) { var realMoveTo = this.moveTo; var realStroke = this.stroke; + /** @type {function()|undefined} */ this.uninstallPattern = function() { this.beginPath = realBeginPath; this.lineTo = realLineTo; @@ -156,7 +158,8 @@ CanvasRenderingContext2D.prototype.installPattern = function(pattern) { } this.restore(); - x1 = x2, y1 = y2; + x1 = x2; + y1 = y2; } } realStroke.call(this); @@ -172,4 +175,6 @@ CanvasRenderingContext2D.prototype.installPattern = function(pattern) { CanvasRenderingContext2D.prototype.uninstallPattern = function() { // This will be replaced by a non-error version when a pattern is installed. throw "Must install a line pattern before uninstalling it."; -} +}; + +})();