mirror of
https://github.com/raysan5/raylib.git
synced 2026-08-13 02:35:20 +00:00
[rshapes] Fix drawing circle sectors (#6045)
* [rshapes] Fix drawing circle sectors Functions that draw a sector of a circle would keep drawing segments past a full rotation, which looked bad. * [rshapes] Change `DrawCircleSectorLines()` and `DrawRingLines()` `DrawCircleSectorLines()` and `DrawRingLines()` drew the cap lines even when drawing a full circle, which seems undesirable.
This commit is contained in:
@@ -1481,6 +1481,9 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
|
||||
endAngle = tmp;
|
||||
}
|
||||
|
||||
// Drawing a whole circle, things get weird without limiting the circle to 360 degrees
|
||||
if (endAngle - startAngle >= 360.0f) endAngle = startAngle + 360.0f;
|
||||
|
||||
int minSegments = (int)ceilf((endAngle - startAngle)/90);
|
||||
|
||||
if (segments < minSegments)
|
||||
@@ -1573,6 +1576,14 @@ void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float
|
||||
endAngle = tmp;
|
||||
}
|
||||
|
||||
bool showCapLines = true;
|
||||
// Drawing a whole circle, things get weird without limiting the circle to 360 degrees
|
||||
if (endAngle - startAngle >= 360.0f)
|
||||
{
|
||||
showCapLines = false;
|
||||
endAngle = startAngle + 360.0f;
|
||||
}
|
||||
|
||||
int minSegments = (int)ceilf((endAngle - startAngle)/90);
|
||||
|
||||
if (segments < minSegments)
|
||||
@@ -1586,7 +1597,6 @@ void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float
|
||||
|
||||
float stepLength = (endAngle - startAngle)/(float)segments;
|
||||
float angle = startAngle;
|
||||
bool showCapLines = true;
|
||||
|
||||
rlBegin(RL_LINES);
|
||||
if (showCapLines)
|
||||
@@ -1704,6 +1714,9 @@ void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startA
|
||||
endAngle = tmp;
|
||||
}
|
||||
|
||||
// Drawing a whole circle, things get weird without limiting the circle to 360 degrees
|
||||
if (endAngle - startAngle >= 360.0f) endAngle = startAngle + 360.0f;
|
||||
|
||||
int minSegments = (int)ceilf((endAngle - startAngle)/90);
|
||||
|
||||
if (segments < minSegments)
|
||||
@@ -1795,6 +1808,14 @@ void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float s
|
||||
endAngle = tmp;
|
||||
}
|
||||
|
||||
bool showCapLines = true;
|
||||
// Drawing a whole circle, things get weird without limiting the circle to 360 degrees
|
||||
if (endAngle - startAngle >= 360.0f)
|
||||
{
|
||||
showCapLines = false;
|
||||
endAngle = startAngle + 360.0f;
|
||||
}
|
||||
|
||||
int minSegments = (int)ceilf((endAngle - startAngle)/90);
|
||||
|
||||
if (segments < minSegments)
|
||||
@@ -1814,7 +1835,6 @@ void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float s
|
||||
|
||||
float stepLength = (endAngle - startAngle)/(float)segments;
|
||||
float angle = startAngle;
|
||||
bool showCapLines = true;
|
||||
|
||||
rlBegin(RL_LINES);
|
||||
if (showCapLines)
|
||||
|
||||
Reference in New Issue
Block a user