Skip to content

Commit 9ff54eb

Browse files
committed
[rshapes] Correct DrawPolyLinesEx() line thickness.
Follow up to raysan5#6004. The previous formula would produce inconsistent results for different polygons with the same `thick` parameter.
1 parent f0a8201 commit 9ff54eb

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/rshapes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,8 @@ void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, fl
12651265
if (sides < 3) sides = 3;
12661266
float centralAngle = rotation*DEG2RAD;
12671267
float exteriorAngle = 360.0f/(float)sides*DEG2RAD;
1268-
float innerRadius = fmaxf(0.0f, radius - (thick*cosf(DEG2RAD*exteriorAngle/2.0f)));
1268+
float apothem = radius*cosf(DEG2RAD*180.0f/(float)sides);
1269+
float innerRadius = fmaxf(0.0f, radius - thick*(radius/apothem));
12691270

12701271
#if SUPPORT_QUADS_DRAW_MODE
12711272
rlSetTexture(GetShapesTexture().id);

0 commit comments

Comments
 (0)