Skip to content

Commit

Permalink
fix box issue
Browse files Browse the repository at this point in the history
  • Loading branch information
techird committed Sep 14, 2014
1 parent fee45f6 commit d3163f9
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 7 deletions.
29 changes: 27 additions & 2 deletions dist/kity.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* ====================================================
* kity - v2.0.0 - 2014-08-28
* kity - v2.0.0 - 2014-09-14
* https://github.com/fex-team/kity
* GitHub: https://github.com/fex-team/kity.git
* Copyright (c) 2014 Baidu FEX; Licensed BSD
Expand Down Expand Up @@ -3139,12 +3139,15 @@ _p[25] = {
*
* ```js
* var box1 = new kity.Box(10, 10, 50, 50);
* var box2 = new kity.BOx(30, 30, 50, 50);
* var box2 = new kity.Box(30, 30, 50, 50);
* var box3 = box1.merge(box2);
* console.log(box3.valueOf()); // [10, 10, 70, 70]
* ```
*/
merge: function(another) {
if (this.isEmpty()) {
return new Box(another.x, another.y, another.width, another.height);
}
var left = Math.min(this.left, another.left), right = Math.max(this.right, another.right), top = Math.min(this.top, another.top), bottom = Math.max(this.bottom, another.bottom);
return new Box(left, top, right - left, bottom - top);
},
Expand Down Expand Up @@ -3228,6 +3231,22 @@ _p[25] = {
*/
toString: function() {
return this.valueOf().join(" ");
},
/**
* @method isEmpty()
* @for kity.Box
* @description 判断当前盒子是否具有尺寸(面积大
*
* @grammar isEmpty() => {boolean}
*
* @example
* ```js
* var box = new kity.Box(0, 0, 0, 100000);
* console.log(box.isEmpty()); // true
* ```
*/
isEmpty: function() {
return !this.width || !this.height;
}
});
/**
Expand Down Expand Up @@ -6351,6 +6370,12 @@ _p[51] = {
},
spof: function() {
return new Point((this.x | 0) + .5, (this.y | 0) + .5);
},
round: function() {
return new Point(this.x | 0, this.y | 0);
},
isOrigin: function() {
return this.x === 0 && this.y === 0;
}
});
/**
Expand Down
8 changes: 4 additions & 4 deletions dist/kity.min.js

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion src/graphic/box.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,15 @@ define(function(require, exports, module) {
*
* ```js
* var box1 = new kity.Box(10, 10, 50, 50);
* var box2 = new kity.BOx(30, 30, 50, 50);
* var box2 = new kity.Box(30, 30, 50, 50);
* var box3 = box1.merge(box2);
* console.log(box3.valueOf()); // [10, 10, 70, 70]
* ```
*/
merge: function(another) {
if (this.isEmpty()) {
return new Box(another.x, another.y, another.width, another.height);
}
var left = Math.min(this.left, another.left),
right = Math.max(this.right, another.right),
top = Math.min(this.top, another.top),
Expand Down Expand Up @@ -280,6 +283,23 @@ define(function(require, exports, module) {
*/
toString: function() {
return this.valueOf().join(' ');
},

/**
* @method isEmpty()
* @for kity.Box
* @description 判断当前盒子是否具有尺寸(面积大
*
* @grammar isEmpty() => {boolean}
*
* @example
* ```js
* var box = new kity.Box(0, 0, 0, 100000);
* console.log(box.isEmpty()); // true
* ```
*/
isEmpty: function() {
return !this.width || !this.height;
}
});

Expand Down
8 changes: 8 additions & 0 deletions src/graphic/point.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ define(function(require, exports, module) {

spof: function() {
return new Point((this.x | 0) + 0.5, (this.y | 0) + 0.5);
},

round: function() {
return new Point((this.x | 0), (this.y | 0));
},

isOrigin: function() {
return this.x === 0 && this.y === 0;
}
});

Expand Down

0 comments on commit d3163f9

Please sign in to comment.