tetraflexagon_diagram: add a function to calculate the tile offset in a square
[flexagon-toolkit.git] / src / flexagon / tetraflexagon_diagram.py
index 5d810de..ab3da17 100755 (executable)
@@ -54,9 +54,8 @@ class TetraflexagonDiagram(object):
 
             for tile in square.tiles:
                 # offset by 1 or -1 times the tile radius
-                tile_cx = cx + self.tile_radius * ((tile.index % 2) * 2 - 1)
-                tile_cy = cy + self.tile_radius * ((tile.index > 1) * 2 - 1)
-                self.tiles_centers[square.index][tile.index] = (tile_cx, tile_cy)
+                tile_xoffset, tile_yoffset = tile.calc_offset_in_square(self.tile_side)
+                self.tiles_centers[square.index][tile.index] = (cx + tile_xoffset, cy + tile_yoffset)
 
     def get_square_center(self, square):
         return self.squares_centers[square.index]