25 #include <SDL2/SDL_rect.h> 50 constexpr
rect() : SDL_Rect{0, 0, 0, 0} {}
53 constexpr
rect(
const SDL_Rect& r) : SDL_Rect{r} {}
56 constexpr
rect(
int x,
int y,
int w,
int h) : SDL_Rect{x, y,
w, h} {}
60 : SDL_Rect{pos.x, pos.y, size.x, size.y}
74 return {x *
s, y *
s,
w *
s,
h * s};
88 return {x /
s, y /
s,
w /
s,
h / s};
101 constexpr
int area()
const {
return w *
h; }
111 bool contains(
const SDL_Rect& r)
const;
114 bool overlaps(
const SDL_Rect& r)
const;
120 rect minimal_cover(
const SDL_Rect& r)
const;
123 rect& expand_to_cover(
const SDL_Rect& r);
129 rect intersect(
const SDL_Rect& r)
const;
136 void clip(
const SDL_Rect& r);
143 void shift(
const point& p);
constexpr rect & operator/=(int s)
constexpr rect(int x, int y, int w, int h)
Specify via (x, y, w, h).
constexpr rect()
Explicitly initialize rects to 0.
constexpr rect(const SDL_Rect &r)
There's nothing extra when converting an SDL_Rect.
constexpr point pos() const
constexpr rect operator*(int s) const
constexpr rect & operator*=(int s)
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
bool operator==(const SDL_Rect &a, const SDL_Rect &b)
bool operator!=(const SDL_Rect &a, const SDL_Rect &b)
constexpr int area() const
The area of this rectangle, in square pixels.
constexpr point size() const
static map_location::DIRECTION s
An abstract description of a rectangle with integer coordinates.
constexpr const SDL_Rect empty_rect
constexpr rect(const point &pos, const point &size)
Specify via top-left corner position and size.
constexpr rect operator/(int s) const
std::ostream & operator<<(std::ostream &s, const SDL_Rect &rect)