Permalink
Browse files

The ART elements have a read only API. No getPath(), no measure()

Don't waste memory and don't code backwards (DOM centric).
  • Loading branch information...
1 parent f00ad4a commit 622f7d1605f5791afde3e22fcec5b20a5d31fe1c @sebmarkbage sebmarkbage committed Jan 12, 2011
Showing with 10 additions and 26 deletions.
  1. +2 −6 Source/ART.SVG.js
  2. +8 −20 Source/ART.VML.js
View
@@ -372,13 +372,9 @@ ART.SVG.Shape = new Class({
if (path != null) this.draw(path);
},
- getPath: function(){
- return this.currentPath || new ART.Path;
- },
-
draw: function(path, width, height){
- this.currentPath = (path instanceof ART.Path) ? path : new ART.Path(path);
- this.element.setAttribute('d', this.currentPath.toSVG());
+ if (!(path instanceof ART.Path)) path = new ART.Path(path);
+ this.element.setAttribute('d', path.toSVG());
if (width != null) this.width = width;
if (height != null) this.height = height;
return this;
View
@@ -228,7 +228,7 @@ ART.VML.Base = new Class({
// Box in shape user space
- var box = this._boxCoords || this.measure() || defaultBox;
+ var box = this._boxCoords || this._size || defaultBox;
var originX = box.left || 0,
originY = box.top || 0,
@@ -523,16 +523,13 @@ ART.VML.Shape = new Class({
if (path != null) this.draw(path);
},
- getPath: function(){
- return this.currentPath;
- },
-
// SVG to VML
draw: function(path, width, height){
- this.currentPath = (path instanceof ART.Path) ? path : new ART.Path(path);
- this.currentVML = this.currentPath.toVML(precision);
+ if (!(path instanceof ART.Path)) path = new ART.Path(path);
+ this._vml = path.toVML(precision);
+ this._size = path.measure();
if (width != null) this.width = width;
if (height != null) this.height = height;
@@ -543,16 +540,10 @@ ART.VML.Shape = new Class({
return this;
},
- measure: function(){
- var path = this.getPath();
- if (!path) return null;
- return path.measure();
- },
-
// radial gradient workaround
_redraw: function(prefix, suffix){
- var vml = this.currentVML || '';
+ var vml = this._vml || '';
this._prefix = prefix;
this._suffix = suffix
@@ -721,14 +712,11 @@ ART.VML.Text = new Class({
this.bottom = ebb.bottom - cbb.top;
this._transform();
-
+
+ this._size = { left: this.left, top: this.top, width: this.width, height: this.height};
return this;
- },
-
- measure: function(){
- return { left: this.left, top: this.top, width: this.width, height: this.height, right: this.right, bottom: this.bottom };
}
-
+
});
})();

0 comments on commit 622f7d1

Please sign in to comment.