summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2023-08-20 21:36:36 +0200
committerRay <[email protected]>2023-08-20 21:36:36 +0200
commit8189bddefbb91525386dfdd60e268cc33e956a1f (patch)
tree81eef7e81b799353eaf0f5ffed4fda616c2824e6 /src
parentf95dc2d565a119d19f8637e42f92782e3e165632 (diff)
downloadraylib-8189bddefbb91525386dfdd60e268cc33e956a1f.tar.gz
raylib-8189bddefbb91525386dfdd60e268cc33e956a1f.zip
tweaks
Diffstat (limited to 'src')
-rw-r--r--src/rshapes.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/rshapes.c b/src/rshapes.c
index ea45aefc..f3061f8b 100644
--- a/src/rshapes.c
+++ b/src/rshapes.c
@@ -498,6 +498,13 @@ void DrawCircle(int centerX, int centerY, float radius, Color color)
DrawCircleV((Vector2){ (float)centerX, (float)centerY }, radius, color);
}
+// Draw a color-filled circle (Vector version)
+// NOTE: On OpenGL 3.3 and ES2 we use QUADS to avoid drawing order issues
+void DrawCircleV(Vector2 center, float radius, Color color)
+{
+ DrawCircleSector(center, radius, 0, 360, 36, color);
+}
+
// Draw a piece of a circle
void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
{
@@ -530,6 +537,7 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
rlSetTexture(texShapes.id);
rlBegin(RL_QUADS);
+
// NOTE: Every QUAD actually represents two segments
for (int i = 0; i < segments/2; i++)
{
@@ -539,7 +547,7 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
rlVertex2f(center.x, center.y);
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
- rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength*2))*radius, center.y + sinf(DEG2RAD*(angle + stepLength*2))*radius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength*2.0f))*radius, center.y + sinf(DEG2RAD*(angle + stepLength*2.0f))*radius);
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*radius, center.y + sinf(DEG2RAD*(angle + stepLength))*radius);
@@ -547,11 +555,11 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
rlVertex2f(center.x + cosf(DEG2RAD*angle)*radius, center.y + sinf(DEG2RAD*angle)*radius);
- angle += (stepLength*2);
+ angle += (stepLength*2.0f);
}
// NOTE: In case number of segments is odd, we add one last piece to the cake
- if (segments%2)
+ if ((segments%2) == 1)
{
rlColor4ub(color.r, color.g, color.b, color.a);
@@ -567,6 +575,7 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
rlVertex2f(center.x, center.y);
}
+
rlEnd();
rlSetTexture(0);
@@ -659,13 +668,6 @@ void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Co
rlEnd();
}
-// Draw a color-filled circle (Vector version)
-// NOTE: On OpenGL 3.3 and ES2 we use QUADS to avoid drawing order issues
-void DrawCircleV(Vector2 center, float radius, Color color)
-{
- DrawCircleSector(center, radius, 0, 360, 36, color);
-}
-
// Draw circle outline
void DrawCircleLines(int centerX, int centerY, float radius, Color color)
{