mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Implement Rectangle#getArea() and use it in reorientPath()
This commit is contained in:
parent
4926e2c8da
commit
5f24bf8da5
2 changed files with 13 additions and 4 deletions
|
@ -470,11 +470,21 @@ var Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
* @type Point
|
||||
*/
|
||||
|
||||
/**
|
||||
* The area of the rectangle in square points.
|
||||
*
|
||||
* @type Number
|
||||
* @bean
|
||||
*/
|
||||
getArea: function() {
|
||||
return this.width * this.height;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {Boolean} {@true the rectangle is empty}
|
||||
*/
|
||||
isEmpty: function() {
|
||||
return this.width == 0 || this.height == 0;
|
||||
return this.width === 0 || this.height === 0;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -81,9 +81,8 @@ PathItem.inject(new function() {
|
|||
bounds = new Array(length),
|
||||
counters = new Array(length),
|
||||
clockwise;
|
||||
children.sort(function(a, b){
|
||||
var b1 = a.getBounds(), b2 = b.getBounds();
|
||||
return b2._width * b2._height - b1._width * b1._height;
|
||||
children.sort(function(a, b) {
|
||||
return b.getBounds().getArea() - a.getBounds().getArea();
|
||||
});
|
||||
path.addChildren(children);
|
||||
clockwise = children[0].isClockwise();
|
||||
|
|
Loading…
Reference in a new issue