I have no fucking clue bro
This commit is contained in:
parent
db6aca6ffb
commit
71f003b7d0
13
async-bot.py
13
async-bot.py
|
@ -61,19 +61,18 @@ class AsyncBotManager:
|
||||||
) -> Image.Image:
|
) -> Image.Image:
|
||||||
left, top, right, bottom = font.getbbox(text)
|
left, top, right, bottom = font.getbbox(text)
|
||||||
with Image.new(
|
with Image.new(
|
||||||
"LA", (int(right - left) + 4, int(bottom - top) + 16), 0
|
"RGBA", (int(right - left) + 4, int(bottom - top) + 16), 0
|
||||||
) as im:
|
) as im:
|
||||||
draw = ImageDraw.Draw(im)
|
draw = ImageDraw.Draw(im)
|
||||||
draw.rectangle(
|
draw.rectangle((0, 0, im.width, im.height), (0, 0, 0, 0))
|
||||||
(0, 0, im.width, im.height), (0, 0)
|
draw.text((left + 2, top + 2), text, font=font, fill=(255, 255, 255, 255), anchor="lt")
|
||||||
)
|
|
||||||
draw.text((left + 2, top + 2), text, font=font, fill=255, anchor="lt")
|
|
||||||
|
|
||||||
alpha = im.convert("L").filter(ImageFilter.MaxFilter(5))
|
alpha = im.convert("L").filter(ImageFilter.MaxFilter(5))
|
||||||
im.putalpha(alpha)
|
im.putalpha(alpha)
|
||||||
if negative:
|
if negative:
|
||||||
im = ImageChops.invert(im.convert("RGBA")).convert("LA")
|
im = ImageChops.invert(im)
|
||||||
return im.copy()
|
im.putalpha(alpha)
|
||||||
|
return im.convert("LA")
|
||||||
|
|
||||||
def get_font(self, font_name: str, size: int = 8):
|
def get_font(self, font_name: str, size: int = 8):
|
||||||
if font := self.fonts.get((font_name, size)):
|
if font := self.fonts.get((font_name, size)):
|
||||||
|
|
Loading…
Reference in New Issue