# Code Snippets #19 - FillCircle

Published 7/30/2013 by createdbyx in Code Snippets | Programming
Tags: ,

```/// <summary>
/// Fills a circle.
/// </summary>
/// <param name="image">
/// The destination image.
/// </param>
/// <param name="centerX">
/// The x center position of the circle.
/// </param>
/// <param name="centerY">
/// The y center position of the circle.
/// </param>
/// <param name="radius">
/// The radius of the circle.
/// </param>
/// <param name="color">
/// The color to use.
/// </param>
public static void FillCircle<T>(this GenericImage<T> image, int centerX, int centerY, int radius, T color)
{
// source -> http://www.dailyfreecode.com/code/fill-circle-scan-line-circle-fill-675.aspx
int x1;
int x2;

var counter = (centerY + radius);

for (var count = (centerY - radius); count <= counter; count++)
{
x1 = (int)(centerX + Math.Sqrt((radius * radius) - ((count - centerY) * (count - centerY))) + 0.5);
x2 = (int)(centerX - Math.Sqrt((radius * radius) - ((count - centerY) * (count - centerY))) + 0.5);

image.DrawLine(x1, count, x2, count, color);
}
}```

Add comment

• Comment
• Preview

# Created by: X

## Just another personal website in this crazy online world

 Dean Lunz (aka Created by: X) Computer programming nerd, and tech geek. About Me -- Resume