Haferman Carpet

The Haferman Carpet is a fractal, which kind of looks like a woven carpet. To generate it, you start with a single black pixel and apply in each cycle a set of rules.
In each generation every pixel in the carpet will be replaced by nine pixels according to the rules. A black pixel is represented by a 0, a white one by a 1.

The rules

  • 0 \rightarrow \left( \begin{array}{ccc}1&0&1\\0&1&0\\1&0&1\end{array} \right) \text{and } 1 \rightarrow \left( \begin{array}{ccc}0&0&0\\0&0&0\\0&0&0\end{array} \right)

6 iterations of the Haferman Carpet


# Python 2.7.7 Code
# Pygame 1.9.1 (for Python 2.7.7)
# Jonathan Frech 26th of February, 2016

Continue reading

Moving Fonts

Experimenting with pygame’s font functions, I wanted to list every font pygame could reach with its built-in font.get_fonts() function. This program does so by letting you spawn in the wonderful sentence ‘Hello world.’ and assigns it a font based on the previously mentioned function.

Controls

  • Left click spawns in a new sentence at current mouse position
  • Space saves a screenshot

The first example The third example The second example


# Python 2.7.7 Code
# Pygame 1.9.1 (for Python 2.7.7)
# Jonathan Frech  9th of January, 2016
# Jonathan Frech 13th of January, 2016
# Jonathan Frech 15th of January, 2016

Continue reading