-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetimages.py
More file actions
104 lines (91 loc) · 3.98 KB
/
getimages.py
File metadata and controls
104 lines (91 loc) · 3.98 KB
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
from PIL import Image
import math
import os
def transPNG(srcImageName):
img = Image.open(srcImageName)
img = img.convert("RGBA")
datas = img.getdata()
newData = list()
for item in datas:
newData.append(item)
img.putdata(newData)
return img
def mix(img1,img2,coordinator):
im = img1
mark = img2
layer = Image.new('RGBA', im.size, (0, 0, 0, 0))
layer.paste(mark, coordinator)
out = Image.composite(layer, im, layer)
return out
def writein(location,color,time,room):
file = Image.open(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'data', 'images', str(room) + "/" + str(time-1)+'.png')))
x = int(ord(location[0])-96)
y = int(location[1:])
interval = 42
lox = 305 + interval * (x - 8)
loy = 304 + interval * (y - 8)
location = (loy, lox)
if color == 1:
chess = transPNG(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'data', 'images', 'black.png')))
elif color == 2:
chess = transPNG(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'data', 'images', 'white.png')))
file = mix(file, chess, location)
roomdata = os.path.abspath(os.path.join(os.path.dirname(__file__), 'gochess', str(room) + '.txt'))
with open(file=roomdata, mode='r', encoding="utf-8") as data:
people = data.readline()
rounds = data.readline()
qqblack = int(data.readline())
qqwhite = int(data.readline())
if time != 1 :
qqdata = os.path.abspath(os.path.join(os.path.dirname(__file__), 'gochess'))
if time % 2 == 1:
qqdata = qqdata + "\\" + str(qqwhite) + '.txt'
elif time % 2 == 0:
qqdata = qqdata + "\\" + str(qqblack) + '.txt'
with open(file=qqdata, mode='r', encoding="utf-8") as data:
lastnx = data.readline()
lastnx = lastnx.strip()
lastx = int(ord(lastnx)-96)
lasty = int(data.readline())
lox = 305 + interval * (lastx - 8)
loy = 304 + interval * (lasty - 8)
location = (loy, lox)
if color == 1:
chess = transPNG(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'data', 'images', 'whitelast.png')))
elif color == 2:
chess = transPNG(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'data', 'images', 'blacklast.png')))
file = mix(file, chess, location)
file.save(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'data', 'images', str(room) + "/" + str(time)+'.png')))
file.save(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'data', 'images', str(room) + "_" + str(time)+'.png')))
def start(room):
os.mkdir(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'data', 'images', str(room))))
file = Image.open(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'data', 'images', 'Board.jpg')))
os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'data', 'images', str(room) + "_0.png"))
file.save(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'data', 'images', str(room) + "/0.png")))
file.save(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'data', 'images', str(room) + "_0.png")))
def getadd(rounds):
r = int(rounds)
if r >= 0 and r < 9:
return "0"
if r >= 9 and r < 15:
return "50.0"
if r >= 15 and r < 21:
return "40.0"
if r >= 21 and r < 27:
return "30.0"
if r >= 27 and r < 33:
return "25.0"
if r >= 33 and r < 39:
return "20.0"
if r >= 39 and r < 51:
return "15.0"
if r >= 51 and r < 100:
return "10.0"
if r >= 100 and r < 150:
return "30.0"
if r >= 150 and r < 200:
return "100.0"
if r >= 200 and r< 225:
return "200.0"
if r == 225:
return "500.0"