Staaarter

Generate a Peano Curve

Generates the classic Peano curve, the first published space-filling curve, using its standard order-3 L-system construction, and renders it as SVG line art you can download. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-08-05
By Staaarter Team
fractalgeneratorsvgspace-filling-curve

Overview

Introduction

The Peano curve was the first space-filling curve ever published, a single continuous line that, in the limit, touches every point of a square. This tool renders its classic order-3 construction as SVG line art.

Enter an iteration count and the tool expands the standard Peano L-system rule that many iterations, then draws the resulting path so you can see how a simple back-and-forth replacement rule fills more and more of the square as it repeats.

What Is Generate a Peano Curve?

A real, named mathematical curve, first described by Giuseppe Peano in 1890 as a proof that a continuous curve can fill an entire two-dimensional area, contradicting the intuition that curves are one-dimensional.

This tool uses its standard base-3 L-system definition: a single forward segment expands into nine segments arranged in a boustrophedon (back-and-forth) sweep, applied recursively.

How Generate a Peano Curve Works

The generator starts from the axiom "F" and repeatedly applies the rule F becomes "F+F-F-F-F+F+F+F-F" for as many iterations as you enter, where + and - are 90-degree left and right turns.

That nine-segment replacement is the classic order-3 Peano construction, each straight segment turns into a sweep through a 3-by-3 sub-grid, alternating direction row by row so the resulting path never crosses itself.

The expanded instruction string is walked by a turtle to produce line segments, which are then rescaled to fit the SVG viewbox and drawn as one continuous path.

When To Use Generate a Peano Curve

Use it to see a real space-filling curve in action, for teaching continuity and dimension in a way that's easier to grasp visually than algebraically.

It's also useful as generative-art source material, the dense, evenly-spaced sweeping pattern makes distinctive geometric backgrounds and prints.

For a closed-loop space-filling curve instead of Peano's open one, use the Moore Curve Generator.

Features

Advantages

  • A well-documented, classic mathematical curve with a single, unambiguous construction, not an invented variant.
  • Fills its bounding square evenly at every iteration, producing a visually balanced pattern at any depth.
  • Downloadable as both SVG (for further vector editing) and PNG (for quick use anywhere).

Limitations

  • Segment count grows nine-fold per iteration, so the iteration range is capped at 4 to keep rendering and downloads responsive; higher orders exist mathematically but aren't offered here.
  • As a genuinely space-filling curve, high iteration counts produce very dense line art where individual segments become difficult to distinguish visually.

Examples

Zero iterations

Input

Iterations: 0

Output

A single straight line segment, the bare axiom before any Peano sweeping is applied.

At 0 iterations there's no replacement yet, just the starting segment.

Default iteration count

Input

Iterations: 3

Output

A dense, evenly-spaced sweeping pattern that visibly fills most of its square bounding area.

By order 3 the boustrophedon sweeping pattern that defines the Peano curve is clearly visible at multiple scales.

Best Practices & Notes

Best Practices

  • Start at order 1 or 2 to see the basic nine-segment sweep before jumping to order 3 or 4, where the recursive self-similarity becomes the dominant visual feature.
  • Download the SVG rather than the PNG if you plan to recolor, scale, or further edit the curve, vector output has no resolution limit.

Developer Notes

Implemented as the standard L-system preset ("peano-curve" in l-system-presets.ts): axiom "F", rule F: "F+F-F-F-F+F+F+F-F", 90-degree turn angle, capped at 4 iterations. Expansion and turtle interpretation both go through the shared generateLSystemCurve/drawLSystem engine used by every other L-system tool in this category, before geometry normalization and SVG rendering.

Generate a Peano Curve Use Cases

  • Teaching space-filling curves, continuity, and fractal dimension with a real, citable example
  • Generative art and print patterns built from a dense, evenly-swept geometric curve
  • Downloadable SVG line art for design projects referencing a classic mathematical fractal

Common Mistakes

  • Assuming higher iteration counts always look "better", past order 3 or 4 the sweep becomes so dense that the self-similar structure is hard to see without zooming into the downloaded SVG.
  • Confusing this with the Hilbert or Moore curves, all three are space-filling curves but each uses a different production rule and produces a visually distinct sweep pattern.

Tips

  • Compare against the Moore Curve Generator and Gosper Curve Generator to see how different space-filling and plane-filling constructions produce very different visual textures.
  • Zoom into the downloaded SVG in a vector editor to trace the boustrophedon sweep row by row at higher iteration counts.

References

Frequently Asked Questions