self.plan_origin = (self.x_border * 2. + self.hexagon_radius / 2.,
self.x_border + self.triangle_radius / 3.)
+ # The offset of the backfaces relative to the first hexagon
+ self.backfaces_offsets = (0,
+ (self.hexagon_radius + self.x_border) * 2)
+
self.hexagons_color_map = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
def _init_centers(self):
def get_triangle_center(self, triangle):
return self.triangles_centers[triangle.hexagon.index][triangle.index]
+ def get_triangle_center_in_backfaces(self, triangle):
+ """Get the center of this triangle but in the backface"""
+ x0, y0 = self.backfaces_offsets
+
+ backface_triangle_index = triangle.get_backface_index()
+ x, y = self.triangles_centers[triangle.hexagon.index][backface_triangle_index]
+
+ return x0 + x, y0 + y
+
def get_triangle_center_in_plan(self, triangle):
x0, y0 = self.plan_origin
i, j = self.hexaflexagon.get_triangle_plan_position(triangle)
return self.backend.calc_rotate_translate_transform(src_x, src_y,
dest_x, dest_y, theta)
+ def get_triangle_backfaces_transform(self, triangle):
+ """Calculate the transformation matrix from a triangle in an hexagon to
+ the correspondent triangle in a backface.
+
+ Return the matrix as a list of values sorted in row-major order."""
+ src_x, src_y = self.get_triangle_center(triangle)
+ dest_x, dest_y = self.get_triangle_center_in_backfaces(triangle)
+ theta = triangle.get_angle_in_backface_relative_to_hexagon()
+
+ return self.backend.calc_rotate_translate_transform(src_x, src_y,
+ dest_x, dest_y, theta)
+
def draw_hexagon_template(self, hexagon):
for triangle in hexagon.triangles:
cx, cy = self.get_triangle_center(triangle)