|
|
|
@@ -3,12 +3,11 @@ from PIL import Image, ImageDraw, ImageFont |
|
|
|
def sub(p1, p2): |
|
|
|
return (p1[0] - p2[0], p1[1] - p2[1]) |
|
|
|
|
|
|
|
def overlay(image_in): |
|
|
|
def overlay(image_in, message="YOU DIED"): |
|
|
|
image = image_in.convert("RGBA") |
|
|
|
|
|
|
|
size = image.size |
|
|
|
center = (size[0]/2, size[1]/2) |
|
|
|
message = "YOU DIED" |
|
|
|
limit = size[1] |
|
|
|
if size[0] / size[1] < 1: |
|
|
|
limit = int(limit * size[0] / size[1]) |
|
|
|
@@ -34,6 +33,14 @@ def overlay(image_in): |
|
|
|
draw.line([0, rect_bot[1] + y, size[0], rect_bot[1] + y], fill=(0,0,0,c)) |
|
|
|
|
|
|
|
text_size = draw.textsize(message, font=font) |
|
|
|
|
|
|
|
# in case the text is too long |
|
|
|
ratio = text_size[0] / size[0] |
|
|
|
|
|
|
|
if ratio > 1: |
|
|
|
font = ImageFont.truetype("OptimusPrinceps.ttf", int(font_size / ratio)) |
|
|
|
text_size = draw.textsize(message, font=font) |
|
|
|
|
|
|
|
offset = (center[0] - text_size[0]/2, center[1] - text_size[1]/2) |
|
|
|
|
|
|
|
draw.text(offset, message, (200,25,25), font=font) |
|
|
|
|