25 return SDL_RectEquals(&a, &
b) != SDL_FALSE;
35 s <<
'[' << r.x <<
',' << r.y <<
'|' << r.w <<
',' << r.h <<
']';
41 return SDL_RectEquals(
this, &r) != SDL_FALSE;
46 return SDL_RectEquals(
this, &r) != SDL_FALSE;
51 return SDL_RectEmpty(
this);
57 return SDL_PointInRect(&
p,
this) != SDL_FALSE;
62 return SDL_PointInRect(&
point,
this) != SDL_FALSE;
67 if(this->x > r.x)
return false;
68 if(this->y > r.y)
return false;
69 if(this->x + this->
w < r.x + r.w)
return false;
70 if(this->y + this->
h < r.y + r.h)
return false;
76 return SDL_HasIntersection(
this, &r);
82 SDL_UnionRect(
this, &other, &result);
88 SDL_UnionRect(
this, &other,
this);
95 if(!SDL_IntersectRect(
this, &other, &result)) {
128 static_cast<int>(this->x + std::round(this->
w * std::clamp(x, 0.0, 1.0))),
129 static_cast<int>(this->y + std::round(this->
h * std::clamp(y, 0.0, 1.0)))
135 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.
void clip(const rect &r)
Clip this rectangle by the given rectangle.
rect minimal_cover(const rect &r) const
Calculates the minimal rectangle that completely contains both this rectangle and the given rectangle...
bool empty() const
False if both w and h are > 0, true otherwise.
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.
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
rect intersect(const rect &r) const
Calculates the intersection of this rectangle and another; that is, the maximal rectangle that is con...
void shift(const point &p)
Shift the rectangle by the given relative position.
rect & expand_to_cover(const rect &r)
Minimally expand this rect to fully contain another.
bool overlaps(const rect &r) const
Whether the given rectangle and this rectangle overlap.
static map_location::direction s