inkscape-tetraflexagon-editor.svg: update the tetraflexagon example
[flexagon-toolkit.git] / src / svg_tetraflexagon_editor.py
index 6b57160..58209c7 100755 (executable)
@@ -32,6 +32,7 @@ class SvgwriteTetraflexagonDiagram(TetraflexagonDiagram):
         # create some layers and groups
         layers = {
             "Squares": svg.layer(label="Squares"),
+            "Backfaces": svg.layer(label="Backfaces"),
             "Tetraflexagon": svg.layer(label="Tetraflexagon"),
             "Template": svg.layer(label="Template")
         }
@@ -90,6 +91,19 @@ class SvgwriteTetraflexagonDiagram(TetraflexagonDiagram):
                 ref['clip-path'] = "url(%s)" % (tile_href + '-clip-path')
                 group.add(ref)
 
+        # A tri-tetraflexagon only have one visible backface, the first one.
+        group = self.groups["Backfaces"]
+        for tile in self.tetraflexagon.squares[0].tiles:
+            m = self.get_backface_tile_transform(tile)
+            svg_matrix = "matrix(%f, %f, %f, %f, %f, %f)" % (m[0], m[3],
+                                                             m[1], m[4],
+                                                             m[2], m[5])
+            tile_href = "#square0-tile%d" % tile.index
+            ref = self.backend.svg.use("#square0-content")
+            ref['transform'] = svg_matrix
+            ref['clip-path'] = "url(%s)" % (tile_href + '-clip-path')
+            group.add(ref)
+
     def draw_tile_template(self, tile, cx, cy, theta):
         old_active_group = self.backend.active_group
         group_name = "square%d-tile%d" % (tile.square.index, tile.index)