Curves

Gielis superformula

One equation by Johan Gielis draws circles, polygons, stars, flowers and shells — as nested outlines, a grid or a table of shapes.

  • vector geometry
  • seamless tile
  • looping animation
  • SVG export
Open in the editor →

A circle, a rounded square, a starfish, a clover leaf: can one equation describe them all? In 2003 Johan Gielis proposed a formula in polar coordinates with just six parameters that draws all of these and much more.

How it works

The starting point is Lamé's superellipse, |x|ⁿ + |y|ⁿ = 1. At n = 1 it is a diamond, at n = 2 a circle; as n grows it becomes a square with ever sharper corners, and below 1 a four-pointed star with concave sides. Gielis multiplied the angle by m/4, so the figure repeats m times per turn, gave the sine and cosine exponents of their own, and put a common exponent outside.

r(θ) = ( |cos(mθ/4) / a|^n₂ + |sin(mθ/4) / b|^n₃ )^(−1/n₁) m = 4, n₁ = n₂ = n₃ = n, a = b = 1 → |x|ⁿ + |y|ⁿ = 1

“Symmetry m” is the number of rays. “n₁ — pinch” works like a magnifying glass: a small n₁ blows any bump up into a spike, a large one smooths everything towards a circle. n₂ and n₃ bend the sides, each its own half: n₃ shapes the curve near one set of rays, n₂ near the other, so when n₂ ≠ n₃ neighbouring rays differ. “a : b” stretches the even rays against the odd ones. With n₂ = n₃ = 2 and a : b = 1 the terms add up to cos² + sin² = 1: a circle, whatever m and n₁.

The “nested outlines” mode shrinks the shape step by step, rounding and twisting it towards the centre as n₁ grows; “grid” lays shapes out in cells; “table of shapes” is a periodic table, with m growing along the rows, n₁ down the columns and side curvature along the diagonal.

A bit of history

The French mathematician Gabriel Lamé studied the curves |x/a|ⁿ + |y/b|ⁿ = 1 in 1818. In 1959 the Danish polymath Piet Hein proposed a superellipse with n = 2.5 for Sergels torg in Stockholm, a compromise between a circle and a rectangle that suited both the city grid and the traffic. Gielis published his generalisation in the American Journal of Botany and filed a patent application on generating patterns with it, which expired in 2020.

What to tweak

  • Start from a circle: with n₂ = n₃ = 2, n₁ does nothing. Take n₂ and n₃ below 2 and m rays appear; above 2, m bulging corners. Now n₁ decides whether they are sharp or soft.
  • “Symmetry m” at 5 with “n₁ — pinch” around 0.3 gives a starfish; m at 4 with all three exponents at 4, a rounded square.
  • Pull n₂ and n₃ apart, say 1 and 8: some rays sharpen while their neighbours turn blunt.
  • “Mode” set to “table of shapes” with “Variation” at 1 is a ready-made atlas of supershapes.
  • Put the “Dither” effect on top in “1-bit” mode for the look of an old computer magazine.

Parameters

Mode
nested outlines · grid · table of shapes
Symmetry m
Number of rays
n₁ — pinch
Lower makes sharper rays, higher a rounder shape
n₂ — side curve
n₃ — side curve
a : b
Stretches the even rays against the odd ones
Outlines
Nested outlines per shape
Cells
Shapes across the short side — for the grid and the table
Variation
How the outlines change towards the centre; cell turns in the grid; the range of change in the table
Style
outline · fill · fill and edge
Line width
Colouring
one colour · gradient · random
Rotation
Speed
Each loop the shape breathes in and out and turns by one step of its symmetry