86 lines
3.7 KiB
Python
86 lines
3.7 KiB
Python
#!/usr/bin/env python3
|
|
"""生成D330Viewer所需的图标"""
|
|
|
|
from PIL import Image, ImageDraw
|
|
import os
|
|
|
|
def create_icon(size, bg_color, fg_color, shape, filename):
|
|
"""创建一个简单的图标"""
|
|
img = Image.new('RGBA', (size, size), (0, 0, 0, 0))
|
|
draw = ImageDraw.Draw(img)
|
|
margin = size // 8
|
|
|
|
if shape == 'play':
|
|
# 播放三角形
|
|
points = [(margin, margin), (margin, size - margin), (size - margin, size // 2)]
|
|
draw.polygon(points, fill=fg_color)
|
|
|
|
elif shape == 'stop':
|
|
# 停止方块
|
|
draw.rectangle([margin, margin, size - margin, size - margin], fill=fg_color)
|
|
|
|
elif shape == 'camera':
|
|
# 相机图标
|
|
draw.ellipse([margin, margin, size - margin, size - margin], outline=fg_color, width=3)
|
|
draw.ellipse([size//3, size//3, 2*size//3, 2*size//3], fill=fg_color)
|
|
|
|
elif shape == 'save':
|
|
# 保存图标
|
|
draw.rectangle([margin, margin, size - margin, size - margin], outline=fg_color, width=3)
|
|
draw.rectangle([margin*2, margin, size - margin*2, margin*3], fill=fg_color)
|
|
|
|
elif shape == 'folder':
|
|
# 文件夹图标
|
|
draw.rectangle([margin, size//3, size - margin, size - margin], outline=fg_color, width=3)
|
|
draw.rectangle([margin, size//3, size//2, size//3 + margin], fill=fg_color)
|
|
|
|
elif shape == 'refresh':
|
|
# 刷新图标
|
|
draw.arc([margin, margin, size - margin, size - margin], 45, 315, fill=fg_color, width=3)
|
|
draw.polygon([(size - margin, margin*2), (size - margin, margin*3), (size - margin*2, margin*2.5)], fill=fg_color)
|
|
|
|
elif shape == 'connect':
|
|
# 连接图标
|
|
draw.ellipse([margin, margin, size//2, size//2], fill=fg_color)
|
|
draw.ellipse([size//2, size//2, size - margin, size - margin], fill=fg_color)
|
|
draw.line([size//4, size//4, 3*size//4, 3*size//4], fill=fg_color, width=3)
|
|
|
|
elif shape == 'clear':
|
|
# 清除图标
|
|
draw.line([margin, margin, size - margin, size - margin], fill=fg_color, width=3)
|
|
draw.line([size - margin, margin, margin, size - margin], fill=fg_color, width=3)
|
|
|
|
elif shape == 'app':
|
|
# 应用图标
|
|
draw.rectangle([margin, margin*2, size - margin, size - margin], fill=bg_color, outline=fg_color, width=3)
|
|
draw.ellipse([size//4, size//3, 3*size//4, 2*size//3], fill=fg_color)
|
|
draw.rectangle([size//3, margin, 2*size//3, margin*2], fill=fg_color)
|
|
|
|
img.save(filename)
|
|
print(f"Created: {filename}")
|
|
|
|
if __name__ == "__main__":
|
|
icons_dir = "icons"
|
|
os.makedirs(icons_dir, exist_ok=True)
|
|
|
|
# 颜色方案 - 使用白色/浅色图标,确保在任何背景上都可见
|
|
white_color = (255, 255, 255, 255) # 白色
|
|
light_gray = (220, 220, 220, 255) # 浅灰色
|
|
transparent = (0, 0, 0, 0) # 透明背景
|
|
|
|
# 为应用图标使用深色背景
|
|
app_bg_color = (33, 150, 243, 255) # 蓝色背景
|
|
|
|
# 生成图标 - 所有按钮图标使用白色,透明背景
|
|
create_icon(64, transparent, white_color, 'play', f'{icons_dir}/start.png')
|
|
create_icon(64, transparent, white_color, 'stop', f'{icons_dir}/stop.png')
|
|
create_icon(64, transparent, white_color, 'camera', f'{icons_dir}/camera.png')
|
|
create_icon(64, transparent, white_color, 'save', f'{icons_dir}/save.png')
|
|
create_icon(64, transparent, white_color, 'folder', f'{icons_dir}/folder.png')
|
|
create_icon(64, transparent, white_color, 'refresh', f'{icons_dir}/refresh.png')
|
|
create_icon(64, transparent, white_color, 'connect', f'{icons_dir}/connect.png')
|
|
create_icon(64, transparent, white_color, 'clear', f'{icons_dir}/clear.png')
|
|
create_icon(128, app_bg_color, white_color, 'app', f'{icons_dir}/app_icon.png')
|
|
|
|
print("\nAll icons generated successfully!")
|