From 7e1f9ca38a4d105ead9e965069344ca935a8499a Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Tue, 24 Jul 2012 19:56:51 -0400 Subject: [PATCH] add more comments to dashed-canvas.js --- dashed-canvas.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dashed-canvas.js b/dashed-canvas.js index beb4d47..af2470e 100644 --- a/dashed-canvas.js +++ b/dashed-canvas.js @@ -27,6 +27,24 @@ * the drawing context. */ +/** + * Change the stroking style of the canvas drawing context from a solid line to + * a pattern (e.g. dashes, dash-dot-dash, etc.) + * + * Once you've installed the pattern, you can draw with it by using the + * beginPath(), moveTo(), lineTo() and stroke() method calls. Note that some + * more advanced methods (e.g. quadraticCurveTo() and bezierCurveTo()) are not + * supported. See file overview for a working example. + * + * Side effects of calling this method include adding an "isPatternInstalled" + * 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 + * 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) { if (typeof(this.isPatternInstalled) !== 'undefined') { throw "Must un-install old line pattern before installing a new one."; -- 2.7.4