Skip to content

Commit

Permalink
Documentation refactor (#2)
Browse files Browse the repository at this point in the history
* Moving the documentation of all Tessagon classes to own file.
* Make the tile class a class property for each Tessagon class
* Make the color pattern stuff more automatic and allow Tessagon
  classes to inspect how many color patterns there are.
* Let tessagon demo figure out how many color patterns to draw.
* Let documentation image script figure out what it needs to render.
* Modify the documentation images script to create thumbnails.
* Adding thumbnails for all classes to documentation
* List how many color patterns each class has in README
  • Loading branch information
cwant committed Jan 19, 2018
1 parent ee7833a commit 386db10
Show file tree
Hide file tree
Showing 55 changed files with 286 additions and 303 deletions.
199 changes: 46 additions & 153 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion core/grid_tile_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
3 changes: 2 additions & 1 deletion core/rotate_tile_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 6 additions & 2 deletions core/tessagon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down
15 changes: 12 additions & 3 deletions core/tile.py
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Loading

0 comments on commit 386db10

Please sign in to comment.