from PIL import Image, ImageDraw
# 指定RGB颜色值
red = (252, 222, 233) #
# 指定图标尺寸
size = (120, 120) # 图标尺寸
# 创建图像对象,背景为透明
image = Image.new("RGBA", size, (0, 0, 0, 0))
draw = ImageDraw.Draw(image)
# 计算圆形的位置和半径
center = (size[0] // 2, size[1] // 2)
radius = min(center)
# 绘制圆形
draw.ellipse((center[0] - radius, center[1] - radius, center[0] + radius, center[1] + radius), fill=red)
# 保存图标为图像文件
image.save("./icon/other.ico")
# 显示图标
image.show()
画颜色圆圈icon
于 2023-12-26 13:41:58 首次发布
本文介绍了如何使用Python的PIL库和ImageDraw模块创建一个指定大小和RGB颜色的透明圆形图标,包括计算位置、绘制图形并将其保存为ICO文件,最后展示图标。
8216

被折叠的 条评论
为什么被折叠?



