-
Notifications
You must be signed in to change notification settings - Fork 1
/
frieze.py
50 lines (47 loc) · 1.82 KB
/
frieze.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import Tkinter
def repeat(cw, ch, r, s, (x, y)):
# canvas width, canvas height, width:height ratio of cell,
# symmetry type, (x,y) of mouse
coords = []
if s == 0: # pmm2
x %= int(ch * r)
coords = [(x, y)]
coords += [(x, ch - y - 1)]
coords += [(int(ch * r - i[0] - 1), i[1]) for i in coords[-2:]]
for j in range(int(float(cw)/(ch*r))):
coords += [(int(i[0] + ch * r), i[1]) for i in coords[-4:]]
elif s == 1: # pma2
x %= int(ch * r)
coords = [(x, y)]
coords += [(int(ch * r - x - 1), ch - y - 1)]
for j in range(int(float(cw)/(ch*r))):
coords += [(int(ch * r + i[0]), ch - i[1] - 1) for i in coords[-2:]]
elif s == 2: # p112
x %= int(ch * r)
coords = [(x, y)]
coords += [(int(2 * ch * r - x) - 1, int(ch - y) - 1)]
for j in range(int(float(cw)/(ch*r))):
coords += [(int(i[0] + 2 * ch * r), i[1]) for i in coords[-2:]]
elif s == 3: # p1m1
x %= int(0.5 * ch * r)
coords = [(x, y)]
coords += [(x, ch - y - 1)]
for j in range(int(2*float(cw)/(ch*r))):
coords += [(int(i[0] + 0.5 * ch * r), i[1]) for i in coords[-2:]]
elif s==4: # pm11
x %= int(ch * r)
coords = [(x, y)]
coords += [(int(2*ch*r-x)-1, y)]
for j in range(int(float(cw)/(ch*r))):
coords += [(int(i[0] + 2* ch * r), i[1]) for i in coords[-2:]]
elif s==5: # p111
x %= int(ch * r)
coords = [(x, y)]
for j in range(int(float(cw)/(ch*r))):
coords += [(coords[-1][0]+int(ch*r), coords[-1][1])]
elif s==6: # p1a1
x %= int(ch * r)
coords = [(x, y)]
for j in range(int(float(cw)/(ch*r))):
coords += [(coords[-1][0]+int(ch*r), ch-coords[-1][1]-1)]
return coords