utils.toString for https://github.com/zenozeng/p5.js-svg/issues/204
This commit is contained in:
parent
31bd280829
commit
f65d64aa53
@ -28,6 +28,10 @@ const mySerializedSVG = ctx.getSerializedSvg();
|
||||
|
||||
## CHANGELOG
|
||||
|
||||
### v2.0.6
|
||||
|
||||
- utils.toString for https://github.com/zenozeng/p5.js-svg/issues/204
|
||||
|
||||
### v2.0.5
|
||||
|
||||
- Fix adding CanvasPattern ([Xavier Delamotte](https://github.com/x4d3)) [#7](https://github.com/zenozeng/svgcanvas/pull/7)
|
||||
|
@ -13,6 +13,8 @@
|
||||
* Copyright (c) 2021 Zeno Zeng
|
||||
*/
|
||||
|
||||
import * as utils from 'utils';
|
||||
|
||||
export default (function () {
|
||||
"use strict";
|
||||
|
||||
@ -194,6 +196,7 @@ export default (function () {
|
||||
CanvasGradient.prototype.addColorStop = function (offset, color) {
|
||||
var stop = this.__ctx.__createElement("stop"), regex, matches;
|
||||
stop.setAttribute("offset", offset);
|
||||
color = utils.toString(color);
|
||||
if (color.indexOf("rgba") !== -1) {
|
||||
//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;
|
||||
@ -394,7 +397,7 @@ export default (function () {
|
||||
//gradient
|
||||
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) {
|
||||
if ((style.svgAttr === "stroke" || style.svgAttr === "fill") && utils.toString(value).indexOf("rgba") !== -1) {
|
||||
//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;
|
||||
matches = regex.exec(value);
|
||||
|
5
package-lock.json
generated
5
package-lock.json
generated
@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "svgcanvas",
|
||||
"version": "2.0.1",
|
||||
"version": "2.0.6",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"version": "2.0.1",
|
||||
"name": "svgcanvas",
|
||||
"version": "2.0.6",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"rollup": "^2.51.1"
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "svgcanvas",
|
||||
"version": "2.0.5",
|
||||
"version": "2.0.6",
|
||||
"description": "svgcanvas",
|
||||
"main": "dist/svgcanvas.js",
|
||||
"scripts": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user