From 9ee9cc2e6cf30f8525a17b9bb2db8dd1b6974207 Mon Sep 17 00:00:00 2001 From: Fu Zhen Date: Fri, 27 Nov 2015 03:34:03 +0800 Subject: [PATCH] implements setLineDash implements canvas.setLineDash --- canvas2svg.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/canvas2svg.js b/canvas2svg.js index fb56e82..1d790bc 100644 --- a/canvas2svg.js +++ b/canvas2svg.js @@ -167,6 +167,12 @@ }, "textBaseline":{ canvas : "alphabetic" + }, + "lineDash" : { + svgAttr : "stroke-dasharray", + canvas : [], + svg : null, + apply : "stroke" } }; @@ -1102,7 +1108,15 @@ } return new CanvasPattern(pattern, this); }; - + + ctx.prototype.setLineDash = function(dashArray) { + if (dashArray && dashArray.length > 0) { + this.lineDash = dashArray.join(","); + } else { + this.lineDash = null; + } + }; + /** * Not yet implemented */ @@ -1112,7 +1126,6 @@ ctx.prototype.putImageData = function(){}; ctx.prototype.globalCompositeOperation = function(){}; ctx.prototype.setTransform = function(){}; - ctx.prototype.setLineDash = function(){}; //add options for alternative namespace if (typeof window === "object") {