Draw Peano Fractal
Draw the Peano curve (1890) - first space-filling curve, 3×3 recursive subdivision, dim 2.0. Rainbow gradient option. Free, offline, client-side, instant, secure.
- Runs in your browser
- Nothing uploaded
- Free, no sign-up
Renders the Peano curve (Giuseppe Peano, 1890) - the first published space-filling curve, built by recursive 3×3 subdivision via L-system with 90° turns. Fractal dimension 2.0 in the limit.
How to Use Draw Peano Fractal
- Pick iterations (1-5). Each level produces
9ⁿ − 1F-segments (not9ⁿ- see the FAQ for why). Iter 3 = 728 segments; iter 5 = 59,048. - Set canvas size (300-1200 px). Larger helps at iter 4+ where the 81×81 or 243×243 grid gets dense.
- Choose line and background colors. A YIQ luminance check warns if they are too close to see.
- Adjust line width (1-10 px). Use 1 px at iter 5 to keep the curve readable.
- Optionally enable the grid overlay - draws the 3ⁿ × 3ⁿ subdivision lines below the curve so you can see how Peano partitions the square at each level.
- Optionally enable the rainbow gradient - hues progress 0° → 360° along the curve so you can trace the start-to-end traversal.
- Click Draw Fractal or press Ctrl/Cmd + Enter. At iter ≥ 4 a non-blocking toast warns of the render time; no modal interrupts you.
- Copy or download the PNG. Copy uses the clipboard API (with execCommand fallback); download saves
peano-curve-iter-N.png.
Frequently Asked Questions
What is the Peano curve?
The Peano curve is a continuous mapping from the unit interval onto the unit square – its image fills the square completely. It was published by the Italian mathematician Giuseppe Peano in 1890 in the paper “Sur une courbe, qui remplit toute une aire plane” (Mathematische Annalen, vol. 36). It was the first such “space-filling curve” ever constructed and overturned the prevailing belief that a continuous curve must remain one-dimensional. Hilbert’s better-known curve appeared the following year (1891) as a simpler 2×2 variant of the same idea.
Why does the tool report 9ⁿ − 1 segments, not 9ⁿ?
The L-system used here is the standard one: axiom L, rule L → LFRFL-F-RFLFR+F+LFRFL, rule R → RFLFR+F+LFRFL-F-RFLFR. L and R are non-drawing recursion tokens; only F draws a segment. Each rule contains exactly 8 F characters and 9 L/R children. Solving the recurrence: F-count after n iterations is 8 · (9ⁿ − 1)/(9 − 1) = 9ⁿ − 1. So iter 1 has 8 segments (not 9), iter 2 has 80, iter 3 has 728, iter 4 has 6,560, iter 5 has 59,048. An earlier version of this FAQ claimed 9ⁿ – that was wrong; the displayed stats have always shown the true count.
What is the fractal dimension?
The Peano curve is genuinely space-filling, so its similarity dimension is exactly log(9) over log(3) = 2.0. At each iteration the pattern is replaced by 9 copies scaled by 1/3, so dim = log(N) / log(1/r) = log(9) / log(3) = 2. The displayed value is this limit; at any finite iteration the rendered polyline is still 1-dimensional in the strict sense.
How is Peano different from Hilbert?
Both are space-filling, both have dimension 2.0, both came out of late-19th-century work on the continuity of dimension. Peano (1890) uses a 3×3 subdivision with 90° turns and visits 9 sub-cells per iteration. Hilbert (1891) uses a 2×2 subdivision with 90° turns and visits 4 sub-cells. Hilbert’s curve has better locality preservation (consecutive index points stay close in 2D), which is why modern spatial indexes prefer it; Peano’s curve is the historical first.
Does the curve actually never cross itself?
The continuous limit curve is non-self-crossing – the L-system rules are designed so adjacent 3×3 sub-cells meet at shared boundary points but the path never doubles back. At any finite iteration the rendered polyline may share endpoints between adjacent unit segments (that is the L-system’s job), but it does not loop back through previously visited interior points. Peano explicitly proved the non-self-intersection property in his 1890 paper.
What does the rainbow gradient show?
Each F-segment is drawn with an HSL color whose hue is set by the segment’s position along the curve. The first segment is red (hue 0°), the last segment is purple (hue ~330°), and the spectrum in between traces the traversal order. This makes it visually clear which sub-cell is visited first, which is visited next, and so on – useful for understanding how Peano’s traversal order differs from Hilbert’s or Moore’s.
What does the 3ⁿ × 3ⁿ grid overlay show?
The overlay draws the cell boundaries at the current iteration depth: an 9×9 grid at iter 2, a 27×27 grid at iter 3, etc. The Peano curve enters each cell, traverses its interior recursively, and exits at a specific boundary point. The grid helps you see exactly which cells are being filled and in what order.
Is anything sent to a server?
No. The page loads three static files (HTML, CSS, JS), then everything – L-system expansion, drawing, PNG export, clipboard copy – runs in your browser. You can disconnect from the internet after the page loads and the tool keeps working. No analytics, no telemetry, no cookies.
Is this tool free?
Yes – free, unlimited, no signup, no watermark. Use the PNGs in lectures, papers, blog posts, or art freely. Attribution to is appreciated but not required.
Related Tools
Draw Canopy Fractal →
Draw a canopy-tree L-system fractal in your browser. 7 iterations, custom colors, gradient depth,…
Draw Cantor Dust Fractal →
Draw true Cantor Dust (4-corner) or Sierpiński carpet (8-square) in your browser. Color modes,…
Draw Cantor Fractal →
Draw the Cantor set with middle-third deletion. 0-10 iterations, custom colors, dimension and measure…
Draw Flowsnake Fractal →
Draw the Gosper curve hexagonal space-filling fractal in your browser. Iterations 1-6, custom colors,…
Draw Frosty Fractal →
Draw Frosty Fractal online, free and private. Runs in your browser, no upload, instant…
Draw Hausdorff Fractal →
Draw the Hilbert curve or Moore curve (closed-loop variant) - true space-filling fractals (dim…
Draw Heighway Fractal →
Draw the Heighway dragon (paper-folding fractal) with fire gradient and symmetry modes. L-system based.…
Draw Hexaflake Fractal →
Draw the hexaflake (hexagon snowflake) - 7-hexagon recursive fractal with 6-fold symmetry. Custom colors,…
Draw Hilbert Fractal →
Draw the Hilbert space-filling curve in your browser. 9 iterations, rotation, gradient, endpoints. Free,…
Draw Koch Fractal →
Draw Koch curve, snowflake, or anti-snowflake at any angle. Iterations 0-7. Free, offline, client-side,…
Draw Levy Fractal →
Draw the Lévy C-curve (Paul Lévy 1938) - space-filling fractal at 45°. Gradient and…
Draw Mcworter Dendrite Fractal →
Draw Mcworter Dendrite Fractal online, free and private. Runs in your browser, no upload,…