svg_tetraflexagon_editor: draw also the backface
[flexagon-toolkit.git] / src / flexagon / tetraflexagon_diagram.py
index ab3da17..a79a7a0 100755 (executable)
@@ -39,6 +39,9 @@ class TetraflexagonDiagram(object):
         self.plan_origin = ((self.backend.width - self.tile_side * 5) / 2,
                             self.x_border)
 
         self.plan_origin = ((self.backend.width - self.tile_side * 5) / 2,
                             self.x_border)
 
+        self.backfaces_origin = (self.squares_centers[0][0] - self.tile_side,
+                                 self.squares_centers[0][1] + self.x_border * 2 + self.tile_side)
+
         self.squares_color_map = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
 
     def _init_centers(self):
         self.squares_color_map = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
 
     def _init_centers(self):
@@ -69,6 +72,16 @@ class TetraflexagonDiagram(object):
         x, y = tile.calc_plan_coordinates(self.tile_side, i, j)
         return x0 + x, y0 + y
 
         x, y = tile.calc_plan_coordinates(self.tile_side, i, j)
         return x0 + x, y0 + y
 
+    def get_backface_tile_transform(self, tile):
+        src_x, src_y = self.get_tile_center(tile)
+        tile_xoffset, tile_yoffset = tile.calc_offset_in_square(self.tile_side)
+        # When calculating dest_x the minus in the formula switches the columns.
+        dest_x = self.backfaces_origin[0] + self.tile_side - tile_xoffset
+        dest_y = self.backfaces_origin[1] + self.tile_side + tile_yoffset
+
+        return self.backend.calc_rotate_translate_transform(src_x, src_y,
+                                                            dest_x, dest_y, 0)
+
     def get_tile_transform(self, tile):
         """Calculate the transformation matrix from a tile in an square to
         the correspondent tile in the plan.
     def get_tile_transform(self, tile):
         """Calculate the transformation matrix from a tile in an square to
         the correspondent tile in the plan.