Overview
Introduction
The Gosper curve, also known as the Peano-Gosper curve or flowsnake, is a classic space-filling fractal whose outline tiles the plane using hexagonal-flavored, seven-fold self-similar pieces. This tool renders its standard L-system construction as SVG line art.
Enter an iteration count and the tool expands the Gosper curve's two-symbol production rules that many times, then draws the resulting path so you can see its distinctive swirling, snowflake-like silhouette emerge.
What Is Generate a Gosper Curve?
A real, named space-filling curve first described by Bill Gosper, built from a seven-segment self-similar replacement at 60-degree turn angles, the same angle family as hexagonal grids and Koch-style curves.
The region it encloses, the Gosper island, is a well-known rep-tile: seven smaller copies of the same shape tile one larger copy of itself exactly, which is what gives the curve its name-sake seven-fold segment growth.
How Generate a Gosper Curve Works
The generator starts from the axiom "A" and repeatedly applies the rules A becomes "A-B--B+A++AA+B-" and B becomes "+A-BB--B-A++A+B" for as many iterations as you enter, where + and - are 60-degree turns.
Both A and B are draw-forward letters in this L-system (unlike the standalone F convention), so every A and B in the expanded string moves the turtle forward and draws a segment, only the turning pattern between segments differs between the two.
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 swirling path.
When To Use Generate a Gosper Curve
Use it whenever you want a visually distinctive, swirling space-filling curve for generative art, backgrounds, or fractal-geometry demonstrations that go beyond the more common Hilbert or Peano curves.
It's a good teaching example of a rep-tile, a shape that seven smaller copies of itself can tile exactly, paired with the turtle-graphics curve that traces its boundary.
If you want a simpler, right-angle space-filling curve instead, use the Peano Curve Generator or Moore Curve Generator.
Often used alongside Generate a Peano Curve, Generate a Moore Curve and Generate a Sierpinski Arrowhead Curve.
Features
Advantages
- A well-documented, classic mathematical curve with a single, unambiguous construction, not an invented variant.
- Its 60-degree, seven-fold structure produces a visually distinctive, organic-looking silhouette compared to right-angle space-filling curves.
- Downloadable as both SVG (for further vector editing) and PNG (for quick use anywhere).
Limitations
- Segment count grows seven-fold per iteration, so the range is capped at 5 to keep rendering and downloads responsive.
- At higher iterations the swirling detail becomes dense enough that individual segments are hard to distinguish without zooming into the downloaded SVG.
Examples
Best Practices & Notes
Best Practices
- Start at iteration 1 or 2 to see the seven-segment replacement clearly before increasing toward the denser, more swirling higher end of the range.
- 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 ("gosper-curve" in l-system-presets.ts): axiom "A", rules A: "A-B--B+A++AA+B-" and B: "+A-BB--B-A++A+B", 60-degree turn angle, with both A and B registered as draw letters (drawLetters: ["A", "B"]) rather than the default F-only convention, capped at 5 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 Gosper Curve Use Cases
- Teaching rep-tiles and space-filling curves with a real, citable, visually distinctive example
- Generative art and print patterns built from a swirling, hexagonal-flavored fractal
- Downloadable SVG line art for design projects referencing the classic Gosper curve or flowsnake
Common Mistakes
- Assuming only F draws in this L-system; both A and B are draw-forward letters here, unlike most of the other curves in this category where only F draws.
- Setting iterations to the maximum right away; past 3 or 4 the swirling detail becomes dense enough to make individual segments hard to distinguish visually.
Tips
- Compare against the Sierpinski Arrowhead Curve Generator to see another 60-degree turtle-graphics curve with a very different overall silhouette.
- Zoom into the downloaded SVG in a vector editor to trace the seven-fold self-similar replacement at higher iteration counts.