39 GPU_Rect create_gpu_rect(
const float x,
const float y,
const float w,
const float h)
49 return x >= rect.x && y >= rect.y && x < rect.x + rect.w && y < rect.y + rect.h;
54 return (rect1.x < rect2.x+rect2.w && rect2.x < rect1.x+rect1.w &&
55 rect1.y < rect2.y+rect2.h && rect2.y < rect1.y+rect1.h);
61 res.x = std::max<int>(rect1.x, rect2.x);
62 res.y = std::max<int>(rect1.y, rect2.y);
63 int w = std::min<int>(rect1.x + rect1.w, rect2.x + rect2.w) - res.x;
64 int h = std::min<int>(rect1.y + rect1.h, rect2.y + rect2.h) - res.y;
71 SDL_Rect
union_rects(SDL_Rect
const &rect1, SDL_Rect
const &rect2)
73 if (rect1.w == 0 || rect1.h == 0)
return rect2;
74 if (rect2.w == 0 || rect2.h == 0)
return rect1;
76 res.x = std::min<int>(rect1.x, rect2.x);
77 res.y = std::min<int>(rect1.y, rect2.y);
78 res.w = std::max<int>(rect1.x + rect1.w, rect2.x + rect2.w) - res.x;
79 res.h = std::max<int>(rect1.y + rect1.h, rect2.y + rect2.h) - res.y;
85 if(alpha == SDL_ALPHA_OPAQUE) {
88 }
else if(alpha == SDL_ALPHA_TRANSPARENT) {
97 SDL_Rect
r = {0,0,rect.w,rect.h};
123 fill_rect_alpha(rect,SDL_MapRGB(target->format,r,g,b),Uint8(alpha*255),target);
127 void draw_rect(
CVideo &video,
const SDL_Rect &rect, Uint8
r, Uint8
g,
130 video.set_texture_color_modulation(0, 0, 0, 0);
132 GPU_Rectangle(video.render_target(), rect.x, rect.y, rect.x + rect.w, rect.y + rect.h,
136 void draw_rect(
CVideo &video,
const SDL_Rect &rect, SDL_Color color)
138 video.set_texture_color_modulation(0, 0, 0, 0);
139 GPU_Rectangle(video.render_target(), rect.x, rect.y, rect.x + rect.w, rect.y + rect.h,
146 video.set_texture_color_modulation(0, 0, 0, 0);
147 SDL_Color color = {
r,
g,
b, a};
149 rect.y + rect.h,
color);
154 video.set_texture_color_modulation(0, 0, 0, 0);
156 rect.y + rect.h,
color);
164 return a.x == b.x && a.y == b.y && a.w == b.w && a.h == b.h;
void GPU_RectangleFilled(GPU_Target *target, float x1, float y1, float x2, float y2, SDL_Color color)
void GPU_Rectangle(GPU_Target *target, float x1, float y1, float x2, float y2, SDL_Color color)
SDL_Rect intersect_rects(SDL_Rect const &rect1, SDL_Rect const &rect2)
Calculates the intersection of two rectangles.
SDL_Rect union_rects(SDL_Rect const &rect1, SDL_Rect const &rect2)
Calculates the union of two rectangles.
void fill_rect(surface &dst, SDL_Rect *dst_rect, const Uint32 color)
Fill a rectangle on a given surface.
bool rects_overlap(const SDL_Rect &rect1, const SDL_Rect &rect2)
Tests whether two rectangles overlap.
const SDL_Rect empty_rect
bool operator!=(const SDL_Rect &a, const SDL_Rect &b)
GLint GLint GLint GLint GLint GLint y
GLdouble GLdouble GLdouble b
void draw_solid_tinted_rectangle(int x, int y, int w, int h, int r, int g, int b, double alpha, surface target)
Fills a specified rectangle area of a surface with a given color and opacity.
GLubyte GLubyte GLubyte GLubyte w
GLboolean GLboolean GLboolean GLboolean a
GLclampf GLclampf GLclampf alpha
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)
GLfloat GLfloat GLfloat GLfloat h
GLint GLint GLint GLint GLint x
GLdouble GLdouble GLdouble r
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
Creates an empty SDL_Rect.
Contains the SDL_Rect helper code.
void fill_rect_alpha(SDL_Rect &rect, Uint32 color, Uint8 alpha, surface target)
Fills a specified area of a surface with a given color and opacity.
surface create_compatible_surface(const surface &surf, int width, int height)
void sdl_blit(const surface &src, SDL_Rect *src_rect, surface &dst, SDL_Rect *dst_rect)
int SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha)
Compatibility layer for using SDL 1.2 and 2.0.
void draw_rectangle(int x, int y, int w, int h, Uint32 color, surface target)
Draw a colored rectangle on a surface.