feat: 图标改为家族版式绿色款(同 FlashTool 色系)并重打包

- 黑底/绿色圆角框 rgb(0,200,120)/框内黑字 Serial + 白字 Mate, 与 DLPilot/EDID-Viewer/FlashTool 同版式
This commit is contained in:
2026-09-28 09:37:54 +08:00
parent b627f79dad
commit d658fd459a
3 changed files with 56 additions and 29 deletions
+56 -29
View File
@@ -1,35 +1,62 @@
"""生成 SerialMate 图标(Pillow, 开发时手动运行): 蓝底白色波形 + RS485 字样""" #!/usr/bin/env python3
from pathlib import Path # -*- coding: utf-8 -*-
"""
SerialMate 图标栅格化(家族风格, 与 DLPilot/EDID-Viewer/FlashTool 同版式):
黑底 512, 绿色圆角矩形, 第一行 Serial(框内黑字), 第二行 Mate(白字)
================================================================
设计参数: 黑底 512, 绿色圆角矩形 x38 y64 w436 h186 rx34 (#00C878, 与
gd32e230f8_firmware_merge_tool 的 FlashTool 同色系), Arial Bold。
Serial 6 字母按框宽自适应字号(上限 146px, 留边距),
Mate 146px 白字(基线对齐同 DLPilot 的 Pilot)。
用法: python make_icon.py # 生成 serial-mate.png / serial-mate.ico
"""
import os
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
out = Path(__file__).resolve().parent BASE = os.path.dirname(os.path.abspath(__file__))
size = 512 FONT = r'C:\Windows\Fonts\arialbd.ttf' # Arial Bold, Windows 标配
img = Image.new('RGBA', (size, size), (0, 0, 0, 0))
d = ImageDraw.Draw(img)
d.rounded_rectangle((24, 24, 488, 488), radius=96, fill='#0f6cbd')
d.rounded_rectangle((24, 24, 488, 488), radius=96, outline='#5ab0f2', width=10)
# 示波器式白色波形(锯齿+衰减循环, 手绘点位)
wave = [(56, 268)]
segs = ((46, -96), (40, 84), (52, -52), (38, 66), (60, -120), (44, 78),
(50, -40), (42, 56), (56, -88), (44, 60))
x, y = 56, 268
for half, dy in segs:
d.line((x, y, x + half // 2, y + dy), fill='white', width=20)
d.line((x + half // 2, y + dy, x + half, y), fill='white', width=20)
x, y = x + half, y
d.ellipse((x - 10, y - 10, x + 10, y + 10), fill='white')
# 顶部 TX/RX 指示点 def fit_font(draw, text, max_w, start):
for cx, color in ((88, '#ffd166'), (146, '#7ee081')): """从 start 字号往下找能装入 max_w 宽的字号(步进 2)"""
d.ellipse((cx - 17, 84 - 17, cx + 17, 84 + 17), fill=color) size = start
while size > 8:
f = ImageFont.truetype(FONT, size)
box = draw.textbbox((0, 0), text, font=f)
if box[2] - box[0] <= max_w:
return f
size -= 2
return ImageFont.truetype(FONT, 8)
font = 'C:/Windows/Fonts/arialbd.ttf'
d.text((256, 410), 'RS485', font=ImageFont.truetype(font, 72), def render(size=512):
anchor='mm', fill='white') s = size / 512.0
img.save(out / 'serial-mate.png') img = Image.new('RGB', (size, size), (0, 0, 0))
img.save(out / 'serial-mate.ico', d = ImageDraw.Draw(img)
sizes=[(16, 16), (24, 24), (32, 32), (48, 48), (64, 64), d.rounded_rectangle([38 * s, 64 * s, (38 + 436) * s, (64 + 186) * s],
(128, 128), (256, 256)]) radius=34 * s, fill=(0, 200, 120))
print('icon ->', out / 'serial-mate.ico') if not os.path.exists(FONT):
raise SystemExit(f'未找到字体 {FONT}, 无法栅格化')
# Serial: 黑字居中于橙色框, 按框宽自适应(留 2×18px 边距)
f1 = fit_font(d, 'Serial', 400 * s, round(146 * s))
d.text((size / 2, 64 * s + 186 * s / 2), 'Serial', font=f1,
fill=(0, 0, 0), anchor='mm')
# Mate: 白字, 与家族一致 146px(无下伸字母, 中心 = 基线421 - cap/2 ~= 368)
f2 = ImageFont.truetype(FONT, max(8, round(146 * s)))
d.text((size / 2, 368 * s), 'Mate', font=f2, fill=(255, 255, 255),
anchor='mm')
return img
if __name__ == '__main__':
img = render(512)
png = os.path.join(BASE, 'serial-mate.png')
ico = os.path.join(BASE, 'serial-mate.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}')
Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 16 KiB