Files
esengine/source/src/Utils/RectangleExt.ts

17 lines
648 B
TypeScript
Raw Normal View History

2020-06-16 11:59:40 +08:00
class RectangleExt {
2020-07-20 16:38:49 +08:00
/**
*
* @param first
* @param point
*/
2020-07-08 15:15:15 +08:00
public static union(first: Rectangle, point: Vector2){
2020-06-16 11:59:40 +08:00
let rect = new Rectangle(point.x, point.y, 0, 0);
2020-07-20 16:38:49 +08:00
// let rectResult = first.union(rect);
let result = new Rectangle();
result.x = Math.min(first.x, rect.x);
result.y = Math.min(first.y, rect.y);
result.width = Math.max(first.right, rect.right) - result.x;
result.height = Math.max(first.bottom, result.bottom) - result.y;
return result;
2020-06-16 11:59:40 +08:00
}
}