-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimages.py
More file actions
42 lines (36 loc) · 1.15 KB
/
images.py
File metadata and controls
42 lines (36 loc) · 1.15 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
from PIL import Image
import math
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):
file = Image.open('D:/go-cqhttp_windows_amd64/data/images/123456/'+ str(time-1)+'.png')
last = Image.open('last.png')
x = int(ord(location[0])-64)
y = int(location[1:])
interval = 42
lox = 305 + interval * (x - 8)
loy = 304 + interval * (y - 8)
location = (loy, lox)
lastlo = (loy + 7, lox + 7)
if color == 1:
chess = transPNG('black.png')
elif color == -1:
chess = transPNG('white.png')
file = mix(file, chess, location)
file = mix(file, last, lastlo)
file.save('D:/go-cqhttp_windows_amd64/data/images/123456/'+str(time)+'.png')
writein("H7",1,3)