Bubbles in foam, pebbles on a beach, cells in a slice of tissue: circles readily fill space. This layer does it in two ways, greedily at random or by the strict geometry of the Apollonian gasket, where a new circle is fitted into every gap between three touching ones, forever.
How it works
With the “random” method the generator drops a point and inflates a circle until it touches its nearest neighbour, allowing for the “Gap”. “Max radius”, jittered a little per circle, caps the size; if there is no room even for “Min radius”, the point is rejected. Placed circles never move: early ones come out large, later ones fill the cracks. To avoid wasted attempts, the generator keeps a map of the places where a circle still fits. In tile mode distances wrap across the edges, so the packing is seamless.
The Apollonian gasket starts from a large circle holding three circles that all touch each other. For any four mutually tangent circles, Descartes' theorem links their curvatures k = 1/r, the enclosing circle's curvature being negative. It follows that the two circles touching the same triple have curvatures adding up to 2(k₁ + k₂ + k₃); the same holds for the products kz, with the centre z as a complex number, which places each new circle at once. The generator fills the gaps from the largest circles down until it reaches “Min radius” or the “Circles” limit.
A bit of history
Apollonius of Perga studied circles touching three given ones in the third century BC; his book Tangencies is lost. In 1643, in a letter to Princess Elisabeth of the Palatinate, Descartes related the radii of four touching circles. The theorem was rediscovered several times, and in 1936 the Nobel chemist Frederick Soddy put it into verse in Nature as The Kiss Precise. Jeffrey Lagarias, Colin Mallows and Allan Wilks published the complex version for the centres in 2002. The gasket is a fractal: what remains between the circles has a Hausdorff dimension of about 1.3057. And if the starting curvatures are whole numbers, say −1, 2, 2, 3, so are all the rest; number theorists still study such gaskets.
What to tweak
- “Method” set to “Apollonian gasket”, plenty of “Circles” and a small “Min radius”: the fractal goes as deep as the pixels allow.
- Bring “Min radius” and “Max radius” close together for an even foam; pull them apart for a range from boulders to sand.
- “Style” set to “rings” with 3–6 “Rings” gives targets or tree slices; “Colouring” set to “by size” follows the logarithm of the radius.
- Lay the packing in “rings” over a “Mesh gradient” layer with the “multiply” blend mode for soft shifting colour.