From 5ee499ebffd6abc0e4eefe8ce9f892fcca2c9b3a Mon Sep 17 00:00:00 2001 From: Matthew Roush Date: Fri, 31 Jul 2026 14:56:51 -0400 Subject: [PATCH] [rshapes] Update `DrawRectangleRoundedLinesEx()` Make the outline vertices easier to work with. --- src/rshapes.c | 57 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/src/rshapes.c b/src/rshapes.c index 28e0dd007..fa357c3be 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -1052,30 +1052,47 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f \\ P13 P12 // 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] = { - {(float)rec.x + innerRadius + 0.5f, rec.y - thick + 0.5f}, - {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y - thick + 0.5f}, - {rec.x + rec.width + thick - 0.5f, (float)rec.y + innerRadius + 0.5f}, // PO, P1, P2 - {rec.x + rec.width + thick - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, - {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + rec.height + thick - 0.5f}, // P3, P4 - {(float)rec.x + innerRadius + 0.5f, rec.y + rec.height + thick - 0.5f}, - {rec.x - thick + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, - {rec.x - thick + 0.5f, (float)rec.y + innerRadius + 0.5f}, // P5, P6, P7 - {(float)rec.x + innerRadius + 0.5f, rec.y + 0.5f}, - {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + 0.5f}, // P8, P9 - {rec.x + rec.width - 0.5f, (float)rec.y + innerRadius + 0.5f}, - {rec.x + rec.width - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, // P10, P11 - {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + rec.height - 0.5f}, - {(float)rec.x + innerRadius + 0.5f, rec.y + rec.height - 0.5f}, // P12, P13 - {rec.x + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, - {rec.x + 0.5f, (float)rec.y + innerRadius + 0.5f} // P14, P15 + {x0, y0}, // P0 + {x1, y0}, // P1 + {x2, y1}, // P2 + {x2, y2}, // P3 + {x1, y3}, // P4 + {x0, y3}, // P5 + {x3, y2}, // P6 + {x3, y1}, // P7 + {x0, y4}, // P8 + {x1, y4}, // P9 + {x4, y1}, // P10 + {x4, y2}, // P11 + {x1, y5}, // P12 + {x0, y5}, // P13 + {x5, y2}, // P14 + {x5, y1} // P15 }; const Vector2 centers[4] = { - {(float)rec.x + innerRadius + 0.5f, (float)rec.y + innerRadius + 0.5f}, - {(float)(rec.x + rec.width) - innerRadius - 0.5f, (float)rec.y + innerRadius + 0.5f}, // P16, P17 - {(float)(rec.x + rec.width) - innerRadius - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, - {(float)rec.x + innerRadius + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f} // P18, P19 + {x0, y1}, // P16 + {x1, y1}, // P17 + {x1, y2}, // P18 + {x0, y2} // P19 }; const float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f };