From d1ef6869a9e9404ce7039ddddad8fa35240d4f42 Mon Sep 17 00:00:00 2001 From: Ray San Date: Fri, 2 Feb 2018 11:01:38 +0100 Subject: [PATCH] Added function DrawRectangleLinesEx() --- src/raylib.h | 1 + src/shapes.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/raylib.h b/src/raylib.h index 76ad9b557..f881dc68f 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -851,6 +851,7 @@ RLAPI void DrawRectangleGradientV(int posX, int posY, int width, int height, Col RLAPI void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a horizontal-gradient-filled rectangle RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline +RLAPI void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color); // Draw rectangle outline with extended parameters RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version) diff --git a/src/shapes.c b/src/shapes.c index fac147604..693463ff4 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -457,6 +457,21 @@ void DrawRectangleLines(int posX, int posY, int width, int height, Color color) } } +// Draw rectangle outline with extended parameters +void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color) +{ + if (lineThick > rec.width || lineThick > rec.height) + { + if(rec.width > rec.height) lineThick = rec.height/2; + else if (rec.width < rec.height) lineThick = rec.width/2; + } + + DrawRectangle(rec.x, rec.y, rec.width, lineThick, color); + DrawRectangle(rec.x - lineThick + rec.width, rec.y + lineThick, lineThick, rec.height - lineThick*2, color); + DrawRectangle(rec.x, rec.y + rec.height - lineThick, rec.width, lineThick, color); + DrawRectangle(rec.x, rec.y + lineThick, lineThick, rec.height - lineThick*2, color); +} + // Draw a triangle void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color) {