mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-03 11:34:41 +00:00
Add fabric.Circle#getRadiusX, fabric.Circle#getRadiusY methods.
This commit is contained in:
parent
752eff298d
commit
cc0c5085d7
3 changed files with 59 additions and 0 deletions
17
dist/all.js
vendored
17
dist/all.js
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in a new issue