mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-28 22:08:54 -04:00
Export view size and set svg attributes in project.exportSVG()
This commit is contained in:
parent
041f3a6c4d
commit
b3d7f5aff6
1 changed files with 13 additions and 3 deletions
|
@ -17,7 +17,8 @@
|
||||||
new function() {
|
new function() {
|
||||||
var formatter = Formatter.instance,
|
var formatter = Formatter.instance,
|
||||||
namespaces = {
|
namespaces = {
|
||||||
href: 'http://www.w3.org/1999/xlink'
|
href: 'http://www.w3.org/1999/xlink',
|
||||||
|
xlink: 'http://www.w3.org/2000/xmlns'
|
||||||
};
|
};
|
||||||
|
|
||||||
function setAttributes(node, attrs) {
|
function setAttributes(node, attrs) {
|
||||||
|
@ -514,10 +515,19 @@ new function() {
|
||||||
*/
|
*/
|
||||||
exportSVG: function() {
|
exportSVG: function() {
|
||||||
var node = createElement('svg'),
|
var node = createElement('svg'),
|
||||||
layers = this.layers;
|
layers = this.layers,
|
||||||
|
size = this.view.getSize();
|
||||||
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 setAttributes(exportDefinitions(node), {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
width: size.width,
|
||||||
|
height: size.height,
|
||||||
|
version: '1.1',
|
||||||
|
xmlns: 'http://www.w3.org/2000/svg',
|
||||||
|
xlink: 'http://www.w3.org/1999/xlink'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue