#include #include #include #include #include using std::abs; namespace kurator { namespace engine { Rect::Rect() : position {0, 0}, size {0, 0} { } Rect::Rect(const Point& first, const Point& second) : position {std::min(first.x, second.x), std::min(first.y, second.y)}, size {abs(second - first)} { } Point Rect::topleft() const { return position; } Point Rect::bottomright() const { return position + size; } Point Rect::center() const { return position + size.scale(0.5); } bool Rect::contains(const Point& point) { const auto br = bottomright(); return point.x >= position.x && point.x <= br.x && point.y >= position.y && point.y <= br.y; } bool Rect::contains(const Point& circle, double radius) { return CheckCollisionCircleRec( {static_cast(circle.x), static_cast(circle.y)}, radius, { static_cast(position.x), static_cast(position.y), static_cast(size.x), static_cast(size.y) }); } } // namespace engine } // namespace kurator