Sierpinski Fractals

A Sierpinski Gasket, and some other things based on the same technique. These were all made in postscript.

A normal Sierpinski Gasket drawn with filled triangles Drawn with spokes instead
postscript source postscript source
Drawn with hollow triangles in a different way The same, except the lines get thinner for each level recursed
postscript source postscript source

This Sierpinski Triangle was generated from Pascal's Triangle. The color for each segment is obtained from the appropriate value in Pascal's Triangle modulus 4. Lots of other people have done things like this. I'll add some links sometime. This was generated with a Python program which generates postscript. Thanks to Tom for pointing this idea out to me.

A Sierpinski Triangle generated by color coding Pascal's Triangle modulus 4
Python source

This is a Sierpinski Pentagon and a snowflake derived from it by selectively filling the shapes which are left white in the first one. Incidentaly, it looks to me like each side of each pentagon in the Sierpinski Pentagon is a Koch Curve, except that the triangles aren't equilateral so the proportions are different.

The normal Sierpinski Pentagon was made in postscript and the snowflake thing in metapost.

Drawn with pentagons in a similar way to a Sierpinski Gasket An inverse Sierpinski Pentagon with only some parts filled
postscript source METAPOST source
ready-made postscript

My only POV hack so far is a Sierpinski Gasket in 3D (using tetrahedrons instead of triangles). I made this by writing a simple perl program with a recursive function which prints definitions cylinders in the POV scene language. That can then be rendered in POV. It's not perfect yet. The colors are generated by working out how far each cylinder is from the three corners of the base and scaling the red, green and blue components accordingly.

Someone else has made a similar POV scene, a picture of which is here, and there's a square-based version under a floating monk here.

I've also recently made a Perl program which shows a rotating 3D sierpinski gasket, using OpenGL.

3D Sierpinski Gasket
perl source
(the POV source it generates is too big to include here.)

A Menger Sponge generated with an OpenGL program. The program can really kill a machine if its rendered to more than a few levels of recursion. When the program is running the ‘+’ and ‘-’ keys can be used to changed the depth. There are other keys to rotate it and zoom in.

3D Menger Sponge
C++/OpenGL source