2008-08-26, 05:07 PM
Stereo Wrote:Pseudocode for a contiguous fill is not too complex, especially with a 2-color GIF like this where all color matches are exact. Recursively ...
edit: oops[/color]Code:fill(x,y,newcolor) {
oldcolor=color(x,y);
color(x,y) = newcolor;
for (int i = 0; i<4;i++) {
if ( color(x+cos(pi/2*i),y+sin(pi/2*i)) == oldcolor ) {
fill(x+cos(pi/2*i),y+sin(pi/2*i),newcolor);
}
}
}
}
I rather meant an A* Algorithm.
Spoiler
Finding the shortest way to the end. (As is in this case the only way).


![[Image: a-star-trap.png]](http://theory.stanford.edu/~amitp/game-programming/a-star/a-star-trap.png)