python 用PIL画一个python图标
形状目测差不多
from PIL import Image, ImageColor, ImageDraw, ImageFont
def getPyImage(s=256):
ratio = s / 256
def pos(*cord):
return [int(ratio * x) for x in cord]
c1 = ImageColor.getcolor('#387eb8ff', 'RGBA')
c2 = ImageColor.getcolor('#ffe052ff', 'RGBA')
clear = ImageColor.getcolor('#00000000', 'RGBA')
def half(color):
image = Image.new(mode='RGBA', size=pos(256, 256), color=(0, 0, 0, 0))
draw = ImageDraw.Draw(image) # 新建画布绘画对象
draw.chord(pos(66, 0, 190, 55), 180, 0, fill=color)
draw.rectangle(pos(66, 27.5, 190, 58), fill=color)
draw.rectangle(pos(128, 27.5, 190, 124), fill=color)
draw.chord(pos(0, 66, 70, 190), 90, 270, fill=color)
draw.rectangle(pos(35, 66, 58, 190), fill=color)
draw.rectangle(pos(35, 66, 190, 124), fill=color)
draw.rectangle(pos(160, 94, 190, 124), fill=clear)
draw.ellipse(pos(130, 64, 190, 124), fill=color)
draw.rectangle(pos(58, 124, 88, 154), fill=color)
draw.ellipse(pos(58, 124, 118, 184), fill=clear)
draw.ellipse(pos(82, 19, 104, 41), fill=clear)
return image
image1 = half(c1)
image2 = half(c2)
image2 = image2.rotate(180)
py_image = Image.alpha_composite(image1, image2)
return py_image
getPyImage(1024).show()