def initialize_bottom_boundary(self, id_prefix): if not self.boundary['bottom']: tile = self.get_neighbor_tile(['bottom']) if tile: corners = [ self._blend(self.c1, self.c3 - 1.0), self._blend(1, 0), self._blend(0, 0), self._blend(self.c4, self.c2) ] offset = self.basic_offset(self.fingerprint) offset[0] -= 1 offset[1] -= 1 generator = TileGenerator(self.tessagon, corners=corners, u_num=self.n, v_num=1, u_cyclic=False, v_cyclic=False, id_prefix=id_prefix, color_pattern=self.color_pattern, fingerprint_offset=offset) tiles = generator.initialize_tiles(self.tessagon.tile_class) generator.initialize_neighbors(tiles) self.boundary['bottom'] = tiles tile.boundary['top'] = tiles self.tiles += self._flatten_list(tiles)
def initialize_left_boundary(self, id_prefix): if not self.boundary['left']: tile = self.get_neighbor_tile(['left']) if tile: corners = [ self.blend(0, 0), self.blend(self.c2, self.c1), self.blend(self.c3 - 1.0, self.c4), self.blend(0, 1) ] offset = self.basic_offset(self.fingerprint) offset[0] -= 1 generator = TileGenerator(self.tessagon, corners=corners, u_num=1, v_num=self.n, u_cyclic=False, v_cyclic=False, id_prefix=id_prefix, color_pattern=self.color_pattern, fingerprint_offset=offset) tiles = generator.initialize_tiles(self.tessagon.tile_class) generator.initialize_neighbors(tiles) self.boundary['left'] = tiles tile.boundary['right'] = tiles self.tiles = self.tiles.__add__(self._flatten_list(tiles))
def initialize_interior(self): self.interior_corners = [self.blend(self.c2, self.c1), self.blend(self.c4, self.c2), self.blend(self.c1, self.c3), self.blend(self.c3, self.c4)] if self.n < 2: return offset = self.basic_offset(self.fingerprint) generator = TileGenerator(self.tessagon, corners=self.interior_corners, u_num=self.n-1, v_num=self.n-1, u_cyclic=False, v_cyclic=False, id_prefix=self.id + '.interior', color_pattern=self.color_pattern, fingerprint_offset=offset) self.interior \ = generator.initialize_tiles(self.tessagon.__class__.tile_class) generator.initialize_neighbors(self.interior) self.tiles += self._flatten_list(self.interior)
def test_u_v_cyclic(self): tessagon = FakeTessagon() tile_generator = TileGenerator(tessagon, u_range=[0.5, 1.0], v_range=[2.5, 4.0], u_num=2, v_num=3, u_cyclic=True, v_cyclic=True) tiles = tile_generator.initialize_tiles(FakeTileSubClass) assert len(tiles) == 2 assert len(tiles[0]) == 3 assert len(tiles[1]) == 3 tile_generator.initialize_neighbors(tiles) assert (tiles[0][0].get_neighbor_tile(['left']) is tiles[1][0]) assert (tiles[0][0].get_neighbor_tile(['bottom']) is tiles[0][2]) assert (tiles[0][0].get_neighbor_tile(['right']) is tiles[1][0]) assert (tiles[0][0].get_neighbor_tile(['top']) is tiles[0][1]) assert (tiles[1][2].get_neighbor_tile(['left']) is tiles[0][2]) assert (tiles[1][2].get_neighbor_tile(['bottom']) is tiles[1][1]) assert (tiles[1][2].get_neighbor_tile(['right']) is tiles[0][2]) assert (tiles[1][2].get_neighbor_tile(['top']) is tiles[1][0])