dojox.gfx.path.Path._updateWithSegment
dojo.require("dojox.gfx.path");
defined in dojox/gfx/path.js
updates the bounding box of path with new segment
Usage
function (/*Object*/ segment) (view source)
var n = segment.args, l = n.length; // update internal variables: bbox, absolute, last switch(segment.action){ case "M": case "L": case "C": case "S": case "Q": case "T": for(var i = 0; i < l; i += 2){ this._updateBBox(n[i], n[i + 1]); } this.last.x = n[l - 2]; this.last.y = n[l - 1]; this.absolute = true; break; case "H": for(var i = 0; i < l; ++i){ this._updateBBox(n[i], this.last.y); } this.last.x = n[l - 1]; this.absolute = true; break; case "V": for(var i = 0; i < l; ++i){ this._updateBBox(this.last.x, n[i]); } this.last.y = n[l - 1]; this.absolute = true; break; case "m": var start = 0; if(!("x" in this.last)){ this._updateBBox(this.last.x = n[0], this.last.y = n[1]); start = 2; } for(var i = start; i < l; i += 2){ this._updateBBox(this.last.x += n[i], this.last.y += n[i + 1]); } this.absolute = false; break; case "l": case "t": for(var i = 0; i < l; i += 2){ this._updateBBox(this.last.x += n[i], this.last.y += n[i + 1]); } this.absolute = false; break; case "h": for(var i = 0; i < l; ++i){ this._updateBBox(this.last.x += n[i], this.last.y); } this.absolute = false; break; case "v": for(var i = 0; i < l; ++i){ this._updateBBox(this.last.x, this.last.y += n[i]); } this.absolute = false; break; case "c": for(var i = 0; i < l; i += 6){ this._updateBBox(this.last.x + n[i], this.last.y + n[i + 1]); this._updateBBox(this.last.x + n[i + 2], this.last.y + n[i + 3]); this._updateBBox(this.last.x += n[i + 4], this.last.y += n[i + 5]); } this.absolute = false; break; case "s": case "q": for(var i = 0; i < l; i += 4){ this._updateBBox(this.last.x + n[i], this.last.y + n[i + 1]); this._updateBBox(this.last.x += n[i + 2], this.last.y += n[i + 3]); } this.absolute = false; break; case "A": for(var i = 0; i < l; i += 7){ this._updateBBox(n[i + 5], n[i + 6]); } this.last.x = n[l - 2]; this.last.y = n[l - 1]; this.absolute = true; break; case "a": for(var i = 0; i < l; i += 7){ this._updateBBox(this.last.x += n[i + 5], this.last.y += n[i + 6]); } this.absolute = false; break; } // add an SVG path segment var path = [segment.action]; for(var i = 0; i < l; ++i){ path.push(dojox.gfx.formatNumber(n[i], true)); } if(typeof this.shape.path == "string"){ this.shape.path += path.join(""); }else{ var l = path.length, a = this.shape.path; for(var i = 0; i < l; ++i){ a.push(path[i]); } }
parameter | type | description |
---|---|---|
segment | Object | a segment |