Skip to content

Commit

Permalink
Merge pull request #819 from Asthegor/patch-1
Browse files Browse the repository at this point in the history
Update PrimitiveDrawing.cs
  • Loading branch information
Gandifil authored Apr 7, 2024
2 parents 68c0b3d + 5b858d4 commit bde79b8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/cs/MonoGame.Extended/VectorDraw/PrimitiveDrawing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,31 @@ public void DrawSolidCircle(Vector2 center, float radius, Color color)

DrawCircle(center, radius, color);
}
public void DrawSolidCircle(Vector2 center, float radius, Color color, Color fillcolor)
{
if (!_primitiveBatch.IsReady())
throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");

const double increment = Math.PI * 2.0 / CircleSegments;
double theta = 0.0;

Vector2 v0 = center + radius * new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta));
theta += increment;

for (int i = 1; i < CircleSegments - 1; i++)
{
Vector2 v1 = center + radius * new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta));
Vector2 v2 = center + radius * new Vector2((float)Math.Cos(theta + increment), (float)Math.Sin(theta + increment));

_primitiveBatch.AddVertex(v0, fillcolor, PrimitiveType.TriangleList);
_primitiveBatch.AddVertex(v1, fillcolor, PrimitiveType.TriangleList);
_primitiveBatch.AddVertex(v2, fillcolor, PrimitiveType.TriangleList);

theta += increment;
}

DrawCircle(center, radius, color);
}

public void DrawSegment(Vector2 start, Vector2 end, Color color)
{
Expand Down

0 comments on commit bde79b8

Please sign in to comment.