blob: 9a9f25b3e33f06c4d7309811c1669a86c224c493 [file] [log] [blame]
function ShapePath(){
this.c = false;
this._length = 0;
this._maxLength = 8;
this.v = Array.apply(null,{length:this._maxLength});
this.o = Array.apply(null,{length:this._maxLength});
this.i = Array.apply(null,{length:this._maxLength});
}
ShapePath.prototype.setPathData = function(closed, len) {
this.c = closed;
while(len > this._maxLength){
this.doubleArrayLength();
}
var i = 0;
while(i < len){
this.v[i] = point_pool.newPoint();
this.o[i] = point_pool.newPoint();
this.i[i] = point_pool.newPoint();
i += 1;
}
this._length = len;
}
ShapePath.prototype.doubleArrayLength = function() {
this.v = this.v.concat(Array.apply(null,{length:this._maxLength}))
this.i = this.i.concat(Array.apply(null,{length:this._maxLength}))
this.o = this.o.concat(Array.apply(null,{length:this._maxLength}))
this._maxLength *= 2;
}
ShapePath.prototype.setXYAt = function(x, y, type, pos, replace) {
var arr;
this._length = Math.max(this._length, pos + 1);
if(this._length >= this._maxLength) {
this.doubleArrayLength();
}
switch(type){
case 'v':
arr = this.v;
break;
case 'i':
arr = this.i;
break;
case 'o':
arr = this.o;
break;
}
if(!arr[pos] || (arr[pos] && !replace)){
arr[pos] = point_pool.newPoint();
}
arr[pos][0] = x;
arr[pos][1] = y;
}
ShapePath.prototype.setTripleAt = function(vX,vY,oX,oY,iX,iY,pos, replace) {
this.setXYAt(vX,vY,'v',pos, replace);
this.setXYAt(oX,oY,'o',pos, replace);
this.setXYAt(iX,iY,'i',pos, replace);
}