Skip to content

Commit 0503fdf

Browse files
committed
rshapes: fix auto segment rounded-corner math and rounding
1 parent 0d78f10 commit 0503fdf

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/rshapes.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
361361
{
362362
// Calculate the maximum angle between segments based on the error rate (usually 0.5f)
363363
float th = acosf(2*powf(1 - SMOOTH_CIRCLE_ERROR_RATE/radius, 2) - 1);
364-
segments = (int)((endAngle - startAngle)*ceilf(2*PI/th)/360);
364+
segments = (int)ceilf((endAngle - startAngle)*(2*PI/th)/360.0f);
365365

366366
if (segments <= 0) segments = minSegments;
367367
}
@@ -453,7 +453,7 @@ void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float
453453
{
454454
// Calculate the maximum angle between segments based on the error rate (usually 0.5f)
455455
float th = acosf(2*powf(1 - SMOOTH_CIRCLE_ERROR_RATE/radius, 2) - 1);
456-
segments = (int)((endAngle - startAngle)*ceilf(2*PI/th)/360);
456+
segments = (int)ceilf((endAngle - startAngle)*(2*PI/th)/360.0f);
457457

458458
if (segments <= 0) segments = minSegments;
459459
}
@@ -579,7 +579,7 @@ void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startA
579579
{
580580
// Calculate the maximum angle between segments based on the error rate (usually 0.5f)
581581
float th = acosf(2*powf(1 - SMOOTH_CIRCLE_ERROR_RATE/outerRadius, 2) - 1);
582-
segments = (int)((endAngle - startAngle)*ceilf(2*PI/th)/360);
582+
segments = (int)ceilf((endAngle - startAngle)*(2*PI/th)/360.0f);
583583

584584
if (segments <= 0) segments = minSegments;
585585
}
@@ -670,7 +670,7 @@ void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float s
670670
{
671671
// Calculate the maximum angle between segments based on the error rate (usually 0.5f)
672672
float th = acosf(2*powf(1 - SMOOTH_CIRCLE_ERROR_RATE/outerRadius, 2) - 1);
673-
segments = (int)((endAngle - startAngle)*ceilf(2*PI/th)/360);
673+
segments = (int)ceilf((endAngle - startAngle)*(2*PI/th)/360.0f);
674674

675675
if (segments <= 0) segments = minSegments;
676676
}
@@ -960,7 +960,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
960960
{
961961
// Calculate the maximum angle between segments based on the error rate (usually 0.5f)
962962
float th = acosf(2*powf(1 - SMOOTH_CIRCLE_ERROR_RATE/radius, 2) - 1);
963-
segments = (int)(ceilf(2*PI/th)/2.0f);
963+
segments = (int)ceilf((2*PI/th)/4.0f);
964964
if (segments <= 0) segments = 4;
965965
}
966966

@@ -1195,7 +1195,7 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f
11951195
{
11961196
// Calculate the maximum angle between segments based on the error rate (usually 0.5f)
11971197
float th = acosf(2*powf(1 - SMOOTH_CIRCLE_ERROR_RATE/radius, 2) - 1);
1198-
segments = (int)(ceilf(2*PI/th)/2.0f);
1198+
segments = (int)ceilf((2*PI/th)/4.0f);
11991199
if (segments <= 0) segments = 4;
12001200
}
12011201

0 commit comments

Comments
 (0)