My Profile

I, Das ShrikKrishna J. MCA III IMSCD&R, Ahmednagar.
Showing posts with label Circle using Bresenham's algorithm. Show all posts
Showing posts with label Circle using Bresenham's algorithm. Show all posts

Monday, 15 August 2011

Generation of circle using Bresenham's algorithm

/* Generation of circle using Bresenham's algorithm */
#include<stdio.h>
#include<graphics.h>
main()
{
int x,y,r,d,orgx,orgy,gd=DETECT,gm;
clrscr();
printf("\n Enter the radius of circle ");
scanf("%d",&r);
clrscr();
x=0;
y=r;
orgx=orgy=r;
d=1-r;
initgraph(&gd,&gm,"");
while(y>x)
{
if(d<0)
{
x++;
d=d+(2*x)+3;
}
else
{
x++;
y--;
d=d+(2*(x-y))+5;
}
putpixel(orgx+x,orgy+y,RED);
putpixel(orgx-x,orgy+y,RED);
putpixel(orgx+y,orgy+x,RED);
putpixel(orgx+x,orgy-y,RED);
putpixel(orgx-y,orgy+x,RED);
putpixel(orgx+y,orgy-x,RED);
putpixel(orgx-x,orgy-y,RED);
putpixel(orgx-y,orgy-x,RED);
}
getch();
return 0;
}

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | cheap international calls