#include #include #include #include void bfill(int x,int y,int f_col,int b_col) { int xmove=x,ymove=y; while(getpixel(xmove,ymove)!=b_col) { //filling upwards while(getpixel(xmove,ymove)!=b_col) while(getpixel(xmove,ymov e)!=b_col) { putpixel(xmove,ymove,f_col); ymove--; } ymove=y; //filling downwards while(getpixel(xmove,ymove)!=b_col) { putpixel(xmove,ymove,f_col); ymove++; } ymove=y; xmove--; } xmove=x; while(getpixel(xmove,ymove)!=b_col) { //filling upwards while(getpixel(xmove,ymove)!=b_col) while(getpixel(xmove,ymov e)!=b_col) { putpixel(xmove,ymove,f_col); ymove--; } ymove=y; //filling downwards while(getpixel(xmove,ymove)!=b_col) { putpixel(xmove,ymove,f_col); ymove++; } ymove=y; xmove++; } } void main()
{ int xc,yc,r; int gdriver = DETECT,gmode; initgraph(&gdriver,&gmode,"C:\\TC\\BGI"); initgraph(&gdriver,&gmode ,"C:\\TC\\BGI"); printf("Enter co-ordinates of the centre: "); scanf("%d%d",&xc,&yc); printf("Enter radius of circle: "); scanf("%d",&r); printf("Press any key to fill circle"); getch(); cleardevice(); circle(xc,yc,r); bfill(xc,yc,RED,WHITE); getch(); }