forked from sahlberg/pop-fe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme_dotpainting.py
63 lines (51 loc) · 1.67 KB
/
theme_dotpainting.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
#!/usr/bin/env python
# coding: utf-8
#
# Auto theme for DOTPAINTING art
#
#
from PIL import Image, ImageDraw, ImageFont
import os
import sys
if sys.platform == 'win32':
font = 'arial.ttf'
else:
font = 'DejaVuSansMono.ttf'
def create_dotpainting_pic0(game_id, title):
p0 = Image.new("RGB", (250, 140), (0,0,0))
fnt = ImageFont.truetype(font, 12)
d = ImageDraw.Draw(p0)
off = 80
y = 1
t = '##############################'
ts = d.textsize(t, font=fnt)
d.text((off, y), t, font=fnt, fill=(255,128,128,255))
y = y + ts[1] + 2
strings = title.split(' - ')
for t in strings:
ts = d.textsize('#', font=fnt)
d.text((off, y), '#', font=fnt, fill=(255,128,128,255))
ts = d.textsize(t, font=fnt)
d.text((off + 11, y), t, font=fnt,
fill=(255,255,255,255))
y = y + ts[1] + 2
t = '##############################'
ts = d.textsize(t, font=fnt)
d.text((off, y), t, font=fnt, fill=(255,128,128,255))
pic0 = Image.new("RGBA", (1000, 560), (255,255,255,0))
d = ImageDraw.Draw(pic0)
for i in range(250):
for j in range(140):
p = p0.getpixel((i,j))
if p != (0,0,0):
d.ellipse([(i * 4, j * 4), (i * 4 + 3, j * 4 + 3)], fill = p)
return pic0
def create_dotpainting_pic1(game_id, icon0):
icon0 = icon0.resize((120,120), Image.Resampling.BILINEAR)
pic1 = Image.new("RGB", (1920, 1080), (0,0,0))
d = ImageDraw.Draw(pic1)
for i in range(120):
for j in range(120):
p = icon0.getpixel((i,j))
d.ellipse([(i * 9 - 3, j * 9 - 3), (i * 9 + 4, j * 9 + 4)], fill = p)
return pic1