Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here


Tilings of regular polygons.

Subscribe to updates I use Tiling

Statistics on Tiling

Number of watchers on Github 386
Number of open issues 2
Average time to close an issue about 9 hours
Main language Python
Average time to merge a PR about 2 hours
Open pull requests 1+
Closed pull requests 0+
Last commit over 6 years ago
Repo Created over 6 years ago
Repo Last Updated over 2 years ago
Size 339 KB
Organization / Authorfogleman
Page Updated
Do you use Tiling? Leave a review!
View open issues (2)
View Tiling activity
View on github
Book a Mock Interview With Me (Silicon Valley Engineering Leader, 100s of interviews conducted)
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating Tiling for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)


Quickly construct tilings of regular polygons and their dual tilings using a simple API.

Scroll down for a tutorial. Here are some examples.






  1. Write polygon tiling code.
  2. ???
  3. Profit!


How To

pycairo is used for rendering. Installation on OS X is easy using Homebrew.

brew install py2cairo

Before creating a new pattern, set these flags to zoom in and label the polygons and their edges.

SCALE = 128

The first step is to create a Model that will hold our polygons.

model = Model()

Next, we will place our first polygon at the origin. We need only specify its number of sides. Let's add a hexagon.


At this point we can run the following code to render the model.

surface = model.render()


Now, let's add squares adjacent to all of the hexagon's edges.

a = model.add(0, range(6), 4)

The first parameter, 0, specifies which shape(s) we're attaching to. Here, we're only attaching to one shape (the hexagon) and it was the first one created, so it's referred to by zero.

The second parameter, range(6), specifies the edges we're attaching to. In this case we want to attach to all six sides of the hexagon. You can see the edges labeled in the output image.

The third parameter, 4, specifies the number of sides for the new shapes. In this case, squares.

The return value of add tracks the indexes of the newly created squares so we can refer to them later.


Next comes the cool part. We can attach triangles to all of the squares we just created in one fell swoop by using the previous return value. Here, we are adding triangles to edge number 1 of each of those squares.

b = model.add(a, 1, 3)


Now we'll add more hexagons which will represent the repeating positions of our template.

c = model.add(a, 2, 6)


Now that we have positions for repeating the pattern, we can use the repeat function to automatically fill in the rest of the surface with our pattern.



Here's all the code needed for this pattern:

from tile import Model, Shape

BLUE = 0x477984
RED = 0xC03C44

model = Model()
model.append(Shape(6, fill=RED))
a = model.add(0, range(6), 4, fill=ORANGE)
b = model.add(a, 1, 3, fill=BLUE)
c = model.add(a, 2, 6, fill=RED)
surface = model.render()

Once finished, you can turn off the helper labels and adjust the scale as desired.


Dual tilings can be created with model.render(dual=True). This setting renders polygons such that the vertices of the original tiling correspond to the faces of the dual tiling and vice-versa.

Here is the dual of the above pattern.


Tiling open issues Ask a question     (View All Issues)
  • over 6 years Label doesn't show up
Tiling open pull requests (View All Pulls)
  • distributable package (added setup.py)
Tiling questions on Stackoverflow (View All Questions)
  • Tiling an image taking long
  • cuBlas matrix multiplication is slower than just cuda tiling code
  • Tiling/covering a polygon algorithm
  • Tiling, how to use recursion in this case?
  • How to retain tiling information(contentTransform property) of a texture in SceneKit while saving/exporting the scene to .dae format?
  • Creating a tiling algorithm for a given space
  • 3D tiling of a numpy array
  • Image tiling causes some browsers to ignore overflow constraints
  • Can I get a proper tiling window manager in KDE
  • How to transform mouse location in isometric tiling map?
  • How would I stretch a Bitmap Shader as opposed to tiling it?
  • tiling images one after the other in python
  • Matlab - Periodic tiling of a surface
  • Compiz Automatic Window Tiling
  • Tiling + OpenGL texture flipping
  • Finding recurrence for Domino Tiling
  • Cropping and tiling a background image with CSS
  • Tiling atlas textures correctly with a custom shader in Unity
  • CUDA : programming with twice as much blocks (tiling?)
  • combine two different length videos frame by frame so as they appear in one frame, kind of like video tiling
  • Quick way to upsample numpy array by nearest neighbor tiling
  • HLSL Tiling Pixel Shader Failing On Large Images
  • Tiling with iText, and adding margins
  • How to launch a gui program in i3 without tiling?
  • Tiling dynamic-sized images seamlessly in column layout using HTML/CSS
  • Perlin noise infinite generation/tiling?
  • OpenGL texture tiling/repeating with matrix
  • Bootstrap Grid Tiling
  • Tiling divs top/bottom right/left, maximum # of divs horizontally?
  • Selenium: resize window in a tiling window manager
Tiling list of languages used
Other projects in Python
Powered by Autocode - Instant Webhooks, Scripts and APIs
Autocode logo wordmark