|
| ||||||||||
| Tags: algorithm, c language, flood fill, function |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Flood-Fill function : C
|
|
#2
| ||||
| ||||
| Flood-Fill function
Hello, Flood fill can also be known as the seed fill. Flood Fill is an algorithm that can determines the area that is connected to a given node in a multi-dimensional array. Flood Fill can be used in the " bucket" fill tool of paint programs. In paint Flood Fill can be used to determine which parts of a bitmap to fill with color and in games like puzzle games such as Magic Drop, Puyo Puyo, Minesweeper, Lumines, Samegame and Magical Drop for determining which pieces are cleared. Flood-Fill can also be known as the Boundary Fill when it is applied on an image to fill a particular area that is bounded with color. |
|
#3
| ||||
| ||||
| Flood-Fill function : C
I think the Flood Fill is an algorithm. The Flood Fill algorithm can takes three parameters such as a start node, a target color, and a replacement color. The Flood Fill algorithm is looking for all the nodes in the an array which are connected to the start node by a path of the target color and changes them to the replacement color. Flood Fill algorithm can be structured in many ways but they all make use of a stack or queue data structure implicitly or explicitly. |
|
#4
| ||||
| ||||
| Flood-Fill function : C
I think you have to carefully see the following line of code of C Program that demonstrates the Implementation of Flood Fill Algorithm : #include<stdio.h> #include<conio.h> #include<dos.h> #include<graphics.h> void fill_right(p,q) int p , q ; { if(getpixel(p,q) == 0) { putpixel(p,q,RED); fill_right(++p,q); p = p - 1 ; fill_right(p,q-1); fill_right(p,q+1); } } void fill_left(p,q) int p , q ; { if(getpixel(p,q) == 0) { putpixel(p,q,RED); fill_left(--p,q); p = p + 1 ; fill_left(p,q-1); fill_left(p,q+1); } } void main() { int p , q ,b[10][10]; int ge, gn ,p,j; detectgraph(&ge,&gn); initgraph(&ge,&gn,"c:\\tc\\bgi"); printf(" \n\n\tEnter the no. of edges of polygon : "); scanf("%d",&p); printf("\n\n\tEnter the cordinates of polygon :\n\n\n "); for(j=0;j<p;j++) { printf("\tP%d Q%d : ",j,j); scanf("%d %d",&b[j][0],&b[j][1]); } b[p][0]=b[0][0]; b[p][1]=b[0][1]; printf("\n\n\tEnter the seed pt. : "); scanf("%d%d",&p,&q); cleardevice(); setcolor(WHITE); for(j=0;j<p;j++) { line(b[j][0],b[j][1],b[j+1][0],b[j+1][1]); } fill_right(p,q); fill_left(p-1,q); getch(); }
__________________ The FIFA Manager 2009 PC Game |
|
#5
| ||||
| ||||
| Flood-Fill function
I think one of the algorithm such implicitly stack-based i.e. recursive flood-fill implementation for a 2-D array as follows: Flood-fill (node, target-color, replacement-color): 1. If the color of node is not equal to target-color then return. 2. Set the color of node to replacement-color. 3. Perform Flood-fill (one step to the west of node, target-color, replacement-color). Perform Flood-fill (one step to the east of node, target-color, replacement-color). Perform Flood-fill (one step to the north of node, target-color, replacement-color). Perform Flood-fill (one step to the south of node, target-color, replacement-color). 4. Return.
__________________ Grand Theft Auto 4 PC Video Game |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Flood-Fill function : C" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Hypertransport Sync Flood Error with MSI 870-G45 motherboard | Prabhukumar | Motherboard Processor & RAM | 9 | 13-10-2011 05:01 PM |
| "Magic Fill import function" in Maxthon 3 | Dum | Technology & Internet | 5 | 04-07-2011 07:19 PM |
| IRC/BACKDOOR.FLOOD Trojan | zhallart | Windows Software | 4 | 18-12-2010 11:31 AM |
| IRC/Flood.gen.h Virus Problem | Adrina_g | Networking & Security | 5 | 11-01-2010 11:54 AM |
| Microsoft Readies Flood of Patches | Jackie | Web News & Trends | 0 | 13-10-2008 03:44 PM |