C Language Program for Mid Point Circle Algorithm Implementation


#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>
int midx,midy,i,gdriver = DETECT, gmode,j,x,y,radius,p,xc,yc,x1,y1;
main()
{
initgraph(&gdriver, &gmode, "..//bgi");
setfillstyle(7,8);
bar(0,35,getmaxx(),getmaxy());
settextstyle( 2,0,7);
border();
setcolor(15);
gotoxy(60,14);
outtextxy(80,200,"ENTER THE VALUES OF X-CENTER ");
scanf("%d",&xc);
gotoxy(60,17);
outtextxy(80,250,"ENTER THE VALUES OF Y-CENTER ");
scanf("%d",&xc,&yc);
gotoxy(60,20);
outtextxy(80,300,"ENTER THE RADIUS OF THE CIRCLE ");
scanf("%d",&radius);
setcolor(BLUE);
for(i=0;i<70;i++)
{
setcolor(4);
settextstyle(1,0,3);
outtextxy(50+3*i,10,"MIDPOINT  CIRCLE ALGORITHM");
setcolor((rand()%10)+1);
circle(20+3*i,19,12);
circle(410+3*i,19,12);
delay(7);
setcolor(0);
settextstyle(1,0,3);
outtextxy(50+3*i,10,"MIDPOINT  CIRCLE ALGORITHM");
circle(20+3*i,19,12);
circle(410+3*i,19,12);
settextstyle(1,0,1);
setfillstyle(7,8);
bar(300,450,610,477);
setcolor(rand()%100);
outtextxy(250,410," ");
delay(1);
}
 setfillstyle(7,1);
  bar(0,0,getmaxx(),getmaxy());
  border();
  setcolor(WHITE);
  line(getmaxx()/2,0,getmaxx()/2,getmaxy());
  line(0,getmaxy()/2,getmaxx(),getmaxy()/2);
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(4);
x=0;
y=radius;
plotpoints();
p=1-radius;
while(x<y)
{
if(p<0)
{
x=x+1;
p=p+(2*x)+1;
}
else
{
x=x+1;
y=y-1;
p=p+2*(x-y)+1;
plotpoints();
}
}
getch();
closegraph();
return 0;
}
plotpoints()
{
putpixel(xc+x+midx,midy-yc+y,15);
putpixel(xc-x+midx,midy-yc+y,15);
putpixel(xc+x+midx,midy-yc-y,15);
putpixel(midx+xc-x,midy-yc-y,15);
putpixel(midx+xc+y,midy-yc+x,15);
putpixel(midx+xc-y,midy-yc+x,15);
putpixel(midx+xc+y,midy-yc-x,15);
putpixel(midx+xc-y,midy-yc-x,15);
}
border()
{
setcolor(5);
rectangle(0,0,getmaxx(),getmaxy());
rectangle(1,1,getmaxx()-1,getmaxy()-1);
rectangle(2,2,getmaxx()-2,getmaxx()-2);
}



Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com
Share:

Total Pageviews

CONTACT US

Prof. Roshan P. Helonde
Mobile: +917276355704
WhatsApp: +917276355704
Email: roshanphelonde@rediffmail.com

Enter Project Title

Popular Projects

All Archive

Contact Form

Name

Email *

Message *