Space-filling curves

Explore Hilbert, Peano and paper-folding dragon paths, with complete animated traversal and vector or coordinate export.

About this tool

These finite paths show how recursive curves develop. Hilbert and Peano visit every cell of a square grid once; their continuous limits fill a square. The dragon follows a repeated paper-folding turn sequence. A finite polyline has no filled area.

  • Choose the curve and order, then Draw. Limits are Hilbert 1–8, Peano 1–4 and Dragon 1–14. Unsupported values produce an error, never a lower-order replacement.
  • Hilbert order n visits 4ⁿ centres of a 2ⁿ by 2ⁿ grid. Peano visits 9ⁿ vertices of a 3ⁿ by 3ⁿ grid. Dragon has 2ⁿ unit segments; its path may touch itself.
  • A green circle marks the start, a red square the end. Equal axis units preserve the geometry. Gradual drawing takes about three seconds of active playback; Pause/Resume keeps its position and Cancel clears the incomplete result.
  • Resize or a theme change redraws the same points held in memory. Curve and order edits rebuild the path; invalid orders do not produce a replacement drawing.
  • Exports become available only for a complete path. PNG records parameters and endpoints. SVG retains sharp projected lines; CSV lists index,x,y in model coordinates, with the same traversal order. Orientations vary between conventions; this tool keeps its stated grid coordinates.
  • After the first Draw, curve or order changes update the path automatically. Switching gradual drawing off completes the current route immediately. Ctrl/Meta+wheel zooms around the centre; mouse dragging moves the view. Reset fits the entire route without changing playback progress. The Export menu offers PNG, SVG and CSV. Only input values are retained between visits, not the route, playback position or mouse view.