aboutsummaryrefslogtreecommitdiff
path: root/View.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'View.cpp')
-rw-r--r--View.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/View.cpp b/View.cpp
index 998356f..05b823c 100644
--- a/View.cpp
+++ b/View.cpp
@@ -91,7 +91,7 @@ void View::draw_end() {
SDL_RenderPresent(this->renderer);
}
-void View::draw_rect(Rectangle r, Color c) {
+void View::fill_rect(Rectangle r, Color c) {
SDL_SetRenderDrawColor(this->renderer, c.red, c.green, c.blue, 255);
SDL_FRect rect = {
.x = static_cast<float>(r.x),
@@ -102,6 +102,24 @@ void View::draw_rect(Rectangle r, Color c) {
SDL_RenderFillRect(this->renderer, &rect);
}
+void View::draw_rect(Rectangle r, Color c, unsigned border_width) {
+ SDL_SetRenderDrawColor(this->renderer, c.red, c.green, c.blue, 255);
+ SDL_FRect rect;
+ rect.x = r.x;
+ rect.y = r.y;
+ rect.w = r.width;
+ rect.h = border_width;
+ SDL_RenderFillRect(this->renderer, &rect);
+ rect.y = r.y + r.height - border_width;
+ SDL_RenderFillRect(this->renderer, &rect);
+ rect.y = r.y;
+ rect.h = r.height;
+ rect.w = border_width;
+ SDL_RenderFillRect(this->renderer, &rect);
+ rect.x = r.x + r.width - border_width;
+ SDL_RenderFillRect(this->renderer, &rect);
+}
+
typedef struct {
void (* callback)(std::vector<std::string> files, void* data);
void * data;