|
@@ -152,7 +152,6 @@ export class SRect {
|
|
|
height?: number
|
|
|
) {
|
|
|
if (x == undefined) {
|
|
|
-
|
|
|
this.leftTop = new SPoint(0, 0);
|
|
|
this.size = new SSize(0, 0);
|
|
|
} else if (x instanceof SPoint && y instanceof SPoint) {
|
|
@@ -302,8 +301,6 @@ export class SRect {
|
|
|
|
|
|
/**
|
|
|
* 合并矩形
|
|
|
- *
|
|
|
- * @param rect 合并的矩形
|
|
|
*/
|
|
|
union(rect: SRect): void {
|
|
|
let r = this.unioned(rect);
|
|
@@ -342,21 +339,19 @@ export class SRect {
|
|
|
this.width + rect.width > maxX - minX &&
|
|
|
this.height + rect.height > maxY - minY
|
|
|
) {
|
|
|
- return new SRect();
|
|
|
+ return new SRect(new SPoint(minX, minY), new SPoint(maxX, maxY));
|
|
|
}
|
|
|
return new SRect();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 相交矩形
|
|
|
- *
|
|
|
- * @param rect 合并的矩形
|
|
|
*/
|
|
|
- intersect(rect: SRect): SRect {
|
|
|
- let left = Math.min(this.left, rect.left);
|
|
|
- let top = Math.min(this.top, rect.top);
|
|
|
- let right = Math.max(this.right, rect.right);
|
|
|
- let bottom = Math.max(this.bottom, rect.bottom);
|
|
|
- return new SRect(left, top, right - left, bottom - top);
|
|
|
+ intersect(rect: SRect): void {
|
|
|
+ let r = this.intersected(rect);
|
|
|
+ this.x = r.x;
|
|
|
+ this.y = r.y;
|
|
|
+ this.width = r.width;
|
|
|
+ this.height = r.height;
|
|
|
}
|
|
|
}
|