make all Box methods const

This commit is contained in:
hippoz 2022-03-18 03:24:02 +02:00
parent 9c830c48d6
commit 19abbbf057
Signed by: hippoz
GPG key ID: 7C52899193467641
2 changed files with 11 additions and 6 deletions

View file

@ -3,15 +3,15 @@
namespace Raven { namespace Raven {
bool Box::contains_point(double x, double y) { bool Box::contains_point(double x, double y) const {
return x >= m_x && m_x + m_width >= x && y >= m_y && m_y + m_height >= y; return x >= m_x && m_x + m_width >= x && y >= m_y && m_y + m_height >= y;
} }
bool Box::contains_point(Point &point) { bool Box::contains_point(const Point &point) const {
return point.get_x() >= m_x && m_x + m_width >= point.get_x() && point.get_y() >= m_y && m_y + m_height >= point.get_y(); return point.get_x() >= m_x && m_x + m_width >= point.get_x() && point.get_y() >= m_y && m_y + m_height >= point.get_y();
} }
bool Box::contains_box(Box &other) const { bool Box::contains_box(const Box &other) const {
double ax1 = m_x; double ax1 = m_x;
double ax2 = m_x + m_width; double ax2 = m_x + m_width;
double ay1 = m_y; double ay1 = m_y;

View file

@ -26,14 +26,19 @@ public:
double get_width() { return m_width; } double get_width() { return m_width; }
double get_height() { return m_height; } double get_height() { return m_height; }
double get_x() const { return m_x; }
double get_y() const { return m_y; }
double get_width() const { return m_width; }
double get_height() const { return m_height; }
void set_x(double x) { m_x = x; } void set_x(double x) { m_x = x; }
void set_y(double y) { m_y = y; } void set_y(double y) { m_y = y; }
void set_width(double width) { m_width = width; } void set_width(double width) { m_width = width; }
void set_height(double height) { m_height = height; } void set_height(double height) { m_height = height; }
bool contains_point(double x, double y); bool contains_point(double x, double y) const;
bool contains_point(Point &point); bool contains_point(const Point &point) const;
bool contains_box(Box &other) const; bool contains_box(const Box &other) const;
}; };
} }