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

View file

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