def get_pixel_width(self): if ui_cfg.base_style == 1: tile_offsets = BoardTools.get_hex_tile_offsets(self.hex_radius) x_toff = tile_offsets[0] width = x_toff / 2 + (BASE_COLUMN_COUNT * x_toff) return width elif ui_cfg.base_style == 2: tile_offsets = BoardTools.get_rect_tile_offsets(self.hex_radius) x_toff = tile_offsets[0] width = (BASE_COLUMN_COUNT) * x_toff return width
def get_pixel_height(self): if ui_cfg.base_style == 1: tile_offsets = BoardTools.get_hex_tile_offsets(self.hex_radius) y_toff = tile_offsets[1] height = ((self.row_count-1) * y_toff) + 2 * self.hex_radius return height elif ui_cfg.base_style == 2: tile_offsets = BoardTools.get_rect_tile_offsets(self.hex_radius) y_toff = tile_offsets[1] height = (y_toff * self.row_count) return height
def _get_relative_center_pixel_for_visual_position(self, pos): x = pos[0] y = pos[1] offsets = BoardTools.get_hex_vertex_offsets(self.hex_radius) xoffset = offsets[0] yoffset = offsets[1] shifts = BoardTools.get_hex_tile_offsets(self.hex_radius) xshift = shifts[0] yshift = shifts[1] oddOffset = 0 if y % 2 == 1: oddOffset = xoffset x_pixel = xoffset + oddOffset + (x * xshift) y_pixel = self.hex_radius + (y * yshift) return (x_pixel, y_pixel)
def _get_relative_center_pixel_for_slot(self, slot): column = slot[0] row = slot[1] if ui_cfg.base_style == 1: vertex_offsets = BoardTools.get_hex_vertex_offsets(self.hex_radius) x_voff = vertex_offsets[0] y_voff = vertex_offsets[1] tile_offsets = BoardTools.get_hex_tile_offsets(self.hex_radius) x_toff = tile_offsets[0] y_toff = tile_offsets[1] oddOffset = 0 #odd rows are shifted by a half tile if row % 2 == 1: oddOffset = x_toff / 2 x_pixel = (x_toff / 2) + oddOffset + (column * x_toff) y_pixel = self.hex_radius + (row * y_toff) y_pixel = self.get_pixel_height() - y_pixel if (self.direction == TKPlayerBase.RIGHT): x_pixel = self.get_pixel_width() - x_pixel return (x_pixel, y_pixel) elif ui_cfg.base_style == 2: tile_offsets = BoardTools.get_rect_tile_offsets(self.hex_radius) x_toff = tile_offsets[0] y_toff = tile_offsets[1] x_pixel = (x_toff / 2) + (column * x_toff) y_pixel = (y_toff / 2) + row * y_toff y_pixel = self.get_pixel_height() - y_pixel return (x_pixel, y_pixel)
def get_pixel_width(self): xshift = BoardTools.get_hex_tile_offsets(self.hex_radius)[0] width = self.major * xshift return width
def get_pixel_height(self): tile_offsets = BoardTools.get_hex_tile_offsets(self.hex_radius) y_toff = tile_offsets[1] height = ((self.minor-1) * y_toff) + 2 * self.hex_radius return height