From 63f82f0ca873f762ffea0c83ed14e461a905b7fc Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 29 Jul 2026 10:10:26 +0200 Subject: [PATCH] REVIEWED: `DrawRectangleLinesEx()`, avoid early-return NOTE: raylib data validation policy defines not to validate any data that does not suppose a crash in the program, letting user manage that layer... probably several functions should be carefully reviewed or the policy itself... --- src/rshapes.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/rshapes.c b/src/rshapes.c index cc994b99e..5d3598381 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -631,8 +631,6 @@ void DrawRectangleLines(int posX, int posY, int width, int height, Color color) // Draw rectangle outline with line thickness void DrawRectangleLinesEx(Rectangle rec, float thick, Color color) { - if (thick <= 0.0f) return; - if ((thick > rec.width/2) || (thick > rec.height/2)) { if (rec.width >= rec.height) thick = rec.height/2; @@ -649,16 +647,19 @@ void DrawRectangleLinesEx(Rectangle rec, float thick, Color color) // BBBBBBBB // BBBBBBBB // + + if (thick > 0.0f) + { + Rectangle top = { rec.x, rec.y, rec.width, thick }; + Rectangle bottom = { rec.x, rec.y - thick + rec.height, rec.width, thick }; + Rectangle left = { rec.x, rec.y + thick, thick, rec.height - thick*2.0f }; + Rectangle right = { rec.x - thick + rec.width, rec.y + thick, thick, rec.height - thick*2.0f }; - Rectangle top = { rec.x, rec.y, rec.width, thick }; - Rectangle bottom = { rec.x, rec.y - thick + rec.height, rec.width, thick }; - Rectangle left = { rec.x, rec.y + thick, thick, rec.height - thick*2.0f }; - Rectangle right = { rec.x - thick + rec.width, rec.y + thick, thick, rec.height - thick*2.0f }; - - DrawRectangleRec(top, color); - DrawRectangleRec(bottom, color); - DrawRectangleRec(left, color); - DrawRectangleRec(right, color); + DrawRectangleRec(top, color); + DrawRectangleRec(bottom, color); + DrawRectangleRec(left, color); + DrawRectangleRec(right, color); + } } // Draw rectangle with rounded edges