* MIT-licensed (http://opensource.org/licenses/MIT)
*/
+(function() {
+'use strict';
+
/**
* @fileoverview Adds support for dashed lines to the HTML5 canvas.
*
* property and "uninstallPattern" method to this particular canvas context.
* You must call uninstallPattern() before calling installPattern() again.
*
- * @param {pattern | Array<Number>} A description of the stroke pattern. Even
+ * @param {Array.<number>} 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.
var realMoveTo = this.moveTo;
var realStroke = this.stroke;
+ /** @type {function()|undefined} */
this.uninstallPattern = function() {
this.beginPath = realBeginPath;
this.lineTo = realLineTo;
// Set last pattern index we used for this pattern.
var patternIndex = dashedLineToHistory[0];
- x = 0;
+ var x = 0;
while (len > x) {
// Get the length of the pattern segment we are dealing with.
- segment = pattern[patternIndex];
+ var segment = pattern[patternIndex];
// If our last draw didn't complete the pattern segment all the way
// we will try to finish it. Otherwise we will try to do the whole
// segment.
}
this.restore();
- x1 = x2, y1 = y2;
+ x1 = x2;
+ y1 = y2;
}
}
realStroke.call(this);
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.";
-}
+};
+
+})();