source: [view]
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], matrix);
}
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, matrix);
}
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], matrix);
}
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], matrix);
start = 2;
}
for(var i = start; i < l; i += 2){
this._updateBBox(this.last.x += n[i], this.last.y += n[i + 1], matrix);
}
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], matrix);
}
this.absolute = false;
break;
case "h":
for(var i = 0; i < l; ++i){
this._updateBBox(this.last.x += n[i], this.last.y, matrix);
}
this.absolute = false;
break;
case "v":
for(var i = 0; i < l; ++i){
this._updateBBox(this.last.x, this.last.y += n[i], matrix);
}
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], matrix);
this._updateBBox(this.last.x + n[i + 2], this.last.y + n[i + 3], matrix);
this._updateBBox(this.last.x += n[i + 4], this.last.y += n[i + 5], matrix);
}
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], matrix);
this._updateBBox(this.last.x += n[i + 2], this.last.y += n[i + 3], matrix);
}
this.absolute = false;
break;
case "A":
for(var i = 0; i < l; i += 7){
this._updateBBox(n[i + 5], n[i + 6], matrix);
}
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], matrix);
}
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{
Array.prototype.push.apply(this.shape.path, path); //FIXME: why not simple push()?
}