[rshapes] Fix DrawPolyLinesEx() (#6004)
If `innerRadius` is less than 0, it causes the outline to overlap itself and even grow outside of the polygon's bounds when `thick` is greater than `radius`. Clamping `innerRadius` to 0 fixes these problems.
This commit is contained in:
parent
353268b7cf
commit
127e7441da
1 changed files with 3 additions and 1 deletions
|
|
@ -1260,10 +1260,12 @@ void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Colo
|
||||||
|
|
||||||
void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float thick, Color color)
|
void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float thick, Color color)
|
||||||
{
|
{
|
||||||
|
if (thick <= 0.0f) return;
|
||||||
|
|
||||||
if (sides < 3) sides = 3;
|
if (sides < 3) sides = 3;
|
||||||
float centralAngle = rotation*DEG2RAD;
|
float centralAngle = rotation*DEG2RAD;
|
||||||
float exteriorAngle = 360.0f/(float)sides*DEG2RAD;
|
float exteriorAngle = 360.0f/(float)sides*DEG2RAD;
|
||||||
float innerRadius = radius - (thick*cosf(DEG2RAD*exteriorAngle/2.0f));
|
float innerRadius = fmaxf(0.0f, radius - (thick*cosf(DEG2RAD*exteriorAngle/2.0f)));
|
||||||
|
|
||||||
#if SUPPORT_QUADS_DRAW_MODE
|
#if SUPPORT_QUADS_DRAW_MODE
|
||||||
rlSetTexture(GetShapesTexture().id);
|
rlSetTexture(GetShapesTexture().id);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue