24 return SDL_RectEquals(&a, &
b) != SDL_FALSE;
34 s <<
'[' << r.x <<
',' << r.y <<
'|' << r.w <<
',' << r.h <<
']';
40 return SDL_RectEquals(
this, &r) != SDL_FALSE;
45 return SDL_RectEquals(
this, &r) != SDL_FALSE;
50 return SDL_RectEmpty(
this);
56 return SDL_PointInRect(&
p,
this) != SDL_FALSE;
61 return SDL_PointInRect(&
point,
this) != SDL_FALSE;
66 if(this->x > r.x)
return false;
67 if(this->y > r.y)
return false;
68 if(this->x + this->
w < r.x + r.w)
return false;
69 if(this->y + this->
h < r.y + r.h)
return false;
75 return SDL_HasIntersection(
this, &r);
81 SDL_UnionRect(
this, &other, &result);
87 SDL_UnionRect(
this, &other,
this);
94 if(!SDL_IntersectRect(
this, &other, &result)) {
127 static_cast<int>(this->x + this->
w * std::clamp(x, 0.0, 1.0)),
128 static_cast<int>(this->y + this->
h * std::clamp(y, 0.0, 1.0))
134 s <<
'[' << r.x <<
',' << r.y <<
'|' << r.w <<
',' << r.h <<
']';
bool operator==(const SDL_Rect &a, const SDL_Rect &b)
std::ostream & operator<<(std::ostream &s, const SDL_Rect &r)
bool operator!=(const SDL_Rect &a, const SDL_Rect &b)
Contains the SDL_Rect helper code.
An abstract description of a rectangle with integer coordinates.
bool empty() const
False if both w and h are > 0, true otherwise.
rect & expand_to_cover(const SDL_Rect &r)
Minimally expand this rect to fully contain another.
rect shifted_by(int x, int y) const
Returns a new rectangle shifted by the given relative position.
point point_at(double x, double y) const
Returns the proper point that corresponds to the given [0.0, 1.0] coordinates.
rect minimal_cover(const SDL_Rect &r) const
Calculates the minimal rectangle that completely contains both this rectangle and the given rectangle...
constexpr rect()
Explicitly initialize rects to 0.
bool contains(int x, int y) const
Whether the given point lies within the rectangle.
bool operator==(const rect &r) const
void clip(const SDL_Rect &r)
Clip this rectangle by the given rectangle.
void shift(const point &p)
Shift the rectangle by the given relative position.
rect intersect(const SDL_Rect &r) const
Calculates the intersection of this rectangle and another; that is, the maximal rectangle that is con...
bool overlaps(const SDL_Rect &r) const
Whether the given rectangle and this rectangle overlap.
static map_location::direction s