mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Add asString parameter to exportSVG() methods.
This commit is contained in:
parent
f9925a71ea
commit
0bf19d02bd
1 changed files with 6 additions and 6 deletions
|
@ -466,7 +466,7 @@ new function() {
|
||||||
definitions.svgs[type + '-' + item._id] = node;
|
definitions.svgs[type + '-' + item._id] = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportDefinitions(node) {
|
function exportDefinitions(node, asString) {
|
||||||
if (!definitions)
|
if (!definitions)
|
||||||
return node;
|
return node;
|
||||||
// We can only use svg nodes as defintion containers. Have the loop
|
// We can only use svg nodes as defintion containers. Have the loop
|
||||||
|
@ -489,7 +489,7 @@ new function() {
|
||||||
}
|
}
|
||||||
// Clear definitions at the end of export
|
// Clear definitions at the end of export
|
||||||
definitions = null;
|
definitions = null;
|
||||||
return svg;
|
return asString ? new XMLSerializer().serializeToString(svg) : svg;
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportSVG(item) {
|
function exportSVG(item) {
|
||||||
|
@ -509,8 +509,8 @@ new function() {
|
||||||
*
|
*
|
||||||
* @return {SVGSVGElement} the item converted to an SVG node
|
* @return {SVGSVGElement} the item converted to an SVG node
|
||||||
*/
|
*/
|
||||||
exportSVG: function() {
|
exportSVG: function(asString) {
|
||||||
return exportDefinitions(exportSVG(this));
|
return exportDefinitions(exportSVG(this), asString);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -523,7 +523,7 @@ new function() {
|
||||||
*
|
*
|
||||||
* @return {SVGSVGElement} the project converted to an SVG node
|
* @return {SVGSVGElement} the project converted to an SVG node
|
||||||
*/
|
*/
|
||||||
exportSVG: function() {
|
exportSVG: function(asString) {
|
||||||
var layers = this.layers,
|
var layers = this.layers,
|
||||||
size = this.view.getSize(),
|
size = this.view.getSize(),
|
||||||
node = createElement('svg', {
|
node = createElement('svg', {
|
||||||
|
@ -537,7 +537,7 @@ new function() {
|
||||||
});
|
});
|
||||||
for (var i = 0, l = layers.length; i < l; i++)
|
for (var i = 0, l = layers.length; i < l; i++)
|
||||||
node.appendChild(exportSVG(layers[i]));
|
node.appendChild(exportSVG(layers[i]));
|
||||||
return exportDefinitions(node);
|
return exportDefinitions(node, asString);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue