mirror of
https://github.com/libretro/devilutionX.git
synced 2026-11-12 18:38:44 -10:00
30 lines
643 B
C++
30 lines
643 B
C++
#pragma once
|
|
|
|
#include "engine/point.hpp"
|
|
#include "engine/size.hpp"
|
|
|
|
namespace devilution {
|
|
|
|
struct Rectangle {
|
|
Point position;
|
|
Size size;
|
|
|
|
constexpr bool Contains(Point point) const
|
|
{
|
|
return point.x >= this->position.x
|
|
&& point.x < (this->position.x + this->size.width)
|
|
&& point.y >= this->position.y
|
|
&& point.y < (this->position.y + this->size.height);
|
|
}
|
|
|
|
/**
|
|
* @brief Computes the center of this rectangle in integer coordinates. Values are truncated towards zero.
|
|
*/
|
|
constexpr Point Center() const
|
|
{
|
|
return position + Displacement(size / 2);
|
|
}
|
|
};
|
|
|
|
} // namespace devilution
|