[rshapes] Update DrawRectangleRoundedLinesEx()

Make the outline vertices easier to work with.
This commit is contained in:
Matthew Roush 2026-07-31 14:56:51 -04:00
commit 5ee499ebff

View file

@ -1052,30 +1052,47 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f
\\ P13 P12 // \\ P13 P12 //
P5 ================== P4 P5 ================== P4
*/ */
// The x-coordinates used for the outline
const float x0 = (float)rec.x + innerRadius + 0.5f;
const float x1 = (float)(rec.x + rec.width) - innerRadius - 0.5f;
const float x2 = rec.x + rec.width + thick - 0.5f;
const float x3 = rec.x - thick + 0.5f;
const float x4 = rec.x + rec.width - 0.5f;
const float x5 = rec.x + 0.5f;
// The y-coordinates used for the outline
const float y0 = rec.y - thick + 0.5f;
const float y1 = (float)rec.y + innerRadius + 0.5f;
const float y2 = (float)(rec.y + rec.height) - innerRadius - 0.5f;
const float y3 = rec.y + rec.height + thick - 0.5f;
const float y4 = rec.y + 0.5f;
const float y5 = rec.y + rec.height - 0.5f;
const Vector2 point[16] = { const Vector2 point[16] = {
{(float)rec.x + innerRadius + 0.5f, rec.y - thick + 0.5f}, {x0, y0}, // P0
{(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y - thick + 0.5f}, {x1, y0}, // P1
{rec.x + rec.width + thick - 0.5f, (float)rec.y + innerRadius + 0.5f}, // PO, P1, P2 {x2, y1}, // P2
{rec.x + rec.width + thick - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, {x2, y2}, // P3
{(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + rec.height + thick - 0.5f}, // P3, P4 {x1, y3}, // P4
{(float)rec.x + innerRadius + 0.5f, rec.y + rec.height + thick - 0.5f}, {x0, y3}, // P5
{rec.x - thick + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, {x3, y2}, // P6
{rec.x - thick + 0.5f, (float)rec.y + innerRadius + 0.5f}, // P5, P6, P7 {x3, y1}, // P7
{(float)rec.x + innerRadius + 0.5f, rec.y + 0.5f}, {x0, y4}, // P8
{(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + 0.5f}, // P8, P9 {x1, y4}, // P9
{rec.x + rec.width - 0.5f, (float)rec.y + innerRadius + 0.5f}, {x4, y1}, // P10
{rec.x + rec.width - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, // P10, P11 {x4, y2}, // P11
{(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + rec.height - 0.5f}, {x1, y5}, // P12
{(float)rec.x + innerRadius + 0.5f, rec.y + rec.height - 0.5f}, // P12, P13 {x0, y5}, // P13
{rec.x + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, {x5, y2}, // P14
{rec.x + 0.5f, (float)rec.y + innerRadius + 0.5f} // P14, P15 {x5, y1} // P15
}; };
const Vector2 centers[4] = { const Vector2 centers[4] = {
{(float)rec.x + innerRadius + 0.5f, (float)rec.y + innerRadius + 0.5f}, {x0, y1}, // P16
{(float)(rec.x + rec.width) - innerRadius - 0.5f, (float)rec.y + innerRadius + 0.5f}, // P16, P17 {x1, y1}, // P17
{(float)(rec.x + rec.width) - innerRadius - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, {x1, y2}, // P18
{(float)rec.x + innerRadius + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f} // P18, P19 {x0, y2} // P19
}; };
const float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f }; const float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f };