各位好人,帮忙看一下啊,源码:
from PIL import Image, ImageDraw, ImageFont
创建图像
img = Image.new('RGB', (800, 600), color='#FFC0CB')
draw = ImageDraw.Draw(img)
设置字体
font_title = ImageFont.truetype('arialbd.ttf', 30)
font_message = ImageFont.truetype('arial.ttf', 20)
绘制蛋糕
draw.ellipse(((-180, -230), (80, 70)), fill='#F08080') # 外层圆
draw.ellipse(((-170, -220), (70, 60)), fill='#FFFFFF') # 内层圆
draw.rectangle(((-180, -110), (100, -90)), fill='#FFFACD') # 盒子
绘制文字
draw.text((-150, 150), 'Happy Birthday 影影!', font=font_title)
draw.text((-150, -200), 'From a fan', font=font_message)
绘制气球
colors = ["#FFDAB9", "#DDA0DD", "#87CEFA", "#90EE90", "#FFA07A", "#ADD8E6"]
for i in range(6):
draw.ellipse(((-350 + i * 100, -50), (-250 + i * 100, 50)), fill=colors[i])
显示图像
img.show()