【发布时间】:2021-08-03 02:18:03
【问题描述】:
我尝试为我的 Discord Bot 创建排名卡。但是经验条不会正确舍入。 我不知道该怎么办。这是我的代码:
def draw(self, user: str, rank: str, level: str, xp: str, needed_xp: str, profile_bytes: BytesIO) -> BytesIO:
profile_bytes = Image.open(profile_bytes)
im = Image.new('RGBA', (800, 200), (44, 44, 44, 255))
im_draw = ImageDraw.Draw(im)
im_draw.text((154, 5), user, font=self.font, fill=(255, 255, 255, 255))
rank_text = f'Rank: #{rank}'
im_draw.text((154, 37), rank_text, font=self.medium_font, fill=(255, 255, 255, 255))
xp_text = f'Level: {level}'
im_draw.text((154, 62), xp_text, font=self.small_font, fill=(255, 255, 255, 255))
xp_text = f'Experience: {xp}/{needed_xp}'
im_draw.text((154, 87), xp_text, font=self.small_font, fill=(255, 255, 255, 255))
im_draw.rounded_rectangle((40, 180, 440, 150), fill=(64, 64, 64, 255), outline=(92, 23, 47, 255), width=3, radius=15)
length = 40 + int(xp)/int(needed_xp)*400
im_draw.rounded_rectangle((40, 180, length, 150), fill=(221, 221, 221, 255), outline=(92, 23, 47, 255), width=3, radius=15)
im.paste(profile_bytes, (10, 10))
im.show()
但它只是创建了这个:https://imgur.com/TWEbxHh
级别栏看起来像是被切断了。我能做什么?
【问题讨论】:
标签: python image python-imaging-library