08 - Fog of war

The ring marks the viewer and follows the pointer. Drag it around the map: what has been seen stays seen.

cast(originX, originY, directionX, directionY, maxDistance, options)
Finds where each ray of the fan stops.

each(originX, originY, directionX, directionY, maxDistance, callback, options)
Walks that same ray again, only as far as it got, and reports every cell it crossed.
It is the only query that reports empty cells, which is what a fog needs: every other one answers with obstacles, so a fog built on them would reveal the walls and leave the floor between them dark.

This is also the only example that remembers. The others recompute everything on every frame; a fog is a set that only grows, which is why a cell can be in three states rather than two.