Remix.run Logo
▲ taneq 7 hours ago

The pixels are effectively being turned into a linked list using the special values as ‘pointers’. This list is used as a stack, and the current position is the stack pointer.

I don’t think they explain the backtracking part very well, and they should have used an example that fills a non-rectangular area so it actually demonstrates the whole algorithm.

It’s a neat trick if you have spare values to use as markers, though. :)