Update paint.js

master
JFH 2021-09-28 15:58:32 +02:00
parent 49a9063d74
commit 1cd86dfeeb
1 changed files with 13 additions and 3 deletions

View File

@ -56,13 +56,23 @@ export default class Paint {
this.type = 'linearGradient';
this.solidColor = null;
this.radialGradient = null;
this.linearGradient = options.linearGradient.cloneNode(true);
if(options.linearGradient.hasAttribute('xlink:href')) {
const xhref = document.getElementById(options.linearGradient.getAttribute('xlink:href').substr(1));
this.linearGradient = xhref.cloneNode(true);
} else {
this.linearGradient = options.linearGradient.cloneNode(true);
}
// create linear gradient paint
} else if (options.radialGradient) {
this.type = 'radialGradient';
this.solidColor = null;
this.linearGradient = null;
this.radialGradient = options.radialGradient.cloneNode(true);
if(options.radialGradient.hasAttribute('xlink:href')) {
const xhref = document.getElementById(options.radialGradient.getAttribute('xlink:href').substr(1));
this.radialGradient = xhref.cloneNode(true);
} else {
this.radialGradient = options.radialGradient.cloneNode(true);
}
// create solid color paint
} else if (options.solidColor) {
this.type = 'solidColor';
@ -75,4 +85,4 @@ export default class Paint {
this.radialGradient = null;
}
}
}
}