Staaarter

Generate a Sierpinski Square

Generates a square fractal built from a 2x2 grid where one quadrant is dropped at every level, an L-shaped recursion distinct from the classic carpet's 3x3-minus-center pattern. Adjust the Depth input from 0 to 8 and export the result as SVG or PNG. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-08-05
By Staaarter Team
fractalgeneratorsvg

Overview

Introduction

Most Sierpinski-style square fractals are built on the carpet's 3x3-minus-center rule. This tool takes a different, simpler approach, split each square into just 4 quadrants and drop one of them, repeated recursively.

The result is a self-similar, L-shaped fractal rather than the carpet's centered, symmetric hole pattern, and it's our own square-based variant rather than a reproduction of the classical carpet.

What Is Generate a Sierpinski Square?

A recursive square fractal generator that subdivides each surviving square into a 2x2 grid of quadrants and removes one specific quadrant at every level.

It shares the same recursive spirit as the Sierpinski carpet, subdivide and remove, but with a different grid size and removal pattern, producing a visually distinct L-shaped silhouette instead of the carpet's centered lattice.

How Generate a Sierpinski Square Works

Starting from a single square, the tool splits it into a 2x2 grid of four equal quadrants and discards one fixed quadrant, keeping the other three.

Each of the three surviving quadrants is then recursively split the same way, into 4 sub-quadrants with one dropped, down to the chosen Depth.

Because the same quadrant position is dropped at every level and every scale, the overall silhouette accumulates into an L-shaped, self-similar outline rather than a centered hole pattern.

When To Use Generate a Sierpinski Square

Use it when you want a square-grid fractal with an asymmetric, L-shaped character, for generative art, geometric backgrounds, or teaching recursive subdivision with a simpler 2x2 rule than the carpet's 3x3.

If you specifically need the classical, centered Sierpinski carpet pattern, use a carpet generator instead, this tool's quadrant-drop rule produces a different shape.

Features

Advantages

  • Simple 2x2 subdivision rule that's easy to follow visually, even at higher depth.
  • Supports Depth up to 8, well beyond the 3x3-grid tools, since each level only quarters the surviving squares.
  • Filled-square rendering makes the recursive structure easy to read at a glance.

Limitations

  • Not the classical Sierpinski carpet, if you need that exact centered construction, this L-shaped variant isn't a substitute.
  • The self-similarity is directional (always the same quadrant dropped), so the fractal isn't rotationally symmetric the way the carpet is.

Examples

Depth 5 square fractal

Input

Depth: 5

Output

A dense, self-similar L-shaped arrangement of small filled squares, five levels of quadrant-dropping recursion deep.

Every surviving quadrant from depth 4 is quartered again with one quadrant removed, repeated recursively.

Best Practices & Notes

Best Practices

  • Start around Depth 3-4 to see the L-shaped structure clearly before pushing toward the higher end of the range.
  • Use the SVG export if you plan to recolor the filled squares or extract them as separate shapes later.

Developer Notes

The geometry reuses the shared `subdivideGrid` helper with `gridSize = 2` and a `keep(row, col)` predicate that drops one fixed quadrant (row 0, col 1), unlike the carpet/maze tools which pass `gridSize = 3` and drop only the center cell. Because the sub-cell count only grows by a factor of 3 per level (3 kept of 4) rather than 8 of 9, `boundsCheck` allows Depth up to 8 here instead of 4.

Generate a Sierpinski Square Use Cases

  • Generative art and geometric background patterns with an asymmetric fractal silhouette
  • Teaching recursive subdivision using a simpler 2x2 rule before introducing the carpet's 3x3 rule
  • Comparing subdivision strategies against the carpet-based Sierpinski Maze Generator

Common Mistakes

  • Assuming this produces the same shape as the classic Sierpinski carpet, the 2x2 quadrant-drop rule gives a different, L-shaped result.
  • Setting Depth too high too quickly, the squares shrink fast and the structure can become hard to distinguish visually past depth 6 or 7 at typical viewing sizes.

Tips

  • Compare this tool against Sierpinski Maze Generator at the same conceptual depth to see how a 2x2 versus 3x3 subdivision rule changes the resulting silhouette.
  • Lower the Depth if you're exporting for a small thumbnail, the finest detail only matters at larger render sizes.

References

Frequently Asked Questions