summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2020-01-27 16:21:37 +0100
committerRay <[email protected]>2020-01-27 16:21:37 +0100
commit4f7d090fb2f639a9b68378e7250fc159a43acd8d (patch)
tree8609508a8abbcbbfbf11bb416484505cb12904c0
parent954f029118260dce867c1bf6ff3948ca6a6bee85 (diff)
downloadraylib-4f7d090fb2f639a9b68378e7250fc159a43acd8d.tar.gz
raylib-4f7d090fb2f639a9b68378e7250fc159a43acd8d.zip
ADDED: DrawEllipse() and DrawEllipseLines() #1047
-rw-r--r--src/raylib.h2
-rw-r--r--src/shapes.c33
2 files changed, 34 insertions, 1 deletions
diff --git a/src/raylib.h b/src/raylib.h
index 2b5ff3e5..97e37057 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -1059,6 +1059,8 @@ RLAPI void DrawCircleSectorLines(Vector2 center, float radius, int startAngle, i
RLAPI void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle
RLAPI void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version)
RLAPI void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline
+RLAPI void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color); // Draw ellipse
+RLAPI void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color); // Draw ellipse outline
RLAPI void DrawRing(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color); // Draw ring
RLAPI void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color); // Draw ring outline
RLAPI void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle
diff --git a/src/shapes.c b/src/shapes.c
index 43037562..ff9e6c1a 100644
--- a/src/shapes.c
+++ b/src/shapes.c
@@ -398,7 +398,38 @@ void DrawCircleLines(int centerX, int centerY, float radius, Color color)
rlVertex2f(centerX + sinf(DEG2RAD*i)*radius, centerY + cosf(DEG2RAD*i)*radius);
rlVertex2f(centerX + sinf(DEG2RAD*(i + 10))*radius, centerY + cosf(DEG2RAD*(i + 10))*radius);
}
- rlEnd();
+ rlEnd();
+}
+
+// Draw ellipse
+void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color)
+{
+ if (rlCheckBufferLimit(3*36)) rlglDraw();
+
+ rlBegin(RL_TRIANGLES);
+ for (int i = 0; i < 360; i += 10)
+ {
+ rlColor4ub(color.r, color.g, color.b, color.a);
+ rlVertex2f(centerX, centerY);
+ rlVertex2f(centerX + sinf(DEG2RAD*i)*radiusH, centerY + cosf(DEG2RAD*i)*radiusV);
+ rlVertex2f(centerX + sinf(DEG2RAD*(i + 10))*radiusH, centerY + cosf(DEG2RAD*(i + 10))*radiusV);
+ }
+ rlEnd();
+}
+
+// Draw ellipse outline
+void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color)
+{
+ if (rlCheckBufferLimit(2*36)) rlglDraw();
+
+ rlBegin(RL_LINES);
+ for (int i = 0; i < 360; i += 10)
+ {
+ rlColor4ub(color.r, color.g, color.b, color.a);
+ rlVertex2f(centerX + sinf(DEG2RAD*i)*radiusH, centerY + cosf(DEG2RAD*i)*radiusV);
+ rlVertex2f(centerX + sinf(DEG2RAD*(i + 10))*radiusH, centerY + cosf(DEG2RAD*(i + 10))*radiusV);
+ }
+ rlEnd();
}
void DrawRing(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color)