111 lines
4.8 KiB
Python
111 lines
4.8 KiB
Python
from PIL import Image, ImageDraw, ImageFont
|
||
|
||
icon_width = 256
|
||
icon_height = 144
|
||
banner_height = 70
|
||
|
||
# 创建空白画布
|
||
width = icon_width * 5
|
||
height = icon_height * 2 * 5 + banner_height
|
||
background_color = (255, 255, 255)
|
||
image = Image.new("RGB", (width, height), background_color)
|
||
draw = ImageDraw.Draw(image)
|
||
|
||
# 定义字体和颜色
|
||
font_color = (0, 0, 0)
|
||
font = ImageFont.truetype("arial.ttf", 34)
|
||
|
||
# 定义玩家信息的位置
|
||
player_info_x = 0
|
||
player_info_y = banner_height
|
||
player_info_2_x = player_info_x + icon_width
|
||
player_info_2_x_end = int(player_info_2_x + icon_width * 1.5)
|
||
lv_height = int(icon_height / 2)
|
||
|
||
# 添加天辉标题
|
||
radiant_color = "#66bb6a"
|
||
draw.rectangle([0, 0, player_info_2_x_end, 70], fill=radiant_color)
|
||
draw.text((20, 20), "天辉", font=font, fill=font_color)
|
||
|
||
# 添加玩家信息
|
||
for i in range(5):
|
||
# 左侧等级信息
|
||
draw.rectangle([player_info_x, player_info_y, player_info_2_x, player_info_y + lv_height], fill="#808080")
|
||
draw.text((player_info_x + 10, player_info_y + 10), "LV. 25", font=font, fill=font_color)
|
||
|
||
# 左侧头像信息
|
||
icon = Image.open("hero_img/muerta.png")
|
||
# icon = icon.resize((144, 256))
|
||
image.paste(icon, (player_info_x, player_info_y+lv_height))
|
||
|
||
# 左侧KDA信息
|
||
draw.rectangle([player_info_x, player_info_y+lv_height+icon_height, player_info_2_x, player_info_y+lv_height+icon_height+lv_height], fill="#808080")
|
||
draw.text((player_info_x + 10, player_info_y+lv_height+icon_height + 20), "10/0/10", font=font, fill=font_color)
|
||
|
||
# 右侧玩家名称
|
||
draw.rectangle([player_info_2_x, player_info_y, player_info_2_x_end, player_info_y + lv_height], fill="#808080")
|
||
draw.text((player_info_2_x, player_info_y + 20), "muerta", font=font, fill=font_color)
|
||
|
||
# 右侧金钱信息
|
||
draw.rectangle([player_info_2_x, player_info_y + lv_height, player_info_2_x_end, player_info_y + lv_height+lv_height], fill="#808080")
|
||
draw.text((player_info_2_x, player_info_y + lv_height + 20), "金钱:10000", font=font, fill=font_color)
|
||
|
||
# 右侧伤害信息
|
||
draw.rectangle([player_info_2_x, player_info_y + lv_height*2, player_info_2_x_end, player_info_y + lv_height*3], fill="#808080")
|
||
draw.text((player_info_2_x, player_info_y + lv_height*2 +20), "伤害:23456", font=font, fill=font_color)
|
||
|
||
# 右侧段位信息
|
||
draw.rectangle([player_info_2_x, player_info_y + lv_height*3, player_info_2_x_end, player_info_y + lv_height*4], fill="#808080")
|
||
draw.text((player_info_2_x, player_info_y + lv_height*3 +20), "中军 3", font=font, fill=font_color)
|
||
|
||
player_info_y += lv_height * 2 + icon_height
|
||
|
||
# 添加夜魇标题
|
||
dire_color = "#f44336"
|
||
draw.rectangle([player_info_2_x_end, 0, width, 70], fill=dire_color)
|
||
draw.text((player_info_2_x_end + 20,20), "夜魇", font=font, fill=(255, 255, 255))
|
||
|
||
player_info_x = int(width / 2)
|
||
player_info_y = 70
|
||
player_info_2_x = player_info_x + icon_width
|
||
player_info_2_x_end = player_info_2_x + icon_width * 1.5
|
||
lv_height = 72
|
||
|
||
|
||
# 添加玩家信息
|
||
for i in range(5):
|
||
# 左侧等级信息
|
||
draw.rectangle([player_info_x, player_info_y, player_info_2_x, player_info_y + lv_height], fill="#808080")
|
||
draw.text((player_info_x + 10, player_info_y + 10), "LV. 25", font=font, fill=font_color)
|
||
|
||
# 左侧头像信息
|
||
icon = Image.open("hero_img/muerta.png")
|
||
# icon = icon.resize((144, 256))
|
||
image.paste(icon, (player_info_x, player_info_y+lv_height))
|
||
|
||
# 左侧KDA信息
|
||
draw.rectangle([player_info_x, player_info_y+lv_height+icon_height, player_info_2_x, player_info_y+lv_height+icon_height+lv_height], fill="#808080")
|
||
draw.text((player_info_x + 10, player_info_y+lv_height+icon_height + 20), "10/0/10", font=font, fill=font_color)
|
||
|
||
# 右侧玩家名称
|
||
draw.rectangle([player_info_2_x, player_info_y, player_info_2_x_end, player_info_y + lv_height], fill="#808080")
|
||
draw.text((player_info_2_x, player_info_y + 20), "muerta", font=font, fill=font_color)
|
||
|
||
# 右侧金钱信息
|
||
draw.rectangle([player_info_2_x, player_info_y + lv_height, player_info_2_x_end, player_info_y + lv_height+lv_height], fill="#808080")
|
||
draw.text((player_info_2_x, player_info_y + lv_height + 20), "金钱:10000", font=font, fill=font_color)
|
||
|
||
# 右侧伤害信息
|
||
draw.rectangle([player_info_2_x, player_info_y + lv_height*2, player_info_2_x_end, player_info_y + lv_height*3], fill="#808080")
|
||
draw.text((player_info_2_x, player_info_y + lv_height*2 +20), "伤害:23456", font=font, fill=font_color)
|
||
|
||
# 右侧段位信息
|
||
draw.rectangle([player_info_2_x, player_info_y + lv_height*3, player_info_2_x_end, player_info_y + lv_height*4], fill="#808080")
|
||
draw.text((player_info_2_x, player_info_y + lv_height*3 +20), "中军 3", font=font, fill=font_color)
|
||
|
||
player_info_y += lv_height * 2 + icon_height
|
||
|
||
|
||
# 保存图片
|
||
image.save("dota_match_result.png")
|