Bresenham's Circle Algorithm
Bresenham's Circle Algorithm
Bresenham's Circle Algorithm
xi=0;
yi=rad;
di=2*(1-rad);
limit=0;
while(yi>=limit)
{
/*Putpixel function to generate the circle in all quadrents */
putpixel(xc+xi,yc+yi,RED);
putpixel(xc+xi,yc-yi,RED);
putpixel(xc-xi,yc+yi,RED);
putpixel(xc-xi,yc-yi,RED);
delay(50);
if(di<0)
{
d=(2*di)+(2*yi)-1;
if(d<0)
mh();
else
md();
}
else if(di>0)
{
d1=(2*di)-(2*xi)-1;
if(d1<=0)
md();
else
mv();
}
else if(di==0)
md();
}
circle(xc,yc,rad);
getch();
closegraph();
Output: