Some more SVG code refactoring.

This commit is contained in:
Jürg Lehni 2012-10-27 19:25:52 -07:00
parent 44fc5939e5
commit 155b6046cb
2 changed files with 12 additions and 14 deletions

View file

@ -28,10 +28,6 @@
*/
var ExportSvg = this.ExportSvg = Base.extend(/** @Lends ExportSvg# */{
//initialize the svgObj
initialize: function() {
this.svgObj = this.create('svg');
},
create: function(tag) {
return document.createElementNS('http://www.w3.org/2000/svg', tag);
@ -49,13 +45,12 @@ var ExportSvg = this.ExportSvg = Base.extend(/** @Lends ExportSvg# */{
*/
//TODO: Implement symbols and Gradients
exportProject: function(project) {
var layerArray = project.layers;
var layer;
for (var i = 0; i < layerArray.length; ++i) {
layer = layerArray[i];
this.svgObj.appendChild(this.exportLayer(layer));
var svg = this.create('svg'),
layers = project.layers;
for (var i = 0; i < layers.length; ++i) {
svg.appendChild(this.exportLayer(layers[i]));
}
return this.svgObj;
return svg;
},
/**

View file

@ -74,6 +74,7 @@ var ImportSvg = this.ImportSvg = Base.extend(/** @Lends ImportSvg# */{
this._importAttributesAndStyles(svg, item);
symbol = new Symbol(item);
item = null;
break;
default:
// Not supported yet.
}
@ -482,8 +483,10 @@ var ImportSvg = this.ImportSvg = Base.extend(/** @Lends ImportSvg# */{
break;
case 'transform':
this._applyTransform(item, svg);
break;
case 'opacity':
item.opacity = parseFloat(value, 10);
break;
case 'visibility':
item.visibility = (value == 'visible') ? true : false;
break;
@ -566,8 +569,8 @@ var ImportSvg = this.ImportSvg = Base.extend(/** @Lends ImportSvg# */{
transformMatrix.setShearX(0);
break;
case SVGTransform.SVG_TRANSFORM_ROTATE:
transformMatrix.setShearX(transformMatrix.getShearX() * -1);
transformMatrix.setShearY(transformMatrix.getShearY() * -1);
transformMatrix.setShearX(-transformMatrix.getShearX());
transformMatrix.setShearY(-transformMatrix.getShearY());
break;
}
matrix.concatenate(transformMatrix);