Parul Institute of Engineering & Technology Sub : Computer Graphics 090370116031 Practical No : 06

Aim :- Write a C program to implement Flood-Fill algorithm. #include<stdio.h> #include<conio.h> #include<graphics.h> #include<dos.h> void flood_fill(int x,int y,int fill,int old); void main() { int gdriver=DETECT,gmode,errorcode; clrscr(); initgraph(&gdriver,&gmode,"C:\\TC\\BGI"); setcolor(5); circle(getmaxx()/2,getmaxy()/2,30); flood_fill(getmaxx()/2,getmaxy()/2+30,4,5); getch(); } void flood_fill(int x,int y,int fill,int old) { if(getpixel(x,y)==old) { delay(35); putpixel(x,y,fill); flood_fill(x+1,y,fill,old); flood_fill(x+1,y+1,fill,old); flood_fill(x+1,y-1,fill,old); flood_fill(x-1,y,fill,old); flood_fill(x-1,y+1,fill,old); flood_fill(x-1,y-1,fill,old); flood_fill(x,y+1,fill,old); flood_fill(x,y-1,fill,old); } }

Enroll no : Date :

PIET (IT)

12

Parul Institute of Engineering & Technology Sub : Computer Graphics 090370116031 Enroll no : Date : Output: PIET (IT) 13 .