[nostalgia] Rename common package to geo

This commit is contained in:
2022-02-13 04:03:10 -06:00
parent 0aa71f1dbb
commit 320df614a9
26 changed files with 131 additions and 130 deletions
+40
View File
@@ -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()};
}
}