A spanning tree of the canvas is generated using Wilson’s algorithm and then flooded with color. Hue encodes Manhattan distance from the root of the tree. (This is not an optimal visual encoding, but it suffices and is pretty.)
Spanning trees can also be used to generate mazes. See a maze generated with Wilson’s algorithm flooded with color, and compare color floods of spanning trees generated with Wilson’s algorithm to random traversal, randomized depth-first traversal and Prim’s algorithm.
@Ryfteh It uses https://github.com/d3/d3-timer, which is fixed to the framerate of requestAnimationFrame (typicaly 60 frames per sec). The code itself only walks three layers per frame.
If you want it to go faster, just change
i < 3
to something likei < 100
and you'll see it finishes very quickly.You could try swapping out
d3.hsl((distance += .5) % 360, 1, .5)
withd3.hcl((distance += .5) % 360, 40, 74)
.