From f9d5e2b68e957202d1a69d1bc159dee0272253da Mon Sep 17 00:00:00 2001 From: Michael Deal Date: Fri, 6 Jan 2017 16:56:12 -0800 Subject: [PATCH] fix issue with applying gradient to stroke --- canvas2svg.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/canvas2svg.js b/canvas2svg.js index 0796306..a1861ce 100644 --- a/canvas2svg.js +++ b/canvas2svg.js @@ -356,7 +356,7 @@ value = this[keys[i]]; if (style.apply) { //is this a gradient or pattern? - if (style.apply.indexOf("fill") !== -1 && value instanceof CanvasPattern) { + if (value instanceof CanvasPattern) { //pattern if (value.__ctx) { //copy over defs @@ -366,11 +366,11 @@ this.__defs.appendChild(value.__ctx.__defs.childNodes[0]); } } - currentElement.setAttribute("fill", format("url(#{id})", {id:value.__root.getAttribute("id")})); + currentElement.setAttribute(style.apply, format("url(#{id})", {id:value.__root.getAttribute("id")})); } - else if (style.apply.indexOf("fill")!==-1 && value instanceof CanvasGradient) { + else if (value instanceof CanvasGradient) { //gradient - currentElement.setAttribute("fill", format("url(#{id})", {id:value.__root.getAttribute("id")})); + currentElement.setAttribute(style.apply, format("url(#{id})", {id:value.__root.getAttribute("id")})); } else if (style.apply.indexOf(type)!==-1 && style.svg !== value) { if ((style.svgAttr === "stroke" || style.svgAttr === "fill") && value.indexOf("rgba") !== -1) { //separate alpha value, since illustrator can't handle it