Update Regular Expression to handle decimal values
From https://github.com/gliffy/canvas2svg/issues/85
This commit is contained in:
parent
3427480ed3
commit
d7e5bd071d
@ -199,7 +199,7 @@ export default (function () {
|
|||||||
stop.setAttribute("offset", offset);
|
stop.setAttribute("offset", offset);
|
||||||
if (utils.toString(color).indexOf("rgba") !== -1) {
|
if (utils.toString(color).indexOf("rgba") !== -1) {
|
||||||
//separate alpha value, since webkit can't handle it
|
//separate alpha value, since webkit can't handle it
|
||||||
regex = /rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi;
|
regex = /rgba\(\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi;
|
||||||
matches = regex.exec(color);
|
matches = regex.exec(color);
|
||||||
stop.setAttribute("stop-color", format("rgb({r},{g},{b})", {r:matches[1], g:matches[2], b:matches[3]}));
|
stop.setAttribute("stop-color", format("rgb({r},{g},{b})", {r:matches[1], g:matches[2], b:matches[3]}));
|
||||||
stop.setAttribute("stop-opacity", matches[4]);
|
stop.setAttribute("stop-opacity", matches[4]);
|
||||||
@ -415,7 +415,7 @@ export default (function () {
|
|||||||
} else if (style.apply.indexOf(type)!==-1 && style.svg !== value) {
|
} else if (style.apply.indexOf(type)!==-1 && style.svg !== value) {
|
||||||
if ((style.svgAttr === "stroke" || style.svgAttr === "fill") && value.indexOf("rgba") !== -1) {
|
if ((style.svgAttr === "stroke" || style.svgAttr === "fill") && value.indexOf("rgba") !== -1) {
|
||||||
//separate alpha value, since illustrator can't handle it
|
//separate alpha value, since illustrator can't handle it
|
||||||
regex = /rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi;
|
regex = /rgba\(\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi;
|
||||||
matches = regex.exec(value);
|
matches = regex.exec(value);
|
||||||
currentElement.setAttribute(style.svgAttr, format("rgb({r},{g},{b})", {r:matches[1], g:matches[2], b:matches[3]}));
|
currentElement.setAttribute(style.svgAttr, format("rgb({r},{g},{b})", {r:matches[1], g:matches[2], b:matches[3]}));
|
||||||
//should take globalAlpha here
|
//should take globalAlpha here
|
||||||
|
Loading…
x
Reference in New Issue
Block a user