#include "Geometry.h" #include namespace UI { bool Rect::Contains(float px, float py) const { return px >= X && px <= (X + Width) && py >= Y && py <= (Y + Height); } bool Rect::Contains(Point p) const { return Contains(p.x, p.y); } Rect Rect::Intersect(const Rect& other) const { float newX = std::max(X, other.X); float newY = std::max(Y, other.Y); float newRight = std::min(X + Width, other.X + other.Width); float newBottom = std::min(Y + Height, other.Y + other.Height); float newWidth = std::max(0.0f, newRight - newX); float newHeight = std::max(0.0f, newBottom - newY); return Rect(newX, newY, newWidth, newHeight); } /*Rect Rect::Deflate(const Thickness& t) const { float newX = X + t.Left; float newY = Y + t.Top; float newWidth = std::max(0.0f, Width - t.HorizontalTotal()); float newHeight = std::max(0.0f, Height - t.VerticalTotal()); return Rect(newX, newY, newWidth, newHeight); } Rect Rect::Inflate(const Thickness& t) const { return Rect(X - t.Left, Y - t.Top, Width + t.HorizontalTotal(), Height + t.VerticalTotal()); } */ }