Preserve floating point values in DrawRectangleLinesEx (#1683)
This commit is contained in:
parent
f9bab14fdb
commit
b6ca524bdd
1 changed files with 24 additions and 8 deletions
24
src/shapes.c
24
src/shapes.c
|
@ -760,10 +760,26 @@ void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color)
|
||||||
else if (rec.width < rec.height) lineThick = (int)rec.width/2;
|
else if (rec.width < rec.height) lineThick = (int)rec.width/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawRectangle( (int)rec.x, (int)rec.y, (int)rec.width, lineThick, color);
|
// When rec = { x, y, 8.0f, 6.0f } and lineThick = 2, the following
|
||||||
DrawRectangle( (int)(rec.x - lineThick + rec.width), (int)(rec.y + lineThick), lineThick, (int)(rec.height - lineThick*2.0f), color);
|
// four rectangles are drawn ([T]op, [B]ottom, [L]eft, [R]ight):
|
||||||
DrawRectangle( (int)rec.x, (int)(rec.y + rec.height - lineThick), (int)rec.width, lineThick, color);
|
//
|
||||||
DrawRectangle( (int)rec.x, (int)(rec.y + lineThick), lineThick, (int)(rec.height - lineThick*2), color);
|
// TTTTTTTT
|
||||||
|
// TTTTTTTT
|
||||||
|
// LL RR
|
||||||
|
// LL RR
|
||||||
|
// BBBBBBBB
|
||||||
|
// BBBBBBBB
|
||||||
|
//
|
||||||
|
float thick = (float)lineThick;
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw rectangle with rounded edges
|
// Draw rectangle with rounded edges
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue