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]
self.square = square
self.index = index
+ def calc_offset_in_square(self, side):
+ xoffset = side / 2 * ((self.index % 2) * 2 - 1)
+ yoffset = side / 2 * ((self.index > 1) * 2 - 1)
+
+ return xoffset, yoffset
+
@staticmethod
def calc_plan_coordinates(side, i, j):
xoffset = side / 2 + j * side