Skip to content

Commit

Permalink
Added contains method to rectangle to test if it contains the given v…
Browse files Browse the repository at this point in the history
…ector.
  • Loading branch information
bXi committed Mar 20, 2024
1 parent b15984f commit 53c1d7a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions utils/rectangles.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ union rect_generic {

rect_generic(T _x, T _y, T _width, T _height) : x(_x), y(_y), width(_width), height(_height) {}

bool contains(const v2d_generic<T> &_point) {
return !(_point.x < this->pos.x || _point.y < this->pos.y ||
_point.x > (this->pos.x + this->size.x) || _point.y > (this->pos.y + this->size.y));
}

#if __has_include("SDL3/SDL.h")

Expand Down

0 comments on commit 53c1d7a

Please sign in to comment.