Apollonian Gasket
Explore complete stages of tangent-circle packing and export the generated image.
About this tool
The fixed seed has one enclosing unit circle and three equal tangent circles inside it. Depth 0 shows these four circles. Each next depth fills every remaining triangular gap once. The circle count, including the enclosing circle, is 2 × 3depth + 2: depth 1 gives 8 circles and depth 7 gives 4376.
Descartes reflections use signed curvature k: positive for the inner circles and −1 for the enclosing circle. For a known tangent quadruple, replacing one circle gives k′ = 2(k₁ + k₂ + k₃) − k. Apply the same reflection to kx and ky to find its center; its radius is 1/k′. Each new circle is tangent to the other three. The algorithm visits complete levels and skips only the immediate inverse reflection.
See Lagarias, Mallows and Wilks (2001), equations (2.1) and (2.4) on PDF pages 3 and 6; pages 1–2 explain signed orientation. The calculation uses floating-point arithmetic. All circles through the chosen depth are retained, including circles smaller than a screen pixel. Their radii are not enlarged for display.
Generate after editing the depth. The PNG contains the current packing at the displayed size and theme; resizing redraws the cached geometry. Only the last accepted depth is saved. Returning to the tool starts idle and requires Generate again.