Write a program to fill a circle using boundary fill algorithm


#include<stdio.h>
#include<conio.h>
#include<graphics.h>

void boundryFill(int, int, int, int);
int midx=319, midy=239;

void main()
{
  int gdriver=DETECT, gmode, x,y,r;
  initgraph(&gdriver, &gmode, "c:\\tc\\bgi");

  cleardevice();

  printf("Enter the Center of circle (X,Y) : ");
  scanf("%d %d",&x,&y);
  printf("Enter the Radius of circle R : ");
  scanf("%d",&r);

  circle(midx+x,midy-y,r);
  getch();
  boundryFill(midx+x,midy-y,13,15);

  getch();
  closegraph();
}

void boundryFill(int x, int y, int fill, int boundry)
{
  if( (getpixel(x,y) != fill) && (getpixel(x,y) != boundry) )
  {
      putpixel(x,y,fill);
      delay(5);
      boundryFill(x+1,y,fill,boundry);
      boundryFill(x-1,y,fill,boundry);
      boundryFill(x,y+1,fill,boundry);
      boundryFill(x,y-1,fill,boundry);
  }
}

Related Posts Plugin for WordPress, Blogger...

Engineering material

GTU IDP/ UDP PROJECT

GTU IDP/ UDP PROJECT

Patel free software download

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP