Add fabric.Circle#getRadiusX, fabric.Circle#getRadiusY methods.

This commit is contained in:
kangax 2011-04-09 17:37:35 -04:00
parent 752eff298d
commit cc0c5085d7
3 changed files with 59 additions and 0 deletions

17
dist/all.js vendored
View file

@ -7506,6 +7506,23 @@ fabric.util.animate = animate;
}
},
/**
* Returns horizontal radius of an object (according to how an object is scaled)
* @method getRadiusX
* @return {Number}
*/
getRadiusX: function() {
return this.get('radius') * this.get('scaleX');
},
/**
* Returns vertical radius of an object (according to how an object is scaled)
* @method getRadiusY
* @return {Number}
*/
getRadiusY: function() {
return this.get('radius') * this.get('scaleY');
},
/**
* Returns complexity of an instance

View file

@ -69,6 +69,23 @@
}
},
/**
* Returns horizontal radius of an object (according to how an object is scaled)
* @method getRadiusX
* @return {Number}
*/
getRadiusX: function() {
return this.get('radius') * this.get('scaleX');
},
/**
* Returns vertical radius of an object (according to how an object is scaled)
* @method getRadiusY
* @return {Number}
*/
getRadiusY: function() {
return this.get('radius') * this.get('scaleY');
},
/**
* Returns complexity of an instance

View file

@ -13,6 +13,31 @@
same(circle.type, 'circle');
});
test('getRadiusX, getRadiusY', function() {
var circle = new fabric.Circle({ radius: 10 });
ok(typeof circle.getRadiusX == 'function', 'getRadiusX should exist');
ok(typeof circle.getRadiusY == 'function', 'getRadiusY should exist');
equals(circle.getRadiusX(), 10);
equals(circle.getRadiusY(), 10);
circle.scale(2);
equals(circle.getRadiusX(), 20);
equals(circle.getRadiusY(), 20);
circle.set('scaleX', 3);
equals(circle.getRadiusX(), 30);
equals(circle.getRadiusY(), 20);
circle.set('scaleY', 4);
equals(circle.getRadiusX(), 30);
equals(circle.getRadiusY(), 40);
});
test('complexity', function() {
var circle = new fabric.Circle();
ok(typeof circle.complexity == 'function');