Files
tamagotchi-paradise-ko/v3/gen/icons.py
T
syskiller 2d48091205 줄바꿈을 LF로 통일
서버에서 바로 빌드하고 고칠 수 있게 저장소 줄바꿈을 LF로 맞췄습니다.
CRLF로 들어가 있던 sh 빌드 스크립트도 이제 리눅스에서 그대로 돌아갑니다.
내용은 바뀌지 않았습니다.
2026-11-24 07:13:54 +09:00

24 lines
1.3 KiB
Python

# The ten V3Emu icons (20 x 20 PNG, mameise) -> src/app/icons_v3.h. A missing icon is taken from T7Emu (t7/src/app/icons.h).
# python3 gen/icons.py <folder with icon_0.png .. icon_9.png (icon_06.png also works)>
import sys, os, re
from PIL import Image
d = sys.argv[1]
t7 = re.findall(r'\{([^{}]+)\}', open(os.path.join(os.path.dirname(__file__), '../../t7/src/app/icons.h')).read())
rows = []
for i in range(10):
f = next((os.path.join(d, n) for n in ('icon_%d.png' % i, 'icon_%02d.png' % i) if os.path.exists(os.path.join(d, n))), None)
if not f:
rows.append(t7[i].strip()); print('icon %d: from T7Emu' % i); continue
im = Image.open(f).convert('RGBA').resize((20, 20))
v = []
for y in range(20):
b = 0
for x in range(20):
p = im.getpixel((x, y))
if p[3] > 128 and sum(p[:3]) < 384: b |= 0x80000 >> x
v.append('0x%08X' % b)
rows.append(','.join(v)); print('icon %d: %s' % (i, os.path.basename(f)))
with open(os.path.join(os.path.dirname(__file__), '../src/app/icons_v3.h'), 'w') as o:
o.write('/* 20x20 icons of V3Emu (bit 0x80000 = left), drawn by mameise; made by gen/icons.py */\n')
o.write('static const unsigned int g_icons[10][20]={\n' + ''.join(' {%s},\n' % r for r in rows) + '};\n')