Open DoogeJ opened 4 years ago
I added this, adapted from http://fredericgoset.ovh/mathematiques/courbes/en/filled_circle.html. That author goes to further steps to increase efficiency, so it's probably worth taking a look at. Of course it's still a separate method, not combined.
public static void FillCircle(this SpriteBatch spriteBatch, Vector2 center, float radius, Color color)
{
float x = 0;
float y = radius;
float m = 5 - 4 * radius;
while (x <= y) {
DrawLine(spriteBatch, center.X - x, center.Y - y, center.X + x, center.Y - y, color);
DrawLine(spriteBatch, center.X - y, center.Y - x, center.X + y, center.Y - x, color);
DrawLine(spriteBatch, center.X - y, center.Y + x, center.X + y, center.Y + x, color);
DrawLine(spriteBatch, center.X - x, center.Y + y, center.X + x, center.Y + y, color);
if (m > 0) {
y--;
m -= 8 * y;
}
x++;
m += 8 * x + 4;
}
}
DrawCircle has no way of filling circles.
This should be implemented in the same way as #3