-
Notifications
You must be signed in to change notification settings - Fork 1
/
wallpaper_patterns.py
127 lines (106 loc) · 4.21 KB
/
wallpaper_patterns.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import Tkinter
from math import *
# routines to calculate for each point in canvas, the corresponding points
# in the whole wallpaper
def repeat_wallpaper(cw, ch, cell_w,cell_h, s, (x, y)):
# canvas width, canvas height, width:height ratio of cell,
# symmetry type, (x,y) of mouse
coords = []
if s == 0: # p1
if y%(2*cell_h)<cell_h:
x = x%int(cell_w)-int(0.5*cell_w)
else:
x = x%int(cell_w)
y %= int(cell_h)
coords = [(x, y)]
for j in range(cw/cell_w+1):
coords += [(int(i[0] + cell_w), i[1]) for i in coords[-1:]]
count=int(ceil(float(ch)/cell_h))
coords1 = []
for i in range(count):
if(i%2==0):
coords1 +=[(e[0]-int(0.5*cell_w),int(e[1]+(cell_h*i))) for e in coords]
if(i%2==1):
coords1 +=[(e[0],int(e[1]+(cell_h*i))) for e in coords]
if s == 1: # cm
if y%(2*cell_h)<cell_h:
x = x%int(cell_w)-int(0.5*cell_w)
else:
x = x%int(cell_w)
y %= int(cell_h)
coords = [(x, y)]
coords += [(cell_w-x-1, y)]
for j in range(cw/cell_w+2):
coords += [(int(i[0] + cell_w), i[1]) for i in coords[-2:]]
count=int(ceil(float(ch)/cell_h))
coords1 = []
for i in range(count):
if(i%2==0):
coords1 +=[(e[0]-int(0.5*cell_w),int(e[1]+(cell_h*i))) for e in coords]
if(i%2==1):
coords1 +=[(e[0]-cell_w,int(e[1]+(cell_h*i))) for e in coords]
if s == 2: # p2
if y%(2*cell_h)<cell_h:
x = (x%int(cell_w)-int(0.5*cell_w))%cell_w
else:
x = x%int(cell_w)
y %= int(cell_h)
coords = [(x, y)]
coords += [(int( cell_w - i[0] - 1), int(cell_h - i[1] -1)) for i in coords[-1:]]
for j in range(cw/cell_w+1):
coords += [(int(i[0] + cell_w), i[1]) for i in coords[-2:]]
count=int(ceil(float(ch)/cell_h))
coords1 = []
for i in range(count):
if(i%2==0):
coords1 +=[(e[0]-int(0.5*cell_w),int(e[1]+(cell_h*i))) for e in coords]
if(i%2==1):
coords1 +=[(e[0],int(e[1]+(cell_h*i))) for e in coords]
if s == 3: # pmm
x = x%int(2*cell_w)
y = y%int(2*cell_h)
coords = [(x, y)]
coords += [(x, 2*cell_h - y - 1)]
coords += [(int(2*cell_w - i[0] - 1), i[1]) for i in coords[-2:]]
for j in range(cw/cell_w/2+1):
coords += [(int(i[0] + 2*cell_w), i[1]) for i in coords[-4:]]
count=int(ceil(float(ch)/cell_h))
coords1 = []
for i in range(count):
coords1 +=[(e[0],int(e[1]+(2*cell_h*i))) for e in coords]
if s == 4: # pm
x = x%int(2*cell_w)
y = y%int(cell_h)
coords = [(x, y)]
coords += [(int( 2*cell_w - i[0] - 1), i[1]) for i in coords[-1:]]
for j in range(cw/cell_w/2+1):
coords += [(int(i[0] + 2*cell_w), i[1]) for i in coords[-2:]]
count=int(ceil(float(ch)/cell_h))
coords1 = []
for i in range(count):
coords1 +=[(e[0],int(e[1]+(cell_h*i))) for e in coords]
if s == 5: # pmg
x = x%int(2*cell_w)
y = y%int(cell_h)
coords = [(x, y)]
coords += [(int(cell_w - x - 1), cell_h - y - 1)]
for j in range(cw/cell_w+1):
coords += [(int(cell_w + i[0]), cell_h - i[1] - 1) for i in coords[-2:]]
count=int(ceil(float(ch)/cell_h))
coords1 = []
for i in range(count):
coords1 +=[(e[0],int(e[1]+(cell_h*i))) for e in coords]
if s == 6: #cmm
x = x%int(2*cell_w)
y = y%int(2*cell_h)
coords = [(x, y)]
coords += [(int( cell_w - i[0] - 1), int(cell_h - i[1] -1)) for i in coords[-1:]]
coords += [(i[0], int(2*cell_h - i[1] -1)) for i in coords[-2:]]
coords += [(int(2*cell_w - i[0] -1), i[1]) for i in coords[-4:]]
for j in range(cw/cell_w/2+1):
coords += [(int(i[0] + 2*cell_w), i[1]) for i in coords[-8:]]
count=int(ceil(float(ch)/cell_h))
coords1 = []
for i in range(count):
coords1 +=[(e[0],int(e[1]+(2*cell_h*i))) for e in coords]
return coords1