#include namespace ui { bool Rect::contains(Point point) { return point.x >= begin.x && point.y >= begin.y && point.x <= begin.x + width && point.y <= begin.y + height; } Point Rect::normalize(Point point) { if (point.x < begin.x) point.x = begin.x; if (point.y < begin.y) point.y = begin.y; if (point.x > begin.x + width) point.x = begin.x + width; if (point.y > begin.y + height) point.y = begin.y + height; return point; } };