# Path: tessagon/core/grid_tile_generator.py
# class GridTileGenerator(TileGenerator):
#     def __init__(self, tessagon, **kwargs):
#         super().__init__(tessagon, **kwargs)
# 
#         self.tiles = None
# 
#     def create_tiles(self):
#         self.tiles = self.initialize_tiles(self.tessagon.__class__.tile_class)
#         self.initialize_neighbors(self.tiles)
#         # Flatten the tiles
#         return [j for i in self.tiles for j in i]
# 
# Path: tessagon/core/rotate_tile_generator.py
# class RotateTileGenerator(TileGenerator):
#     # This generates tiles that are rotated from a regular
#     # grid arrangement.
#     def __init__(self, tessagon, **kwargs):
#         super().__init__(tessagon, **kwargs)
# 
#         self.rot_factor = kwargs['rot_factor']
#         self.color_pattern = kwargs.get('color_pattern') or None
# 
#         # Rot tiles are not tiles, they are a collection of tiles.
#         # They generate interior tiles ((rot_factor - 1)^2 of them) and
#         # up to 2 * rot_factor boundary tiles that are shared with neighbors
#         # (if they exist).
#         # Maximum tiles generated per rot_tile is rot_factor^2 + 1 tiles
#         # With this in mind, you'll want to set u_num and v_num lower than
#         # you would with the grid tile generator
#         self.rot_tiles = None
# 
#         self.id_prefix = 'rot_tiles'
# 
#     def create_tiles(self):
#         self.rot_tiles \
#             = self.initialize_tiles(RotTile,
#                                     rot_factor=self.rot_factor,
#                                     color_pattern=self.color_pattern)
#         self.initialize_neighbors(self.rot_tiles)
#         self.initialize_interiors()
#         self.initialize_boundaries()
#         self.calculate_boundary_neighbors()
#         return self.calculate_rot_tiles()
# 
#     def initialize_interiors(self):
#         for rot_tile in [j for i in self.rot_tiles for j in i]:
#             rot_tile.initialize_interior()
# 
#     def initialize_boundaries(self):
#         for rot_tile in [j for i in self.rot_tiles for j in i]:
#             rot_tile.initialize_boundary()
# 
#     def calculate_boundary_neighbors(self):
#         for rot_tile in [j for i in self.rot_tiles for j in i]:
#             rot_tile.calculate_boundary_neighbors()
# 
#     def calculate_rot_tiles(self):
#         tiles = []
#         for rot_tile in [j for i in self.rot_tiles for j in i]:
#             tiles += rot_tile.create_tiles()
#         return tiles


from tessagon.core.grid_tile_generator import GridTileGenerator
from tessagon.core.rotate_tile_generator import RotateTileGenerator


class Tessagon:
    tile_class = None
    metadata = None

    def __init__(self, **kwargs):
        if 'function' in kwargs:
            self.f = kwargs['function']
        else:
            raise ValueError('Must specify a function')

        if 'tile_generator' in kwargs:
            self.tile_generator = kwargs['tile_generator'](self, **kwargs)
        elif 'rot_factor' in kwargs:
            self.tile_generator = RotateTileGenerator(self, **kwargs)
        else:

# Path: tessagon/core/grid_tile_generator.py
# class GridTileGenerator(TileGenerator):
#     def __init__(self, tessagon, **kwargs):
#         super().__init__(tessagon, **kwargs)
# 
#         self.tiles = None
# 
#     def create_tiles(self):
#         self.tiles = self.initialize_tiles(self.tessagon.__class__.tile_class)
#         self.initialize_neighbors(self.tiles)
#         # Flatten the tiles
#         return [j for i in self.tiles for j in i]
# 
# Path: tessagon/core/rotate_tile_generator.py
# class RotateTileGenerator(TileGenerator):
#     # This generates tiles that are rotated from a regular
#     # grid arrangement.
#     def __init__(self, tessagon, **kwargs):
#         super().__init__(tessagon, **kwargs)
# 
#         self.rot_factor = kwargs['rot_factor']
#         self.color_pattern = kwargs.get('color_pattern') or None
# 
#         # Rot tiles are not tiles, they are a collection of tiles.
#         # They generate interior tiles ((rot_factor - 1)^2 of them) and
#         # up to 2 * rot_factor boundary tiles that are shared with neighbors
#         # (if they exist).
#         # Maximum tiles generated per rot_tile is rot_factor^2 + 1 tiles
#         # With this in mind, you'll want to set u_num and v_num lower than
#         # you would with the grid tile generator
#         self.rot_tiles = None
# 
#         self.id_prefix = 'rot_tiles'
# 
#     def create_tiles(self):
#         self.rot_tiles \
#             = self.initialize_tiles(RotTile,
#                                     rot_factor=self.rot_factor,
#                                     color_pattern=self.color_pattern)
#         self.initialize_neighbors(self.rot_tiles)
#         self.initialize_interiors()
#         self.initialize_boundaries()
#         self.calculate_boundary_neighbors()
#         return self.calculate_rot_tiles()
# 
#     def initialize_interiors(self):
#         for rot_tile in [j for i in self.rot_tiles for j in i]:
#             rot_tile.initialize_interior()
# 
#     def initialize_boundaries(self):
#         for rot_tile in [j for i in self.rot_tiles for j in i]:
#             rot_tile.initialize_boundary()
# 
#     def calculate_boundary_neighbors(self):
#         for rot_tile in [j for i in self.rot_tiles for j in i]:
#             rot_tile.calculate_boundary_neighbors()
# 
#     def calculate_rot_tiles(self):
#         tiles = []
#         for rot_tile in [j for i in self.rot_tiles for j in i]:
#             tiles += rot_tile.create_tiles()
#         return tiles


# Path: tessagon/core/tessagon.py
from tessagon.core.grid_tile_generator import GridTileGenerator
from tessagon.core.rotate_tile_generator import RotateTileGenerator



class Tessagon:
    tile_class = None
    metadata = None

    def __init__(self, **kwargs):
        if 'function' in kwargs:
            self.f = kwargs['function']
        else:
            raise ValueError('Must specify a function')

        if 'tile_generator' in kwargs:
            self.tile_generator = kwargs['tile_generator'](self, **kwargs)
        elif 'rot_factor' in kwargs:
            self.tile_generator = RotateTileGenerator(self, **kwargs)
        else:

            self.tile_generator = GridTileGenerator(self, **kwargs)