Skip to content

Commit

Permalink
Eight color patterns (from Grünbaum & Shephard) for SquareTessagon.
Browse files Browse the repository at this point in the history
  • Loading branch information
cwant committed Jan 19, 2018
1 parent 35e4d46 commit ee7833a
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 17 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,38 @@ Option `color_pattern=3` gives the following pattern:
### `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`
Expand Down
13 changes: 11 additions & 2 deletions demo/documentation_images_blender.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,29 @@ def render_tessagons():
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('SquareTessagon')
render_object('PythagoreanTessagon')
render_object('BrickTessagon')
render_object('DodecaTessagon')
render_object('ZigZagTessagon')

render_object('SquareTriTessagon')
render_object('WeaveTessagon')
render_object('HexBigTriTessagon')
render_object('ZigZagTessagon')

render_object(['HexTorusIn','WireTorusOut'],
filename='wire_skin.png', mark_edges=False)
Expand Down
39 changes: 24 additions & 15 deletions demo/tessagon_common_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ def create_objects(self):
self.floret_tessagon([column, 0, row - 2*offset], color_pattern=2)
self.floret_tessagon([column, 0, row - 3*offset], color_pattern=3)

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)

# Non-colored objects
column += offset
column += offset
Expand All @@ -50,13 +61,13 @@ def create_objects(self):
column = start_column
row -= offset
# Row 2
self.square_tessagon([column, 0, row])
column += offset
self.pythagorean_tessagon([column, 0, row])
column += offset
self.brick_tessagon([column, 0, row])
column += offset
self.dodeca_tessagon([column, 0, row])
column += offset
self.zig_zag_tessagon([column, 0, row])

column = start_column
row -= offset
Expand All @@ -66,8 +77,6 @@ def create_objects(self):
self.weave_tessagon([column, 0, row])
column += offset
self.hex_big_tri_tessagon([column, 0, row])
column += offset
self.zig_zag_tessagon([column, 0, row])

def hex_tessagon(self, position, **kwargs):
options = {
Expand All @@ -92,6 +101,17 @@ def tri_tessagon(self, position, **kwargs):
}
return self.tessellate(torus, TriTessagon, **{**kwargs, **options})

def square_tessagon(self, position, **kwargs):
options = {
'u_range': [0.0, 1.0],
'v_range': [0.0, 1.0],
'u_num': 24,
'v_num': 6,
'rot_factor': 2,
'position': position
}
return self.tessellate(torus, SquareTessagon, **{**kwargs, **options})

def rhombus_klein(self, u, v):
(x, y, z) = klein(u, v)
return (x, z, -y)
Expand Down Expand Up @@ -142,17 +162,6 @@ def hex_square_tri_tessagon(self, position):
}
return self.tessellate(torus, HexSquareTriTessagon, **options)

def square_tessagon(self, position):
options = {
'u_range': [0.0, 1.0],
'v_range': [0.0, 1.0],
'u_num': 15,
'v_num': 4,
'rot_factor': 2,
'position': position
}
return self.tessellate(torus, SquareTessagon, **options)

def pythagorean_tessagon(self, position):
options = {
'u_range': [0.0, 1.0],
Expand Down
Binary file modified documentation/images/square_tessagon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/images/square_tessagon_color1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/images/square_tessagon_color3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/images/square_tessagon_color4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/images/square_tessagon_color5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/images/square_tessagon_color6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/images/square_tessagon_color7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/images/square_tessagon_color8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions types/square_tessagon.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,89 @@ 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)
else:
self.color_face(['middle'], 1)

def color_pattern2(self):
if (self.fingerprint[0] + self.fingerprint[1]) % 2 == 0:
self.color_face(['middle'], 0)
elif self.fingerprint[0] % 2 == 0:
self.color_face(['middle'], 1)
else:
self.color_face(['middle'], 2)

def color_pattern3(self):
if (self.fingerprint[0] * self.fingerprint[1]) % 2 == 0:
self.color_face(['middle'], 0)
else:
self.color_face(['middle'], 1)

def color_pattern4(self):
if self.fingerprint[1] % 2 == 0:
self.color_face(['middle'], 0)
else:
if ((self.fingerprint[1] // 2) + self.fingerprint[0]) % 2 == 0:
self.color_face(['middle'], 0)
else:
self.color_face(['middle'], 1)

def color_pattern5(self):
if self.fingerprint[1] % 2 == 0:
self.color_face(['middle'], 0)
else:
self.color_face(['middle'], 1)

def color_pattern6(self):
if self.fingerprint[1] % 2 == 0:
self.color_face(['middle'], 0)
else:
if self.fingerprint[0] % 2 == 0:
self.color_face(['middle'], 1)
else:
self.color_face(['middle'], 2)

def color_pattern7(self):
if self.fingerprint[1] % 2 == 0:
self.color_face(['middle'], 0)
else:
if ((self.fingerprint[1] // 2) + self.fingerprint[0]) % 2 == 0:
self.color_face(['middle'], 1)
else:
self.color_face(['middle'], 2)

def color_pattern8(self):
if self.fingerprint[1] % 2 == 0:
if self.fingerprint[0] % 2 == 0:
self.color_face(['middle'], 0)
else:
self.color_face(['middle'], 1)
else:
if self.fingerprint[0] % 2 == 0:
self.color_face(['middle'], 2)
else:
self.color_face(['middle'], 3)

class SquareTessagon(Tessagon):
def init_tile_class(self):
return SquareTile

0 comments on commit ee7833a

Please sign in to comment.