rewrote cropping logic from last pull request, fixed serialization issue in unit test, added new unit tests, and added getX() and getY() methods

This commit is contained in:
Eric Rowell
2012-04-27 19:08:45 -07:00
parent f5735b3462
commit 508bfb7a9b
6 changed files with 190 additions and 39 deletions

View File

@@ -158,6 +158,20 @@ Kinetic.Node.prototype = {
this.attrs[key].y = val.y;
}
break;
case 'crop':
if(val.x !== undefined) {
this.attrs[key].x = val.x;
}
if(val.y !== undefined) {
this.attrs[key].y = val.y;
}
if(val.width !== undefined) {
this.attrs[key].width = val.width;
}
if(val.height !== undefined) {
this.attrs[key].height = val.height;
}
break;
/*
* config properties that we don't want in attrs
*/
@@ -289,6 +303,18 @@ Kinetic.Node.prototype = {
setY: function(y) {
this.attrs.y = y;
},
/**
* get node x position
*/
getX: function() {
return this.attrs.x;
},
/**
* get node y position
*/
getY: function() {
return this.attrs.y;
},
/**
* set detection type
* @param {String} type can be "path" or "pixel"