Lamely Recursing #

YESSSSSS! I have recursion in program. Thanks to a tip from James, I've redone my fill function to use a recursive algorithm (instead of just calling the system function, SeedCFill). The actual algorithm is pretty simple, I start with the source pixel, and look and its neghbors, and at the neighbors' neighbors and so on. It's a classical example of recursion (I've found some class notes on it online, and its in the Computer Graphics: Principles and Practice book I have too). It's not the best solution (a scanline algorithm might work better, but it would be more complicated), but it's a legitimate use of recursion.

I had some problems with filling in selections, but it turned out that that was because my GetPixel/SetPixel functions assumed that the origin of the PixMap was at 0,0. However with selections, since they can be moved around, the origin varies. The fix was simple, all I had to do was to subtract from the passed x/y coordinates the coordinates of the origin.

Post a Comment