Making Fractals with MetaPost

Sierpinski's Sieve rendered with MetaPost I’ve played a lot with MetaPost today — I’ve been making fractals. It’s a lot of fun to make graphics with MetaPost, and making the fractals was no exception.

I’ve made three kinds of fractals: Koch Curves, Hilbert Curves and finally the one shown at the right, Sierpinski’s Sieve. The last one is also know as Sierpinski’s Triangle, for obvious reasons.

You can download the sourcecode and a document here: /downloads/metafractals/. If you’re trying to remake the document, then please note that the images are called filenameN.mps instead of just filename.N. This is because PDFLaTeX works best with those filenames. So you’ll have to rename the files generated by MetaPost before running LaTeX/PDFLaTeX. If you’re running Zsh, then you could use this very little shell-script:

for basename in $*; do
    mpost $basename
    for file in ${}.<0->; do
        mv $file ${file/./}.mps


  1. icryzhijchertaj:

    Thanks to Oprah, Obama camp claims biggest crowd yet

  2. Kristabelle:

    Woot, I will crtaeilny put this to good use!

Leave a comment