Implementation of Midpoint Circle
Algorithm
voidcircleMidpoint (int xCenter,
int yCenter, int radius)
{
int x = 0; int y = radius;
int p = 1 - radius;
voidcirclePlotPoints (int, int,
int, int); /* Plot first set of points */
irclePlotPoints (xCenter,
yCenter, x, y);
while (x < y)
{
x++ ;
if (p < 0) p +=2*x +1;
else
{
y--; p +=2* (x - Y) + 1;
}
circlePlotPoints(xCenter,
yCenter, x, y)
}
}
voidcirclePlotPolnts (int
xCenter, int yCenter, int x, int y)
{
setpixel (xCenter + x, yCenter +
y ) ;
setpixel (xCenter - x. yCenter +
y);
setpixel (xCenter + x, yCenter -
y);
setpixel (xCenter - x, yCenter -
y ) ;
setpixel (xCenter + y, yCenter +
x);
setpixel (xCenter - y , yCenter +
x);
setpixel (xCenter t y , yCenter -
x);
setpixel (xCenter - y , yCenter -
x);
}
No comments:
Post a Comment