diff --git a/include/twn_draw.h b/include/twn_draw.h index 458bdc5..7cb3419 100644 --- a/include/twn_draw.h +++ b/include/twn_draw.h @@ -47,6 +47,10 @@ TWN_API void draw_line(Vec2 start, float thickness, /* optional, default: 1 */ Color color); /* optional, default: all 255 */ +TWN_API void draw_box(Rect rect, + float thickness, /* optional, default: 1 */ + Color color); /* optional, default: all 255 */ + /* pushes a textured 3d triangle onto the render queue */ /* texture coordinates are in pixels */ TWN_API void draw_triangle(char const *texture, diff --git a/src/rendering/twn_draw.c b/src/rendering/twn_draw.c index 76fdc64..73dec45 100644 --- a/src/rendering/twn_draw.c +++ b/src/rendering/twn_draw.c @@ -526,3 +526,14 @@ void draw_line(Vec2 start, arrput(ctx.render_queue_2d, primitive); } + + +void draw_box(Rect rect, + float thickness, + Color color) +{ + draw_line((Vec2){rect.x, rect.y}, (Vec2){rect.x + rect.w, rect.y}, thickness, color); + draw_line((Vec2){rect.x + rect.w, rect.y}, (Vec2){rect.x + rect.w, rect.y + rect.h}, thickness, color); + draw_line((Vec2){rect.x + rect.w, rect.y + rect.h}, (Vec2){rect.x, rect.y + rect.h}, thickness, color); + draw_line((Vec2){rect.x, rect.y + rect.h}, (Vec2){rect.x, rect.y}, thickness, color); +}