Skip to content

Commit

Permalink
add a morbid tagline reminder at the bottom of the image
Browse files Browse the repository at this point in the history
  • Loading branch information
kronicka committed Dec 30, 2018
1 parent 55965c3 commit decb7f7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Binary file modified __pycache__/scraper.cpython-37.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from datetime import date
from dateutil.parser import parse
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
from pycountry import countries
from typing import Tuple
from scraper import scrape_life_expectancy
Expand Down Expand Up @@ -83,6 +85,18 @@ def input_country() -> str:
print('Please enter a valid country name.')


def draw_text(img: Image) -> None:
"""
Draw a tagline on the bottom of the generated image.
"""
text = 'This is your life on a single sheet of paper.'
draw = ImageDraw.Draw(img)
font = ImageFont.truetype('/Library/Fonts/Arial.ttf', 24)
padding = 100
draw.text(((img.size[0] / 2) - padding, img.size[1] - padding), text, (192, 192, 192), font=font)
img.save('img/background.png')


def calculate_weeks(sex: bool, country_index: int, *dob: int) -> int:
"""
Calculate the number of weeks left to live based on date of birth
Expand Down Expand Up @@ -143,6 +157,8 @@ def generate_calendar(units: int, unit_type: str = None):
box = (square.size[0] * col + padding, square_size[1] * row + padding)
background.paste(square, box)

draw_text(background)
# background.save('weeks.png')
background.show()


Expand Down
Binary file modified img/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit decb7f7

Please sign in to comment.