Remix.run Logo
▲ zimpenfish 8 hours ago

Huh, that's useful because I had to write a floodfill a couple of days ago and it was a pain in the arse.

I'll be converting my code to the stackless version toot sweet.

▲brcmthrowaway 8 hours ago | parent [-]

Why were you needing floodfill?

▲zimpenfish 7 hours ago | parent | next [-]

To find connected regions on a map. I could probably have been smarter about the initial generation and connected things as they were generated (but that has only just occurred to me. Worth a go, I suppose.)

▲kragen 4 hours ago | parent [-]

Use union-find to find connected regions on a map, not flood-fill.

▲zimpenfish an hour ago | parent [-]

I assume you mean "connected-component labeling" with union-find as the underlying "manage the sets" algorithm? If not, a link would be helpful.

▲cyberax 2 hours ago | parent | prev [-]

I also wrote a floodfill a while ago! We have a mapping app, and our imagery provider returns half-filled tiles at the edge of their coverage. And annoyingly, they don't have any metadata within the tile itself that indicates the coverage. They just return black pixels for a part of the tile.

So I needed a way to detect that, and doing a floodfill from the edge of the image turned out to be the easiest way.