refactor(flash-gui): 对齐 DLPilot 重构 GUI 并内置 OpenOCD 发布链
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
DAPLink Flash 图标栅格化: 黑底 512, 绿色圆角矩形内 FLASH 黑字, 下方 Link 白字
|
||||
================================================================
|
||||
风格对齐 DLPilot(黑底 + 圆角色块 + 两行字), 绿色区分烧录工具定位。
|
||||
|
||||
输出: logos/logo_flash.png(512, 预览/复用)
|
||||
logos/logo_flash.ico(16~256 七档, exe 图标用)
|
||||
|
||||
用法: python make_ico.py (需 Pillow)
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
BASE = os.path.dirname(os.path.abspath(__file__))
|
||||
FONT = r'C:\Windows\Fonts\arialbd.ttf' # Arial Bold, Windows 标配
|
||||
|
||||
|
||||
def render(size=512):
|
||||
s = size / 512.0
|
||||
img = Image.new('RGB', (size, size), (0, 0, 0))
|
||||
d = ImageDraw.Draw(img)
|
||||
d.rounded_rectangle([38 * s, 64 * s, (38 + 436) * s, (64 + 186) * s],
|
||||
radius=34 * s, fill=(0, 200, 120))
|
||||
if not os.path.exists(FONT):
|
||||
raise SystemExit(f'未找到字体 {FONT}, 无法栅格化')
|
||||
f = ImageFont.truetype(FONT, max(8, round(146 * s)))
|
||||
cx = size / 2
|
||||
# FLASH: 居中于绿色框
|
||||
d.text((cx, 64 * s + 186 * s / 2), 'FLASH', font=f, fill=(0, 0, 0), anchor='mm')
|
||||
# Link: 与 DLPilot 同款基线(中心 ~368)
|
||||
d.text((cx, 368 * s), 'Link', font=f, fill=(255, 255, 255), anchor='mm')
|
||||
return img
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
img = render(512)
|
||||
png = os.path.join(BASE, 'logo_flash.png')
|
||||
ico = os.path.join(BASE, 'logo_flash.ico')
|
||||
img.save(png)
|
||||
img.save(ico, sizes=[(16, 16), (24, 24), (32, 32), (48, 48),
|
||||
(64, 64), (128, 128), (256, 256)])
|
||||
print(f'写出 {png}')
|
||||
print(f'写出 {ico}')
|
||||
Reference in New Issue
Block a user