What Links Here? (1 articles…)

Sierpinski Carpet

Sierpinski didn't just mess around with triangles, he also wrote 50 books (all of them flip-books of Sierpinski triangles, I assume), created a curve and finally — the highlight of his storied career — he released this: his Sierpinski Signature Edition Carpet design.

A short warning before we embark on the creation of Sierpinski's renowned carpet: It takes a while to weave one properly. Fortunately, what you waste on time you make up for on materials. This carpet has an infinite edge and no area!

Before we begin, we'll need a function for drawing a square. (And we will export this function so we can use it in the example below.)

And we're going to need a function for putting a square inside a larger area. It will build on the idea of a square, so first we needs to import our square from above.

Now with those building blocks under our belt, we can build the carpet itself.

Are you ready? I am ready. That means we are both ready. Here we go!

We'll define our carpet function. The code still won't do anything because we don't call the function yet, we're only writing it, and exporting it, for use later. Soon, soon we will call it!

Finally it's time to call the carpet function and weave our mystical weave.

This time we will stop at a recursive depth of 4. If we took it to 5, it would take 8 times as long to build.

If we stopped at a recursive depth of 3... it would be even faster, but far simpler:

 

Logo + Turtle graphics via Papert (via archive.org)

FCa