Files
HW-Debug-Tools/SerialMate/assets/make_icon.py
T
hulk c26d2cdbaa feat: 新增 SerialMate 串口调试助手 v0.1.0
- 协议帧构成令牌序列可定制(包头/板ID/LEN口径/5种CRC x 3种覆盖), 默认兼容 DLPilot 光机协议
2026-09-27 18:52:54 +08:00

36 lines
1.4 KiB
Python

"""生成 SerialMate 图标(Pillow, 开发时手动运行): 蓝底白色波形 + RS485 字样"""
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
out = Path(__file__).resolve().parent
size = 512
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 指示点
for cx, color in ((88, '#ffd166'), (146, '#7ee081')):
d.ellipse((cx - 17, 84 - 17, cx + 17, 84 + 17), fill=color)
font = 'C:/Windows/Fonts/arialbd.ttf'
d.text((256, 410), 'RS485', font=ImageFont.truetype(font, 72),
anchor='mm', fill='white')
img.save(out / 'serial-mate.png')
img.save(out / 'serial-mate.ico',
sizes=[(16, 16), (24, 24), (32, 32), (48, 48), (64, 64),
(128, 128), (256, 256)])
print('icon ->', out / 'serial-mate.ico')