Ford Circles

Each Ford circle is associated with an irreducible fraction p / q, and is tangent to the horizontal axis and its neighbouring circles.

For performance, the underlying Farey sequence is pre-emptively pruned as it is being expanded, such that only the circles that overlap with the x-domain of the viewport are generated.

See also: the Calkin–Wilf tree and the Apollonian gasket.