Overview
Introduction
The Sierpinski carpet is usually drawn as a flat, solid pattern, squares within squares with the centers punched out. This tool takes that exact same recursive subdivision and draws it a different way, as outlines only, so the boundaries between surviving cells link up into something that looks like a maze of corridors.
It's a rendering variation on a well-known fractal rather than a new mathematical construction, the underlying subdivision rule is identical to the standard carpet.
What Is Generate a Sierpinski Maze?
A generator that applies the Sierpinski carpet's recursive 3x3-minus-center subdivision, then renders every surviving cell as a four-sided line outline instead of a filled square.
Where the carpet is normally shown as solid shapes against empty space, this tool inverts the visual emphasis onto the cell boundaries themselves, producing a lattice of nested square corridors.
How Generate a Sierpinski Maze Works
Starting from a single square, the tool splits it into a 3x3 grid of nine equal sub-cells and discards the center one, exactly as the classic carpet does. It then recurses into each of the 8 remaining sub-cells and repeats the same 3x3-minus-center split, down to the chosen Depth.
Once recursion bottoms out, every surviving cell at every level is drawn as an outline, its four edges as separate line segments, rather than filled in. Because cells at different depths sit directly next to and inside one another, their combined outlines form a dense, connected network of corridor-like boundaries.
Increasing Depth adds another round of subdivision to every surviving cell, tripling the density of nested outlines and shrinking the smallest corridors by a further factor of three.
When To Use Generate a Sierpinski Maze
Use it when you want a Sierpinski-style fractal pattern that reads visually as a maze or circuit-board layout, for backgrounds, generative art, or laser-cut/CNC line-art references.
If you want the traditional filled-square look of the carpet instead, this specific outline rendering isn't the right choice, look for a filled carpet generator instead.
Often used alongside Generate a Sierpinski Square, Generate a Sierpinski Hexagon and Generate a Sierpinski Pentagon.
Features
Advantages
- Produces a visually distinct maze-like pattern from a well-understood, easy-to-reason-about recursive rule.
- Outline-only rendering keeps the SVG output lightweight, it's line segments rather than filled polygons.
- Fully deterministic, the same Depth always produces the identical layout, useful for reproducible design work.
Limitations
- Not a functional maze, there's no guaranteed entrance, exit, or connectivity between every corridor.
- Depth is capped at 4, since the cell outlines become too small and dense to render legibly beyond that.
Examples
Best Practices & Notes
Best Practices
- Start at a low Depth (1 or 2) to see the base subdivision clearly before increasing it, the pattern gets visually dense fast.
- Export as SVG when you need to scale or further edit the corridor lines, and PNG when you just need a flat image.
Developer Notes
The geometry comes from the same `subdivideGrid` helper the carpet and square generators share, called with a 3x3 grid and a `keep(row, col)` predicate that drops the center cell (row 1, col 1). Rather than pushing the surviving cells as filled `Rect` shapes, `generateSierpinskiMaze` maps each resulting rect into four `LineSegment`s (top, right, bottom, left), so the SVG renders `<path>` strokes instead of `<rect>` fills. Depth is bounded to 0-4 by the shared `boundsCheck` helper.
Generate a Sierpinski Maze Use Cases
- Generative art backgrounds with a fractal, circuit-board-like texture
- Line-art references for laser cutting or CNC engraving
- Teaching recursive subdivision by contrasting the filled carpet against this outline rendering
Common Mistakes
- Expecting a solvable maze with a clear path from edge to edge, the outlines are just carpet-subdivision boundaries, not a designed puzzle.
- Jumping straight to Depth 4, which produces a very dense pattern, without first checking Depth 1 or 2 to understand the base rule.
Tips
- Compare this tool side by side with Sierpinski Square Generator to see how the same idea of dropping cells looks with a different subdivision rule.
- Download the SVG if you plan to recolor or restyle the strokes later, it keeps the corridor lines as editable vector paths.