Penrose Tiling

A generator written in Python

Penrose Tiling Generator is a Python application for generating P3 Penrose Tilings. Given a golden triangle, golden gnomon, rectangle or circle as input it will output a vector graphic of that shape tiled using Penrose rhombs.

The documentation is written in Markdown. Pandoc together with Tufte Pandoc CSS for styling is used to generate this html file.

The Git Repository is hosted by Sourcehut:

Golden Triangle Golden Gnomon Rectangle Circle

left to right: Golden triangle (8 generations), golden gnomon (8 generations), rectangle (10 generations) and circle (8 generation)

Note: The circle as whole is not a valid penrose tiling. It was constructed using ten golden triangles each tiled separately.



You do not have to install these manually. If you have Python3 and pip installed just follow the section Instruction below.


git clone
cd Penrose-Tiling-Generator
python3 -m venv venv
source venv/bin/activate
pip install .


ptg --help

Usage: ptg [OPTIONS]

  A Penrose Tiling Generator.

  Generates Penrose Tilings for a golden triangle, golden gnomon, rectangle
  or circle shape. Output will be a SVG.

  -s, --shape [triangle|t|gnomon|g|rectangle|r|circle|c]
                                  Golden triangle (t), golden gnomon (g),
                                  rectangle (r) or circle (c).
  -b, --base FLOAT                Length of the base of the golden triangle or
                                  golden gnomon.
  -w, --width FLOAT               Width of rectangle.
  -h, --height FLOAT              Height of rectangle.
  -r, --radius FLOAT              Radius of circle.
  --color-thick-rhombuses TEXT    Hex color code for thick rhombuses.
  --color-thin-rhombuses TEXT     Hex color code for thin rhombuses.
  -g, --generations INTEGER       Number of deflation steps.
  -o, --output PATH               Write output to PATH instead of stdout.
  -v, --verbose                   Enable logging to stdout.
  --version                       Show the version and exit.
  --help                          Show this message and exit.

All options except of shape have default values:

Convert SVG to PNG (Vector to Bitmap)

Using convert (ImageMagick)

From Convert Command Manual: “The convert program is a member of the ImageMagick suite of tools. Use it to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.”

# from file:
convert penrose_tiles.svg penrose_tiles.png

# from stdout:
`ptg -s t | convert svg:- penrose_tiles.png`

Using Inkscape

From the Inkscape Command Manual: “Inkscape - an SVG (Scalable Vector Graphics) editing program.”

# from file:
inkscape penrose_tiles.svg --export-area-drawing --export-area-snap --export-png penrose_tiles.png

# from stdout:
ptg -s t | inkscape - --export-area-drawing --export-area-snap --export-png penrose_tiles.png

Create a GIF

A GIF can be created using the convert (ImageMagick) command. Here is an example bash script which takes a single argument representing the resulting shape as input and generates a GIF with 10 substitutions as output:

for i in `seq 1 10`;
    ptg -s ${shape} -g ${i} |
    convert svg:- penrose_${shape}_${i}.png
convert -delay 60 -loop 0 *.png "penrose_${shape}.gif"
rm penrose_${shape}_*.png



An informal definition of tiling is given by Senechal and Kahn 1995:

A tiling is a partition of a space into a countable number of tiles

The most familiar tilings are periodic consisting of a finite number of shapes. Those shapes are called prototiles. For example a chessboard is a square tiled using two different shapes (two prototiles), differentiated by color. The chessboard is also periodic. The means the pattern will repeat itself.

Penrose Tiling

Penrose tilings are aperiodic tilings (No translational symmetry). The tiling is self-similar which means that every finite patch occurs infinitely many times (1995: Senechal et al.).

There are three types of penrose tiling:

This software project implements rhombus tiling (P3).


Algorithm Steps

  1. Generate of base triangle (Golden Gnomon or Golden Triangle) according to shape and dimensions
  2. Substitute base triangle and resulting triangle for every generation
  3. Draw a Scalable-Vector-Graphic (SVG)
    • Make use of the clipPathand transform attribute




Every Generation:

Exponential Complexity: between O(2n) & O(3n)

Total number of triangles for each generation

Generations Golden Triangle (#) Golden Gnomon (#)
0 1 1
1 2 3
2 5 8
3 13 21
4 34 55
5 89 144
6 233 377
7 610 987
8 1,597 2,584
9 4,181 6,765
10 10,946 17,711
11 28,657 46,368
12 75,025 121,393
13 196,418 317,811
14 514,229 832,040
15 1,346,269 2,178,309
16 - -

Existing Implementations of Penrose Tiling

Math 308 Project - Ianiv Schweber:

Preshing on Programming: