diff --git a/README.md b/README.md index 6a697b7..c333a87 100644 --- a/README.md +++ b/README.md @@ -52,159 +52,52 @@ bmesh = tessagon.create_mesh() Additional tessagon classes can be added by deconstructing how a tessellation fits within a rectangular patch in the plane (check out the ASCII art in each source file in `tessagon.types`). The current `Tessagon` subclasses include: ---- - -### `HexTessagon` -![HexTessagon](documentation/images/hex_tessagon.png) - -Option `color_pattern=1` gives the following pattern: - -![HexTessagon color pattern 1](documentation/images/hex_tessagon_color1.png) - -Option `color_pattern=2` gives the following pattern: - -![HexTessagon color pattern 2](documentation/images/hex_tessagon_color2.png) - ---- - -### `TriTessagon` -![TriTessagon](documentation/images/tri_tessagon.png) - -Option `color_pattern=1` gives the following pattern: - -![TriTessagon color pattern 1](documentation/images/tri_tessagon_color1.png) - -Option `color_pattern=2` gives the following pattern: - -![TriTessagon color pattern 2](documentation/images/tri_tessagon_color2.png) - -Option `color_pattern=3` gives the following pattern: - -![TriTessagon color pattern 3](documentation/images/tri_tessagon_color3.png) - ---- - -### `RhombusTessagon` -![RhombusTessagon](documentation/images/rhombus_tessagon.png) - ---- - -### `OctoTessagon` -![OctoTessagon](documentation/images/octo_tessagon.png) - ---- - -### `HexTriTessagon` (Star of David) -![HexTriTessagon](documentation/images/hex_tri_tessagon.png) - ---- - -### `HexSquareTriTessagon` -![HexSquareTriTessagon](documentation/images/hex_square_tri_tessagon.png) - ---- - -### `SquareTessagon` -![SquareTessagon](documentation/images/square_tessagon.png) - -Option `color_pattern=1` gives the following pattern: - -![SquareTessagon color pattern 1](documentation/images/square_tessagon_color1.png) - -Option `color_pattern=2` gives the following pattern: - -![SquareTessagon color pattern 2](documentation/images/square_tessagon_color2.png) - -Option `color_pattern=3` gives the following pattern: - -![SquareTessagon color pattern 3](documentation/images/square_tessagon_color3.png) - -Option `color_pattern=4` gives the following pattern: - -![SquareTessagon color pattern 4](documentation/images/square_tessagon_color4.png) - -Option `color_pattern=5` gives the following pattern: - -![SquareTessagon color pattern 5](documentation/images/square_tessagon_color5.png) - -Option `color_pattern=6` gives the following pattern: - -![SquareTessagon color pattern 6](documentation/images/square_tessagon_color6.png) - -Option `color_pattern=7` gives the following pattern: - -![SquareTessagon color pattern 7](documentation/images/square_tessagon_color7.png) - -Option `color_pattern=8` gives the following pattern: - -![SquareTessagon color pattern 8](documentation/images/square_tessagon_color8.png) - ---- - -### `PythagoreanTessagon` -![PythagoreanTessagon](documentation/images/pythagorean_tessagon.png) - ---- - -### `BrickTessagon` -![BrickTessagon](documentation/images/brick_tessagon.png) - ---- - -### `DodecaTessagon` -![DodecaTessagon](documentation/images/dodeca_tessagon.png) - ---- - -### `SquareTriTessagon` -![SquareTriTessagon](documentation/images/square_tri_tessagon.png) - ---- - -### `WeaveTessagon` -![WeaveTessagon](documentation/images/weave_tessagon.png) - ---- - -### `FloretTessagon` -![FloretTessagon](documentation/images/floret_tessagon.png) - -Option `color_pattern=1` gives the following pattern: - -![FloretTessagon color pattern 1](documentation/images/floret_tessagon_color1.png) - -Option `color_pattern=2` gives the following pattern: - -![FloretTessagon color pattern 2](documentation/images/floret_tessagon_color2.png) - -Option `color_pattern=3` gives the following pattern: - -![FloretTessagon color pattern 3](documentation/images/floret_tessagon_color3.png) - ---- - -### `HexBigTriTessagon` -![HexBigTriTessagon](documentation/images/hex_big_tri_tessagon.png) - -(Naming things is hard.) - ---- - -### `ZigZagTessagon` -![ZigZagTessagon](documentation/images/zig_zag_tessagon.png) - ---- - -### `DissectedSquareTessagon` -![DissectedSquareTessagon](documentation/images/dissected_square_tessagon.png) - -Option `color_pattern=1` gives the following pattern: - -![DissectedSquareTessagon color pattern 1](documentation/images/dissected_square_tessagon_color1.png) - -Option `color_pattern=2` gives the following pattern: - -![DissectedSquareTessagon color pattern 2](documentation/images/dissected_square_tessagon_color2.png) +### Regular tilings + +* [SquareTessagon](documentation/square_tessagon.md) (8 color patterns) + ![](documentation/images/square_tessagon_thumb.png) +* [HexTessagon](documentation/hex_tessagon.md) (2 color patterns) + ![](documentation/images/hex_tessagon_thumb.png) +* [TriTessagon](documentation/tri_tessagon.md) (3 color patterns) + ![](documentation/images/tri_tessagon_thumb.png) + +### Archimedean tilings + +* [OctoTessagon](documentation/octo_tessagon.md) + ![](documentation/images/octo_tessagon_thumb.png) +* [HexTriTessagon](documentation/hex_tri_tessagon.md) + ![](documentation/images/hex_tri_tessagon_thumb.png) +* [HexSquareTriTessagon](documentation/hex_square_tri_tessagon.md) + ![](documentation/images/hex_square_tri_tessagon_thumb.png) +* [DodecaTessagon](documentation/dodeca_tessagon.md) + ![](documentation/images/dodeca_tessagon_thumb.png) +* [SquareTriTessagon](documentation/square_tri_tessagon.md) + ![](documentation/images/square_tri_tessagon_thumb.png) + +### Laves tilings + +* [RhombusTessagon](documentation/rhombus_tessagon.md) + ![](documentation/images/rhombus_tessagon_thumb.png) +* [FloretTessagon](documentation/floret_tessagon.md) (3 color patterns) + ![](documentation/images/floret_tessagon_thumb.png) + +### Non-edge-to-edge tilings + +* [PythagoreanTessagon](documentation/pythagorean_tessagon.md) + ![](documentation/images/pythagorean_tessagon_thumb.png) +* [BrickTessagon](documentation/brick_tessagon.md) + ![](documentation/images/brick_tessagon_thumb.png) +* [WeaveTessagon](documentation/weave_tessagon.md) + ![](documentation/images/weave_tessagon_thumb.png) +* [HexBigTriTessagon](documentation/hex_big_tri_tessagon.md) + ![](documentation/images/hex_big_tri_tessagon_thumb.png) +* [ZigZagTessagon](documentation/zig_zag_tessagon.md) + ![](documentation/images/zig_zag_tessagon_thumb.png) + +### Misc + +* [DissectedSquareTessagon](documentation/dissected_square_tessagon.md) (2 color patterns) + ![](documentation/images/dissected_square_tessagon_thumb.png) ## Usage and Options diff --git a/core/grid_tile_generator.py b/core/grid_tile_generator.py index dfb876c..8bb460b 100644 --- a/core/grid_tile_generator.py +++ b/core/grid_tile_generator.py @@ -7,7 +7,7 @@ def __init__(self, tessagon, **kwargs): self.tiles = None def create_tiles(self): - self.tiles = self.initialize_tiles(self.tessagon.tile_class) + 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] diff --git a/core/rotate_tile_generator.py b/core/rotate_tile_generator.py index f404ffd..630293f 100644 --- a/core/rotate_tile_generator.py +++ b/core/rotate_tile_generator.py @@ -93,7 +93,8 @@ def initialize_interior(self): color_pattern=self.color_pattern, fingerprint_offset=offset) - self.interior = generator.initialize_tiles(self.tessagon.tile_class) + self.interior = \ + generator.initialize_tiles(self.tessagon.__class__.tile_class) generator.initialize_neighbors(self.interior) self.tiles += self._flatten_list(self.interior) diff --git a/core/tessagon.py b/core/tessagon.py index 15500c9..5bf335b 100644 --- a/core/tessagon.py +++ b/core/tessagon.py @@ -2,14 +2,14 @@ from tessagon.core.rotate_tile_generator import RotateTileGenerator class Tessagon: + tile_class = None + def __init__(self, **kwargs): if 'function' in kwargs: self.f = kwargs['function'] else: raise ValueError('Must specify a function') - self.tile_class = self.init_tile_class() - if 'tile_generator' in kwargs: self.tile_generator = kwargs['tile_generator'](self, **kwargs) elif 'rot_factor' in kwargs: @@ -59,6 +59,10 @@ def inspect(self): for i in range(len(self.tiles)): self.tiles[i].inspect(tile_number=i) + @classmethod + def num_color_patterns(cls): + return cls.tile_class.num_color_patterns + ### Below are protected def _initialize_tiles(self): diff --git a/core/tile.py b/core/tile.py index 905f75e..7588b6f 100644 --- a/core/tile.py +++ b/core/tile.py @@ -1,6 +1,8 @@ from tessagon.core.abstract_tile import AbstractTile class Tile(AbstractTile): + num_color_patterns = 0 + def __init__(self, tessagon, **kwargs): super().__init__(tessagon, **kwargs) @@ -74,6 +76,16 @@ def add_face(self, index_keys, vert_index_keys_list, **kwargs): return face + def calculate_colors(self): + if self.color_pattern > self.__class__.num_color_patterns: + raise ValueError("color_pattern must be below %d" % + (self.__class__.num_color_patterns)) + method_name = "color_pattern%d" % (self.color_pattern) + method = getattr(self, method_name) + if not callable(method): + raise ValueError("%s is not a callable color pattern" % (method_name)) + method() + def color_face(self, index_keys, color_index): face = self._get_face(index_keys) if not face: return @@ -254,6 +266,3 @@ def _set_uv_equivalent_face(self, index_keys, face, **kwargs): u_flip_keys = self._u_flip(index_keys) uv_flip_keys = self._v_flip(u_flip_keys) self.set_equivalent_face([u_index, v_index], uv_flip_keys, face, **kwargs) - - def calculate_colors(self): - pass diff --git a/demo/documentation_images_blender.py b/demo/documentation_images_blender.py index 5bd1f26..5718d82 100644 --- a/demo/documentation_images_blender.py +++ b/demo/documentation_images_blender.py @@ -14,8 +14,26 @@ from tessagon.adaptors.blender_adaptor import BlenderAdaptor def main(): + classes = [HexTessagon, + SquareTessagon, + TriTessagon, + DissectedSquareTessagon, + FloretTessagon, + RhombusTessagon, + OctoTessagon, + HexTriTessagon, + HexSquareTriTessagon, + PythagoreanTessagon, + BrickTessagon, + DodecaTessagon, + ZigZagTessagon, + SquareTriTessagon, + WeaveTessagon, + HexBigTriTessagon] setup_render_scene() - render_tessagons() + render_tessagons(classes) + setup_thumbnail_scene() + render_thumbnails(classes) def setup_render_scene(): scn = bpy.context.scene @@ -73,57 +91,40 @@ def setup_render_scene(): scn.world.horizon_color = [1, 1, 1] +def setup_thumbnail_scene(): + scn = bpy.context.scene + set_layer(scn) + scn.render.resolution_x = 100 + scn.render.resolution_y = 75 + camera = bpy.data.objects['Camera'] + camera.location = [0, -17, 0] + camera.rotation_euler = [pi/2, 0, 0] + camera.data.lens = 120.0 + def set_layer(thing, layer = 1): thing.layers[layer] = True for i in range(20): if i != layer: thing.layers[i] = False -def render_tessagons(): - render_object('HexTessagon') - render_object('HexTessagonColor1') - render_object('HexTessagonColor2') - - render_object('TriTessagon') - render_object('TriTessagonColor1') - render_object('TriTessagonColor2') - render_object('TriTessagonColor3') - - render_object('DissectedSquareTessagon') - render_object('DissectedSquareTessagonColor1') - render_object('DissectedSquareTessagonColor2') - - render_object('FloretTessagon') - render_object('FloretTessagonColor1') - render_object('FloretTessagonColor2') - render_object('FloretTessagonColor3') - - render_object('SquareTessagon') - render_object('SquareTessagonColor1') - render_object('SquareTessagonColor2') - render_object('SquareTessagonColor3') - render_object('SquareTessagonColor4') - render_object('SquareTessagonColor5') - render_object('SquareTessagonColor6') - render_object('SquareTessagonColor7') - render_object('SquareTessagonColor8') - - render_object('RhombusTessagon') - render_object('OctoTessagon') - render_object('HexTriTessagon') - render_object('HexSquareTriTessagon') - - render_object('PythagoreanTessagon') - render_object('BrickTessagon') - render_object('DodecaTessagon') - render_object('ZigZagTessagon') - - render_object('SquareTriTessagon') - render_object('WeaveTessagon') - render_object('HexBigTriTessagon') +def render_tessagons(classes): + for cls in classes: + render_class(cls) render_object(['HexTorusIn','WireTorusOut'], filename='wire_skin.png', mark_edges=False) +def render_thumbnails(classes): + for cls in classes: + render_class(cls, thumbnail = True) + +def render_class(cls, **kwargs): + class_name = cls.__name__ + render_object(class_name, **kwargs) + if kwargs.get('thumbnail'): return + for i in range(cls.num_color_patterns()): + object_name = "%sColor%d" % (class_name, i+1) + render_object(object_name, **kwargs) + def render_object(name, **kwargs): if isinstance(name, list): names = name @@ -140,6 +141,8 @@ def render_object(name, **kwargs): # Writing PNG to /tmp or DOCUMENTATION_IMAGES_DIR dir = os.getenv('DOCUMENTATION_IMAGES_DIR') or '/tmp' filename = kwargs.get('filename') or get_filename(names[0]) + if kwargs.get('thumbnail'): + filename += '_thumb' path = "%s/%s" % (dir, filename) print("Rendering and writing: %s" % path) @@ -162,7 +165,7 @@ def prepare_object_for_render(object, **kwargs): edge.use_freestyle_mark = True mesh.update() -def get_filename(name): +def get_filename(name, **kwargs): # Convert class name to camelcase s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() diff --git a/demo/tessagon_common_demo.py b/demo/tessagon_common_demo.py index 0baac5d..ef56e86 100644 --- a/demo/tessagon_common_demo.py +++ b/demo/tessagon_common_demo.py @@ -16,34 +16,38 @@ def create_objects(self): column = 0 # Color patterns self.hex_tessagon([column, 0, row]) - self.hex_tessagon([column, 0, row - offset], color_pattern=1) - self.hex_tessagon([column, 0, row - 2*offset], color_pattern=2) + for i in range(HexTessagon.num_color_patterns()): + color_pattern = i+1 + self.hex_tessagon([column, 0, row - color_pattern * offset], + color_pattern=color_pattern) column += offset + self.tri_tessagon([column, 0, row]) - self.tri_tessagon([column, 0, row - offset], color_pattern=1) - self.tri_tessagon([column, 0, row - 2*offset], color_pattern=2) - self.tri_tessagon([column, 0, row - 3*offset], color_pattern=3) + for i in range(TriTessagon.num_color_patterns()): + color_pattern = i+1 + self.tri_tessagon([column, 0, row - color_pattern * offset], + color_pattern=color_pattern) column += offset + self.dissected_square_tessagon([column, 0, row]) - self.dissected_square_tessagon([column, 0, row - offset], color_pattern=1) - self.dissected_square_tessagon([column, 0, row - 2*offset], - color_pattern=2) + for i in range(DissectedSquareTessagon.num_color_patterns()): + color_pattern = i+1 + self.dissected_square_tessagon([column, 0, row - color_pattern * offset], + color_pattern=color_pattern) column += offset - self.floret_tessagon([column, 0, row]) - self.floret_tessagon([column, 0, row - offset], color_pattern=1) - self.floret_tessagon([column, 0, row - 2*offset], color_pattern=2) - self.floret_tessagon([column, 0, row - 3*offset], color_pattern=3) + self.floret_tessagon([column, 0, row]) + for i in range(FloretTessagon.num_color_patterns()): + color_pattern = i+1 + self.floret_tessagon([column, 0, row - color_pattern * offset], + color_pattern=color_pattern) column += offset + self.square_tessagon([column, 0, row]) - self.square_tessagon([column, 0, row - offset], color_pattern=1) - self.square_tessagon([column, 0, row - 2*offset], color_pattern=2) - self.square_tessagon([column, 0, row - 3*offset], color_pattern=3) - self.square_tessagon([column, 0, row - 4*offset], color_pattern=4) - self.square_tessagon([column, 0, row - 5*offset], color_pattern=5) - self.square_tessagon([column, 0, row - 6*offset], color_pattern=6) - self.square_tessagon([column, 0, row - 7*offset], color_pattern=7) - self.square_tessagon([column, 0, row - 8*offset], color_pattern=8) + for i in range(SquareTessagon.num_color_patterns()): + color_pattern = i+1 + self.square_tessagon([column, 0, row - color_pattern * offset], + color_pattern=color_pattern) # Non-colored objects column += offset diff --git a/documentation/brick_tessagon.md b/documentation/brick_tessagon.md new file mode 100644 index 0000000..59b4ca0 --- /dev/null +++ b/documentation/brick_tessagon.md @@ -0,0 +1,3 @@ +# `BrickTessagon` + +![BrickTessagon](images/brick_tessagon.png) diff --git a/documentation/dissected_square_tessagon.md b/documentation/dissected_square_tessagon.md new file mode 100644 index 0000000..b76e636 --- /dev/null +++ b/documentation/dissected_square_tessagon.md @@ -0,0 +1,11 @@ +# `DissectedSquareTessagon` + +![DissectedSquareTessagon](images/dissected_square_tessagon.png) + +Option `color_pattern=1` gives the following pattern: + +![DissectedSquareTessagon color pattern 1](images/dissected_square_tessagon_color1.png) + +Option `color_pattern=2` gives the following pattern: + +![DissectedSquareTessagon color pattern 2](images/dissected_square_tessagon_color2.png) diff --git a/documentation/dodeca_tessagon.md b/documentation/dodeca_tessagon.md new file mode 100644 index 0000000..fc6b524 --- /dev/null +++ b/documentation/dodeca_tessagon.md @@ -0,0 +1,3 @@ +# `DodecaTessagon` + +![DodecaTessagon](images/dodeca_tessagon.png) diff --git a/documentation/floret_tessagon.md b/documentation/floret_tessagon.md new file mode 100644 index 0000000..a105915 --- /dev/null +++ b/documentation/floret_tessagon.md @@ -0,0 +1,15 @@ +# `FloretTessagon` + +![FloretTessagon](images/floret_tessagon.png) + +Option `color_pattern=1` gives the following pattern: + +![FloretTessagon color pattern 1](images/floret_tessagon_color1.png) + +Option `color_pattern=2` gives the following pattern: + +![FloretTessagon color pattern 2](images/floret_tessagon_color2.png) + +Option `color_pattern=3` gives the following pattern: + +![FloretTessagon color pattern 3](images/floret_tessagon_color3.png) diff --git a/documentation/hex_big_tri_tessagon.md b/documentation/hex_big_tri_tessagon.md new file mode 100644 index 0000000..9952158 --- /dev/null +++ b/documentation/hex_big_tri_tessagon.md @@ -0,0 +1,5 @@ +# `HexBigTriTessagon` + +![HexBigTriTessagon](images/hex_big_tri_tessagon.png) + +(Naming things is hard.) diff --git a/documentation/hex_square_tri_tessagon.md b/documentation/hex_square_tri_tessagon.md new file mode 100644 index 0000000..c8c26cb --- /dev/null +++ b/documentation/hex_square_tri_tessagon.md @@ -0,0 +1,3 @@ +# `HexSquareTriTessagon` + +![HexSquareTriTessagon](images/hex_square_tri_tessagon.png) diff --git a/documentation/hex_tessagon.md b/documentation/hex_tessagon.md new file mode 100644 index 0000000..0d4eef4 --- /dev/null +++ b/documentation/hex_tessagon.md @@ -0,0 +1,11 @@ +# `HexTessagon` + +![HexTessagon](images/hex_tessagon.png) + +Option `color_pattern=1` gives the following pattern: + +![HexTessagon color pattern 1](images/hex_tessagon_color1.png) + +Option `color_pattern=2` gives the following pattern: + +![HexTessagon color pattern 2](images/hex_tessagon_color2.png) diff --git a/documentation/hex_tri_tessagon.md b/documentation/hex_tri_tessagon.md new file mode 100644 index 0000000..fb1e7f9 --- /dev/null +++ b/documentation/hex_tri_tessagon.md @@ -0,0 +1,3 @@ +# `HexTriTessagon` + +![HexTriTessagon](images/hex_tri_tessagon.png) diff --git a/documentation/images/brick_tessagon_thumb.png b/documentation/images/brick_tessagon_thumb.png new file mode 100644 index 0000000..87d2e69 Binary files /dev/null and b/documentation/images/brick_tessagon_thumb.png differ diff --git a/documentation/images/dissected_square_tessagon_thumb.png b/documentation/images/dissected_square_tessagon_thumb.png new file mode 100644 index 0000000..c42b3fd Binary files /dev/null and b/documentation/images/dissected_square_tessagon_thumb.png differ diff --git a/documentation/images/dodeca_tessagon_thumb.png b/documentation/images/dodeca_tessagon_thumb.png new file mode 100644 index 0000000..6187701 Binary files /dev/null and b/documentation/images/dodeca_tessagon_thumb.png differ diff --git a/documentation/images/floret_tessagon_thumb.png b/documentation/images/floret_tessagon_thumb.png new file mode 100644 index 0000000..7a191b4 Binary files /dev/null and b/documentation/images/floret_tessagon_thumb.png differ diff --git a/documentation/images/hex_big_tri_tessagon_thumb.png b/documentation/images/hex_big_tri_tessagon_thumb.png new file mode 100644 index 0000000..921cae3 Binary files /dev/null and b/documentation/images/hex_big_tri_tessagon_thumb.png differ diff --git a/documentation/images/hex_square_tri_tessagon_thumb.png b/documentation/images/hex_square_tri_tessagon_thumb.png new file mode 100644 index 0000000..3d8b56a Binary files /dev/null and b/documentation/images/hex_square_tri_tessagon_thumb.png differ diff --git a/documentation/images/hex_tessagon_thumb.png b/documentation/images/hex_tessagon_thumb.png new file mode 100644 index 0000000..be27e5e Binary files /dev/null and b/documentation/images/hex_tessagon_thumb.png differ diff --git a/documentation/images/hex_tri_tessagon_thumb.png b/documentation/images/hex_tri_tessagon_thumb.png new file mode 100644 index 0000000..d83356b Binary files /dev/null and b/documentation/images/hex_tri_tessagon_thumb.png differ diff --git a/documentation/images/octo_tessagon_thumb.png b/documentation/images/octo_tessagon_thumb.png new file mode 100644 index 0000000..6f08481 Binary files /dev/null and b/documentation/images/octo_tessagon_thumb.png differ diff --git a/documentation/images/pythagorean_tessagon_thumb.png b/documentation/images/pythagorean_tessagon_thumb.png new file mode 100644 index 0000000..cc4bdd2 Binary files /dev/null and b/documentation/images/pythagorean_tessagon_thumb.png differ diff --git a/documentation/images/rhombus_tessagon_thumb.png b/documentation/images/rhombus_tessagon_thumb.png new file mode 100644 index 0000000..1a42cbd Binary files /dev/null and b/documentation/images/rhombus_tessagon_thumb.png differ diff --git a/documentation/images/square_tessagon_thumb.png b/documentation/images/square_tessagon_thumb.png new file mode 100644 index 0000000..49e812c Binary files /dev/null and b/documentation/images/square_tessagon_thumb.png differ diff --git a/documentation/images/square_tri_tessagon_thumb.png b/documentation/images/square_tri_tessagon_thumb.png new file mode 100644 index 0000000..0660abc Binary files /dev/null and b/documentation/images/square_tri_tessagon_thumb.png differ diff --git a/documentation/images/tri_tessagon_thumb.png b/documentation/images/tri_tessagon_thumb.png new file mode 100644 index 0000000..29c8318 Binary files /dev/null and b/documentation/images/tri_tessagon_thumb.png differ diff --git a/documentation/images/weave_tessagon_thumb.png b/documentation/images/weave_tessagon_thumb.png new file mode 100644 index 0000000..8fadaff Binary files /dev/null and b/documentation/images/weave_tessagon_thumb.png differ diff --git a/documentation/images/zig_zag_tessagon_thumb.png b/documentation/images/zig_zag_tessagon_thumb.png new file mode 100644 index 0000000..f7b9c0b Binary files /dev/null and b/documentation/images/zig_zag_tessagon_thumb.png differ diff --git a/documentation/octo_tessagon.md b/documentation/octo_tessagon.md new file mode 100644 index 0000000..d1a7765 --- /dev/null +++ b/documentation/octo_tessagon.md @@ -0,0 +1,3 @@ +# `OctoTessagon` + +![OctoTessagon](images/octo_tessagon.png) diff --git a/documentation/pythagorean_tessagon.md b/documentation/pythagorean_tessagon.md new file mode 100644 index 0000000..ab5c35c --- /dev/null +++ b/documentation/pythagorean_tessagon.md @@ -0,0 +1,3 @@ +# `PythagoreanTessagon` + +![PythagoreanTessagon](images/pythagorean_tessagon.png) diff --git a/documentation/rhombus_tessagon.md b/documentation/rhombus_tessagon.md new file mode 100644 index 0000000..89eff5e --- /dev/null +++ b/documentation/rhombus_tessagon.md @@ -0,0 +1,3 @@ +# `RhombusTessagon` + +![RhombusTessagon](images/rhombus_tessagon.png) diff --git a/documentation/square_tessagon.md b/documentation/square_tessagon.md new file mode 100644 index 0000000..3949113 --- /dev/null +++ b/documentation/square_tessagon.md @@ -0,0 +1,35 @@ +# `SquareTessagon` + +![SquareTessagon](images/square_tessagon.png) + +Option `color_pattern=1` gives the following pattern: + +![SquareTessagon color pattern 1](images/square_tessagon_color1.png) + +Option `color_pattern=2` gives the following pattern: + +![SquareTessagon color pattern 2](images/square_tessagon_color2.png) + +Option `color_pattern=3` gives the following pattern: + +![SquareTessagon color pattern 3](images/square_tessagon_color3.png) + +Option `color_pattern=4` gives the following pattern: + +![SquareTessagon color pattern 4](images/square_tessagon_color4.png) + +Option `color_pattern=5` gives the following pattern: + +![SquareTessagon color pattern 5](images/square_tessagon_color5.png) + +Option `color_pattern=6` gives the following pattern: + +![SquareTessagon color pattern 6](images/square_tessagon_color6.png) + +Option `color_pattern=7` gives the following pattern: + +![SquareTessagon color pattern 7](images/square_tessagon_color7.png) + +Option `color_pattern=8` gives the following pattern: + +![SquareTessagon color pattern 8](images/square_tessagon_color8.png) diff --git a/documentation/square_tri_tessagon.md b/documentation/square_tri_tessagon.md new file mode 100644 index 0000000..19759db --- /dev/null +++ b/documentation/square_tri_tessagon.md @@ -0,0 +1,3 @@ +# `SquareTriTessagon` + +![SquareTriTessagon](images/square_tri_tessagon.png) diff --git a/documentation/tri_tessagon.md b/documentation/tri_tessagon.md new file mode 100644 index 0000000..b534909 --- /dev/null +++ b/documentation/tri_tessagon.md @@ -0,0 +1,15 @@ +### `TriTessagon` + +![TriTessagon](images/tri_tessagon.png) + +Option `color_pattern=1` gives the following pattern: + +![TriTessagon color pattern 1](images/tri_tessagon_color1.png) + +Option `color_pattern=2` gives the following pattern: + +![TriTessagon color pattern 2](images/tri_tessagon_color2.png) + +Option `color_pattern=3` gives the following pattern: + +![TriTessagon color pattern 3](images/tri_tessagon_color3.png) diff --git a/documentation/weave_tessagon.md b/documentation/weave_tessagon.md new file mode 100644 index 0000000..13bc0e0 --- /dev/null +++ b/documentation/weave_tessagon.md @@ -0,0 +1,3 @@ +# `WeaveTessagon` + +![WeaveTessagon](images/weave_tessagon.png) diff --git a/documentation/zig_zag_tessagon.md b/documentation/zig_zag_tessagon.md new file mode 100644 index 0000000..1b6d475 --- /dev/null +++ b/documentation/zig_zag_tessagon.md @@ -0,0 +1,3 @@ +# `ZigZagTessagon` + +![ZigZagTessagon](images/zig_zag_tessagon.png) diff --git a/types/brick_tessagon.py b/types/brick_tessagon.py index 5af6e3d..67f4f84 100644 --- a/types/brick_tessagon.py +++ b/types/brick_tessagon.py @@ -53,5 +53,4 @@ def calculate_faces(self): [['bottom'], ['right', 'middle']]], v_boundary=True) class BrickTessagon(Tessagon): - def init_tile_class(self): - return BrickTile + tile_class = BrickTile diff --git a/types/dissected_square_tessagon.py b/types/dissected_square_tessagon.py index 8c0521e..9b6d5fb 100644 --- a/types/dissected_square_tessagon.py +++ b/types/dissected_square_tessagon.py @@ -3,6 +3,8 @@ class DissectedSquareTile(Tile): + num_color_patterns = 2 + # VERTS: a = ['top', 'left'] # a---b---c b = ['top', 'center'] # ^ |\..|../| c = ['top', 'right'] @@ -65,12 +67,6 @@ def calculate_faces(self): ['middle', 'center'], ['top', 'center']]) - def calculate_colors(self): - if self.color_pattern == 1: - self.color_pattern1() - elif self.color_pattern == 2: - self.color_pattern2() - def color_pattern1(self): self.color_paths([['top', 'left', 'center'], ['top', 'right', 'middle'], @@ -105,5 +101,4 @@ def color_tiles(self, color1, color2): color2, color1) class DissectedSquareTessagon(Tessagon): - def init_tile_class(self): - return DissectedSquareTile + tile_class = DissectedSquareTile diff --git a/types/dodeca_tessagon.py b/types/dodeca_tessagon.py index 0f75e06..fb23c3c 100644 --- a/types/dodeca_tessagon.py +++ b/types/dodeca_tessagon.py @@ -187,5 +187,4 @@ def calculate_faces(self): face_type='hexagon', u_boundary=True) class DodecaTessagon(Tessagon): - def init_tile_class(self): - return DodecaTile + tile_class = DodecaTile diff --git a/types/floret_tessagon.py b/types/floret_tessagon.py index 3494d50..dc21c8f 100644 --- a/types/floret_tessagon.py +++ b/types/floret_tessagon.py @@ -77,17 +77,11 @@ def calculate_faces(self): self.faces[i] = self.tile.mesh_adaptor.create_face(verts) class FloretTile(Stamp14Tile): + num_color_patterns = 3 + def __init__(self, tessagon, **kwargs): super().__init__(tessagon, Floret, **kwargs) - def calculate_colors(self): - if self.color_pattern == 1: - self.color_pattern1() - elif self.color_pattern == 2: - self.color_pattern2() - elif self.color_pattern == 3: - self.color_pattern3() - def color_pattern1(self): for i in range(14): if not self.stamps[i]: continue @@ -117,13 +111,12 @@ def color_pattern3(self): stamp.color_stamp(2) class FloretTessagon(Stamp14Tessagon): + tile_class = FloretTile + def __init__(self, **kwargs): super().__init__(**kwargs) self.vert_types = { 'center': [], 'edge_to_center': [], 'other': [] } - def init_tile_class(self): - return FloretTile - def _calculate_colors(self): self.mesh_adaptor.initialize_colors() if self.color_pattern == 3: diff --git a/types/hex_big_tri_tessagon.py b/types/hex_big_tri_tessagon.py index a11b339..4aff1ad 100644 --- a/types/hex_big_tri_tessagon.py +++ b/types/hex_big_tri_tessagon.py @@ -102,5 +102,4 @@ def __init__(self, tessagon, **kwargs): super().__init__(tessagon, Thingy, **kwargs) class HexBigTriTessagon(Stamp14Tessagon): - def init_tile_class(self): - return HexBigTriTile + tile_class = HexBigTriTile diff --git a/types/hex_square_tri_tessagon.py b/types/hex_square_tri_tessagon.py index c0928f4..72c4f54 100644 --- a/types/hex_square_tri_tessagon.py +++ b/types/hex_square_tri_tessagon.py @@ -141,5 +141,4 @@ def calculate_faces(self): face_type='hexagon', corner=True) class HexSquareTriTessagon(Tessagon): - def init_tile_class(self): - return HexSquareTriTile + tile_class = HexSquareTriTile diff --git a/types/hex_tessagon.py b/types/hex_tessagon.py index 8fc7000..7449c7f 100644 --- a/types/hex_tessagon.py +++ b/types/hex_tessagon.py @@ -2,6 +2,7 @@ from tessagon.core.tile import Tile class HexTile(Tile): + num_color_patterns = 2 # VERTS: # ..|.. @@ -88,12 +89,6 @@ def calculate_faces(self): # neighboring tiles. corner=True) - def calculate_colors(self): - if self.color_pattern == 1: - self.color_pattern1() - elif self.color_pattern == 2: - self.color_pattern2() - def color_pattern1(self): if self.fingerprint[0] % 3 == 0: self.color_paths([['top', 'left'], @@ -120,5 +115,4 @@ def color_pattern2(self): ['bottom', 'right']]}, 0) class HexTessagon(Tessagon): - def init_tile_class(self): - return HexTile + tile_class = HexTile diff --git a/types/hex_tri_tessagon.py b/types/hex_tri_tessagon.py index 6e1b15e..e517649 100644 --- a/types/hex_tri_tessagon.py +++ b/types/hex_tri_tessagon.py @@ -82,5 +82,4 @@ def calculate_faces(self): face_type='hexagon', corner=True) class HexTriTessagon(Tessagon): - def init_tile_class(self): - return HexTriTile + tile_class = HexTriTile diff --git a/types/octo_tessagon.py b/types/octo_tessagon.py index aa42fd6..240fe94 100644 --- a/types/octo_tessagon.py +++ b/types/octo_tessagon.py @@ -61,5 +61,4 @@ def calculate_faces(self): corner=True) class OctoTessagon(Tessagon): - def init_tile_class(self): - return OctoTile + tile_class = OctoTile diff --git a/types/pythagorean_tessagon.py b/types/pythagorean_tessagon.py index 7a5df70..cf828cc 100644 --- a/types/pythagorean_tessagon.py +++ b/types/pythagorean_tessagon.py @@ -163,5 +163,4 @@ def calculate_faces(self): [5,1]]) class PythagoreanTessagon(Tessagon): - def init_tile_class(self): - return PythagoreanTile + tile_class = PythagoreanTile diff --git a/types/rhombus_tessagon.py b/types/rhombus_tessagon.py index 54a7ae0..57e7ec7 100644 --- a/types/rhombus_tessagon.py +++ b/types/rhombus_tessagon.py @@ -63,5 +63,4 @@ def calculate_faces(self): face_type='horizontal', corner=True) class RhombusTessagon(Tessagon): - def init_tile_class(self): - return RhombusTile + tile_class = RhombusTile diff --git a/types/square_tessagon.py b/types/square_tessagon.py index 97a275d..477484b 100644 --- a/types/square_tessagon.py +++ b/types/square_tessagon.py @@ -2,6 +2,8 @@ from tessagon.core.tile import Tile class SquareTile(Tile): + num_color_patterns = 8 + def __init__(self, tessagon, **kwargs): super().__init__(tessagon, **kwargs) self.u_symmetric = True @@ -26,24 +28,6 @@ def calculate_faces(self): ['bottom', 'right'], ['bottom', 'left']]) - def calculate_colors(self): - if self.color_pattern == 1: - self.color_pattern1() - elif self.color_pattern == 2: - self.color_pattern2() - elif self.color_pattern == 3: - self.color_pattern3() - elif self.color_pattern == 4: - self.color_pattern4() - elif self.color_pattern == 5: - self.color_pattern5() - elif self.color_pattern == 6: - self.color_pattern6() - elif self.color_pattern == 7: - self.color_pattern7() - elif self.color_pattern == 8: - self.color_pattern8() - def color_pattern1(self): if (self.fingerprint[0] + self.fingerprint[1]) % 2 == 0: self.color_face(['middle'], 0) @@ -110,5 +94,4 @@ def color_pattern8(self): self.color_face(['middle'], 3) class SquareTessagon(Tessagon): - def init_tile_class(self): - return SquareTile + tile_class = SquareTile diff --git a/types/square_tri_tessagon.py b/types/square_tri_tessagon.py index 487cab5..1bebd34 100644 --- a/types/square_tri_tessagon.py +++ b/types/square_tri_tessagon.py @@ -116,5 +116,4 @@ def calculate_faces(self): face_type='triangle') class SquareTriTessagon(Tessagon): - def init_tile_class(self): - return SquareTriTile + tile_class = SquareTriTile diff --git a/types/tri_tessagon.py b/types/tri_tessagon.py index e469e52..ccfe521 100644 --- a/types/tri_tessagon.py +++ b/types/tri_tessagon.py @@ -2,6 +2,8 @@ from tessagon.core.tessagon import Tessagon class TriTile(Tile): + num_color_patterns = 3 + # ^ 0.|.1 This is the topology of the tile. # | |\|/| (Not a Dead Kennedy's logo ...). # | |.2.| @@ -43,14 +45,6 @@ def calculate_faces(self): ['left', 'bottom'], ['middle']]) - def calculate_colors(self): - if self.color_pattern == 1: - self.color_pattern1() - elif self.color_pattern == 2: - self.color_pattern2() - elif self.color_pattern == 3: - self.color_pattern3() - def color_pattern1(self): # two colors for triangles pointing in different directions self.color_face(['left', 'top'], 0) @@ -165,5 +159,4 @@ def color_2_2(self): class TriTessagon(Tessagon): - def init_tile_class(self): - return TriTile + tile_class = TriTile diff --git a/types/weave_tessagon.py b/types/weave_tessagon.py index b368603..c3b5d8b 100644 --- a/types/weave_tessagon.py +++ b/types/weave_tessagon.py @@ -133,5 +133,4 @@ def calculate_faces(self): face_type='oct', v_boundary=True) class WeaveTessagon(Tessagon): - def init_tile_class(self): - return WeaveTile + tile_class = WeaveTile diff --git a/types/zig_zag_tessagon.py b/types/zig_zag_tessagon.py index b24a683..a3837ac 100644 --- a/types/zig_zag_tessagon.py +++ b/types/zig_zag_tessagon.py @@ -142,5 +142,4 @@ def calculate_faces(self): self.set_equivalent_face(['bottom'], 3, face) class ZigZagTessagon(Tessagon): - def init_tile_class(self): - return ZigZagTile + tile_class = ZigZagTile