today's problem involves the flood fill algorythm. What i want to do is make a drawing application in flash that's similar to paint, in the sense that it lets you draw lines with colors you choose from a color picker, it lets you erase parts of what you've drawn using the eraser (it really paints with white over) and , it lets you fill shapes you've made with color.
Well, the last part is what i need help on. I've written a version of the flood fill algorythm in pseudocode and i wanted it to be reviewed by you guys before i went in and started coding that might be fundamentally flawed.
we have 2 colors, the color of the selected pixel and the color we've selected in the color picker.
I want to make a function FLOOD which takes the X and Y position of the mouse and the color picker color as variables.
step1. save the selected pixel's color value in a variable named original color.
step2. color the selected pixel in the color picker color
step3.
a) if (color of (mouse.x-1,mouse.y)==original color), then flood(mouse.x-1,mouse.y,color picker color)
b) if (color of (mouse.x+1,mouse.y)==original color), then flood(mouse.x+1,mouse.y,color picker color)
c) if (color of (mouse.x,mouse.y-1)==original color), then flood(mouse.x,mouse.y-1,color picker color)
d) if (color of (mouse.x,mouse.y+1)==original color), then flood(mouse.x,mouse.y,color picker color+1)
step4. DONE