Skip to content

Commit 4f7d090

Browse files
committed
ADDED: DrawEllipse() and DrawEllipseLines() #1047
1 parent 954f029 commit 4f7d090

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

src/raylib.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,8 @@ RLAPI void DrawCircleSectorLines(Vector2 center, float radius, int startAngle, i
10591059
RLAPI void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle
10601060
RLAPI void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version)
10611061
RLAPI void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline
1062+
RLAPI void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color); // Draw ellipse
1063+
RLAPI void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color); // Draw ellipse outline
10621064
RLAPI void DrawRing(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color); // Draw ring
10631065
RLAPI void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color); // Draw ring outline
10641066
RLAPI void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle

src/shapes.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,38 @@ void DrawCircleLines(int centerX, int centerY, float radius, Color color)
398398
rlVertex2f(centerX + sinf(DEG2RAD*i)*radius, centerY + cosf(DEG2RAD*i)*radius);
399399
rlVertex2f(centerX + sinf(DEG2RAD*(i + 10))*radius, centerY + cosf(DEG2RAD*(i + 10))*radius);
400400
}
401-
rlEnd();
401+
rlEnd();
402+
}
403+
404+
// Draw ellipse
405+
void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color)
406+
{
407+
if (rlCheckBufferLimit(3*36)) rlglDraw();
408+
409+
rlBegin(RL_TRIANGLES);
410+
for (int i = 0; i < 360; i += 10)
411+
{
412+
rlColor4ub(color.r, color.g, color.b, color.a);
413+
rlVertex2f(centerX, centerY);
414+
rlVertex2f(centerX + sinf(DEG2RAD*i)*radiusH, centerY + cosf(DEG2RAD*i)*radiusV);
415+
rlVertex2f(centerX + sinf(DEG2RAD*(i + 10))*radiusH, centerY + cosf(DEG2RAD*(i + 10))*radiusV);
416+
}
417+
rlEnd();
418+
}
419+
420+
// Draw ellipse outline
421+
void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color)
422+
{
423+
if (rlCheckBufferLimit(2*36)) rlglDraw();
424+
425+
rlBegin(RL_LINES);
426+
for (int i = 0; i < 360; i += 10)
427+
{
428+
rlColor4ub(color.r, color.g, color.b, color.a);
429+
rlVertex2f(centerX + sinf(DEG2RAD*i)*radiusH, centerY + cosf(DEG2RAD*i)*radiusV);
430+
rlVertex2f(centerX + sinf(DEG2RAD*(i + 10))*radiusH, centerY + cosf(DEG2RAD*(i + 10))*radiusV);
431+
}
432+
rlEnd();
402433
}
403434

404435
void DrawRing(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color)

0 commit comments

Comments
 (0)