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...
This commit is contained in:
parent
60b9f20469
commit
63f82f0ca8
1 changed files with 13 additions and 12 deletions
|
|
@ -631,8 +631,6 @@ void DrawRectangleLines(int posX, int posY, int width, int height, Color color)
|
||||||
// Draw rectangle outline with line thickness
|
// Draw rectangle outline with line thickness
|
||||||
void DrawRectangleLinesEx(Rectangle rec, float thick, Color color)
|
void DrawRectangleLinesEx(Rectangle rec, float thick, Color color)
|
||||||
{
|
{
|
||||||
if (thick <= 0.0f) return;
|
|
||||||
|
|
||||||
if ((thick > rec.width/2) || (thick > rec.height/2))
|
if ((thick > rec.width/2) || (thick > rec.height/2))
|
||||||
{
|
{
|
||||||
if (rec.width >= rec.height) 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
|
||||||
// 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 };
|
DrawRectangleRec(top, color);
|
||||||
Rectangle bottom = { rec.x, rec.y - thick + rec.height, rec.width, thick };
|
DrawRectangleRec(bottom, color);
|
||||||
Rectangle left = { rec.x, rec.y + thick, thick, rec.height - thick*2.0f };
|
DrawRectangleRec(left, color);
|
||||||
Rectangle right = { rec.x - thick + rec.width, rec.y + thick, thick, rec.height - thick*2.0f };
|
DrawRectangleRec(right, color);
|
||||||
|
}
|
||||||
DrawRectangleRec(top, color);
|
|
||||||
DrawRectangleRec(bottom, color);
|
|
||||||
DrawRectangleRec(left, color);
|
|
||||||
DrawRectangleRec(right, color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw rectangle with rounded edges
|
// Draw rectangle with rounded edges
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue