Skip to content

Commit

Permalink
The ART elements have a read only API. No getPath(), no measure()
Browse files Browse the repository at this point in the history
Don't waste memory and don't code backwards (DOM centric).
  • Loading branch information
sebmarkbage committed Jan 12, 2011
1 parent f00ad4a commit 622f7d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
8 changes: 2 additions & 6 deletions Source/ART.SVG.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 8 additions & 20 deletions Source/ART.VML.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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.