[nostalgia] Rename common package to geo
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include "bounds.hpp"
|
||||
|
||||
namespace nostalgia::geo {
|
||||
|
||||
Bounds::Bounds(int x, int y, int w, int h) noexcept {
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->width = w;
|
||||
this->height = h;
|
||||
}
|
||||
|
||||
bool Bounds::intersects(const Bounds &o) const noexcept {
|
||||
return o.x2() >= x && x2() >= o.x && o.y2() >= y && y2() >= o.y;
|
||||
}
|
||||
|
||||
bool Bounds::contains(int x, int y) const noexcept {
|
||||
return x >= this->x && y >= this->y && x <= x2() && y <= y2();
|
||||
}
|
||||
|
||||
int Bounds::x2() const noexcept {
|
||||
return x + width;
|
||||
}
|
||||
|
||||
int Bounds::y2() const noexcept {
|
||||
return y + height;
|
||||
}
|
||||
|
||||
Point Bounds::pt1() const noexcept {
|
||||
return {x, y};
|
||||
}
|
||||
|
||||
Point Bounds::pt2() const noexcept {
|
||||
return {x2(), y2()};
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user