Add fill_rect function

This commit is contained in:
Abdelrahman Said 2024-01-14 22:59:28 +00:00
parent 921bfbf63c
commit 63312be847
2 changed files with 9 additions and 0 deletions

View File

@ -60,5 +60,6 @@ void draw_line(const window_t *wnd, const line_t *ln, colour_t colour);
void draw_triangle(const window_t *wnd, const triangle_t *triangle, void draw_triangle(const window_t *wnd, const triangle_t *triangle,
colour_t colour); colour_t colour);
void draw_rect(const window_t *wnd, const rect_t *rect, colour_t colour); void draw_rect(const window_t *wnd, const rect_t *rect, colour_t colour);
void fill_rect(const window_t *wnd, const rect_t *rect, colour_t colour);
#endif // !WINDOW_H #endif // !WINDOW_H

View File

@ -81,3 +81,11 @@ void draw_rect(const window_t *wnd, const rect_t *rect, colour_t colour) {
SDL_RenderDrawRect(wnd->renderer, &dst); SDL_RenderDrawRect(wnd->renderer, &dst);
} }
void fill_rect(const window_t *wnd, const rect_t *rect, colour_t colour) {
set_colour(wnd, colour);
SDL_Rect dst = {rect->topleft.x, rect->topleft.y, rect->w, rect->h};
SDL_RenderFillRect(wnd->renderer, &dst);
}