added _setPoints so that points setter methods could leverage the same logic that was in the setAttrs() method

This commit is contained in:
Eric Rowell
2012-05-13 11:58:40 -07:00
parent 7f8a174b51
commit ec415c55de
7 changed files with 98 additions and 56 deletions

View File

@@ -187,27 +187,7 @@ Kinetic.Node.prototype = {
go._setXY(this.attrs, key, val);
break;
case 'points':
/*
* if points contains an array of objects, just set
* the attr normally
*/
if(Kinetic.GlobalObject._isObject(val[0])) {
this.attrs[key] = config[key];
}
else {
/*
* convert array of numbers into an array
* of objects containing x, y
*/
var arr = [];
for(var n = 0; n < val.length; n += 2) {
arr.push({
x: val[n],
y: val[n + 1]
});
}
this.attrs[key] = arr;
}
go._setPoints(this.attrs, key, val);
break;
case 'crop':
go._setXY(this.attrs, key, val);