I'm very new to iPhone development. I want to create a application using FloodFill algorithm in iPhone. I'm have no idea about FloodFill. Please Explain me the purpose of FloodFill algorithm.If you give a sample application for FloodFill(iPhone)means I'm really, really happy..Because I'm exploring about FloodFill since morning but, nothing I'm found.
My task is, I want to fill the image with color as part by part. Which means, if I'm choosing one color and click on the particular area of the image means it gets colored with the selected color.
Please help me to do this.
Edit: I am not able to write a code for floodfill algorithm implementation for iPhone.
It's a recursive algorithm, meaning that it calls itself to accomplish smaller parts of the whole process.
Flood fill will start at one pixel. Then it will check the four adjacent pixels (up, down, left, right). For any of those four pixels that are the same colour as the one we started with, it will call another flood fill starting from that pixel.
Imagine a small picture where . is one colour, and X is another colour. The numbers are just there for reference, so 7,0 is the top right. (Ignore the red / black syntax hilighting!)
Now imagine you start a flood fill at 3,3. It will change 3,3 to the new colour. It will then check up,down,left,right. For up (3,2), the colour there is the same (a dot), so it will start another flood fill from there. For down (3,4), the colour is different, so this branch will stop. Left, (2,3), and right (4,3) are also the same (a dot), so more branches of flood fill start from there.
Let's say that new colour is O, so we now have this:
The "up" branch started a new flood fill from (3,2). From here, up is X, so that stops. Right is X, so that stops, down is O, so that stops, but left (2,2) is the same (a dot), so it starts a new flood fill from there.
Similarly, the "right" branch from the original flood fill began from (4,3). The only branch it can use is down (4,4). Now we have this:
And so the flood fill continues from (4,4), by branching right and down. One of those two branches will then branch into (5,5). By that time, there will be no further possible branches.
And that is my lunchtime filled :)