X-Git-Url: https://git.ao2.it/flexagon-toolkit.git/blobdiff_plain/b9037211c176b2af1a8d3bf9813daad1bdea172b..dd8b5a94f44ba92a3e7c10737eee866d529580e3:/src/svg_tetraflexagon_editor.py diff --git a/src/svg_tetraflexagon_editor.py b/src/svg_tetraflexagon_editor.py index 90668e3..58209c7 100755 --- a/src/svg_tetraflexagon_editor.py +++ b/src/svg_tetraflexagon_editor.py @@ -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) @@ -97,7 +111,7 @@ class SvgwriteTetraflexagonDiagram(TetraflexagonDiagram): super(SvgwriteTetraflexagonDiagram, self).draw_tile_template(tile, cx, cy, theta) - # The tile outline in the active group's element is the only polygon + # The tile outline in the active group's element is the only rectangle # element, so get it and set its id so that it can be reused as # a clip-path for element in self.backend.active_group.elements: