Skip to content
Math Background Studioby GordonKit
Open Studio

Apollonian gasket

Circles packed into every gap between tangent circles, forever — an Apollonian gasket (a fractal of dimension ≈ 1.31) tiled across the canvas.

Open Apollonian gasket in Studio

Apollonian gasket background example

Draw three circles that all touch each other, and a curved triangle of empty space is left between them. Fit a circle into that gap that touches all three, and three smaller gaps appear. Fill those, and keep going forever, until circles cover nearly everything.

How the maths works

22336666−1
A big circle holds two circles half its size, then two circles a third its size. The numbers are curvatures k = 1 / r (the big circle touches from the inside, so its curvature is negative): −1, 2, 2 and 3 satisfy Descartes’ circle theorem.
Formula
Curvature: the smaller the circle, the larger the curvature
k = 1 / r
Descartes’ circle theorem: the fourth circle from three tangent ones
k₄ = k₁ + k₂ + k₃ ± 2√(k₁k₂ + k₂k₃ + k₃k₁)
Fractal dimension of what remains
D ≈ 1.3057

Curvature k = 1 / r is the easiest way to describe size: smaller circles have larger curvature. Any four mutually tangent circles satisfy Descartes’ circle theorem, so knowing three of them gives the fourth directly.

If the first curvatures are whole numbers, every curvature in the gasket is a whole number too, such as −1, 2, 2, 3, 6, 11, 14, 15… Number theorists still study these integer Apollonian gaskets today.

However many circles you add, gaps always remain. What is left is a fractal of dimension about 1.3057: more than a line (1), less than a filled area (2).

Parameters

Tiles per short edge
How many gaskets across the short side; one gasket repeats to fill the canvas.
1 to 8
Depth
How many rounds of filling: each round puts a new circle into every gap left by the last. It stops by itself once circles are too small to see.
1 to 9
Gap
How much each circle shrinks toward its own centre, leaving a thin gap between touching circles. 0 makes them touch.
0 to 0.3
Style
Filled paints each circle solid; Ring draws only its outline.
Filled · Rings
Colouring
By size gives circles of similar size the same colour; By depth colours by the round they were added in; By tile gives each gasket its own hue.
By size · By depth · By tile

Examples

Each example opens in the studio with these settings.

Using it as a background

A depth of 4 to 5 with a small gap makes a calm slide texture; full depth with no gap becomes a fine, bubbly texture.

Rings on a dark background look like soap bubbles or cells under a microscope. When colouring by size, choose a palette that runs clearly from dark to light.