26 return SDL_PointInRect(&
p, &rect) != SDL_FALSE;
36 return (rect1.x < rect2.x+rect2.w && rect2.x < rect1.x+rect1.w &&
37 rect1.y < rect2.y+rect2.h && rect2.y < rect1.y+rect1.h);
43 if(!SDL_IntersectRect(&rect1, &rect2, &res)) {
50 SDL_Rect
union_rects(
const SDL_Rect& rect1,
const SDL_Rect& rect2)
53 SDL_UnionRect(&rect1, &rect2, &res);
62 SDL_SetRenderDrawColor(renderer, color.
r, color.
g, color.
b, color.
a);
63 SDL_RenderDrawRect(renderer, &rect);
70 SDL_SetRenderDrawColor(renderer, color.
r, color.
g, color.
b, color.
a);
71 SDL_RenderFillRect(renderer, &rect);
78 return SDL_RectEquals(&a, &b) != SDL_FALSE;
86 std::ostream&
operator<<(std::ostream&
s,
const SDL_Rect& rect)
88 s <<
"x: " << rect.x <<
", y: " << rect.y <<
", w: " << rect.w <<
", h: " << rect.h;
SDL_Rect union_rects(const SDL_Rect &rect1, const SDL_Rect &rect2)
Calculates the union of two rectangles.
bool rects_overlap(const SDL_Rect &rect1, const SDL_Rect &rect2)
Tests whether two rectangles overlap.
bool operator!=(const SDL_Rect &a, const SDL_Rect &b)
static CVideo & get_singleton()
SDL_Rect intersect_rects(const SDL_Rect &rect1, const SDL_Rect &rect2)
Calculates the intersection of two rectangles.
std::ostream & operator<<(std::ostream &s, const SDL_Rect &rect)
void draw_rectangle(const SDL_Rect &rect, const color_t &color)
Draw a rectangle outline.
sdl::window * get_window()
Returns a pointer to the underlying SDL window.
bool point_in_rect(int x, int y, const SDL_Rect &rect)
Tests whether a point is inside a rectangle.
bool operator==(const SDL_Rect &a, const SDL_Rect &b)
static map_location::DIRECTION s
Contains the SDL_Rect helper code.
constexpr const SDL_Rect empty_rect
void fill_rectangle(const SDL_Rect &rect, const color_t &color)
Draws a filled rectangle.
Contains a wrapper class for the SDL_Window class.