class Rectangle { constructor(x, y, w, h) { this.X = x; this.Y = y; this.W = w; this.H = h; } static containsPoint(rectangle, point) { const x2 = (rectangle.X + rectangle.W); const y2 = (rectangle.Y + rectangle.H); return ((point.X >= rectangle.X) && (point.X <= x2) && (point.Y >= rectangle.Y) && (point.Y <= y2)); } static combine(rect1, rect2) { const x2 = Math.max((rect1.X + rect1.W), (rect2.X + rect2.W)); const y2 = Math.max((rect1.Y + rect1.H), (rect2.Y + rect2.H)); const rect = { X: Math.min(rect1.X, rect2.X), Y: Math.min(rect1.Y, rect2.Y), W: 0, H: 0 }; rect.W = x2 - rect.X; rect.H = y2 - rect.Y; return rect; }; } export default Rectangle;