〰️ Peano Space-Filling Curve

A continuous curve that, as its recursion order grows, weaves through every cell of the unit square. Discovered by Giuseppe Peano in 1890, it was the first proof that a one-dimensional curve can fill a two-dimensional area.

About this simulation

Written by MySimulator Team · Reviewed by MySimulator Editorial Review

Last updated: 11 July 2026

This tool draws the Peano curve, the first space-filling curve ever discovered, published by Giuseppe Peano in 1890. At each recursion step the unit square is split into a 3×3 grid of sub-squares, and the curve threads through all nine of them in a continuous back-and-forth boustrophedon path — column by column, alternating bottom-to-top and top-to-bottom — with every sub-copy individually reflected so the whole line never breaks or crosses itself. As the order increases the curve's points get closer and closer to every location in the square, illustrating how a purely one-dimensional object can, in the limit, fill a two-dimensional area.

🔬 What it shows

A recursive 3×3 subdivision of the unit square, traced by a single continuous path. At order n there are 9n visited cells arranged on a 3n×3n grid, and each of the nine sub-squares at every level is a mirrored or unmirrored copy of the same pattern, chosen so that consecutive cells are always edge-adjacent.

🎮 How to use

Set the recursion order n (1–5) and the draw speed, then watch the curve trace itself point by point. Toggle the grid overlay to see the underlying 3n×3n subdivision, and switch the colour mode to shade the path by progress instead of a single accent colour. Redraw replays the animation; Reset restores the default settings.

💡 Did you know?

Peano's 1890 paper gave purely arithmetic formulas with no illustrations at all — the now-familiar zig-zag pictures of his curve were added by later mathematicians, including Hilbert, who devised his own simpler 2×2 variant just a year later.

Frequently asked questions

What is a space-filling curve?

A space-filling curve is a continuous curve whose image, as its construction is repeated infinitely, covers every point of a region such as a square. Despite being the continuous image of a one-dimensional interval, it fills a genuinely two-dimensional area — a result that seemed paradoxical when Giuseppe Peano first proved it in 1890.

How does the 3×3 boustrophedon construction work?

The unit square is divided into nine equal sub-squares arranged in three columns. The curve visits the columns left to right, and within each column it sweeps top-to-bottom or bottom-to-top depending on the column's position, always ending each column exactly where the next one begins. Each sub-square then recursively contains a smaller, individually mirrored copy of this same pattern, keeping the whole path continuous and non-self-crossing at every level.

Why is the recursion order capped at 5?

Each extra order multiplies the number of points by 9, so order 5 already produces 95 = 59,049 points on a 243×243 grid — enough to visually fill the square many times over. Higher orders would add rendering cost without showing anything new to the eye, since the curve is already indistinguishable from a solid fill at that density.

What is the difference between the Peano curve and the Hilbert curve?

Both are space-filling curves built by recursive subdivision, but the Peano curve subdivides each square into a 3×3 grid of nine cells while the Hilbert curve, introduced by David Hilbert in 1891, subdivides into a 2×2 grid of four cells. Hilbert's version is more widely used today because its simpler four-way recursion produces a curve with even better locality-preserving properties for applications like spatial indexing.

Does the curve ever actually touch every point in the square?

Only in the mathematical limit of infinitely many subdivisions. At any finite order n, the simulation draws a finite set of 9n sample points connected by straight segments, which approximates the true curve. As n grows without bound, every point of the square becomes arbitrarily close to some point on the curve, which is exactly what makes it “space-filling.”