#include<stdio.h>#include<graphics.h>#include<conio.h>
main()
{  int gd=DETECT,gm,x=0,radius,xc,yc,y,p;
  void circleplotpoint(int,int,int,int);
  initgraph(&gd,&gm,"");
  setbkcolor(15);
  setcolor(BLUE);
   outtextxy(160,10,"BRESENHAM'S CIRCLE GENERATION ALGORITHM");
   printf("\n\nEnter The Values (xc,yc):");
   scanf("%d %d",&xc,&yc);
   printf("\n\nEnter The Radius :");
   scanf("%d",&radius);
   cleardevice();
   outtextxy(160,10,"BRESENHAM'S CIRCLE GENERATION ALGORITHM");
   y=radius;
   p=3-2*radius;
   while(x<y)   {
      x++;
      if(p<0) p+=4*x+6;
      else      {
            y--;
            p+=4*(x-y)+10;
      }      circleplotpoint(xc,yc,x,y);
      delay(200);    }
    getch();
    closegraph();
}
void circleplotpoint(int xc,int yc,int x,int y)
{  putpixel(xc+x,yc+y,3);
  putpixel(xc-x,yc+y,4);
  putpixel(xc+x,yc-y,5);
  putpixel(xc-x,yc-y,8);
  putpixel(xc+y,yc+x,3);
  putpixel(xc-y,yc+x,4);
  putpixel(xc+y,yc-x,5);
  putpixel(xc-y,yc-x,8);
}

Leave a Reply

Subscribe to Posts | Subscribe to Comments

All Notes on BCA

All Notes  on BCA
BCA all subjects notes

Total Pageviews

Translate

Powered by Blogger.

Copyright © All Notes on BCA