Skip to content

Commit

Permalink
add svgwrite to requirements, move image paths to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
kronicka committed Jan 11, 2019
1 parent 76a7515 commit 47fd702
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 2 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from utils.input import input_all
from utils.draw import draw_text, draw_units_number


# TODO: merge functionality for calculating days, weeks (and, maybe, months and years)
# TODO: let the user pick a shape
# TODO: separate methods into one class
Expand Down Expand Up @@ -46,9 +47,6 @@ def generate_calendar(units: int, unit_type: str = 'weeks'):
"""
Generate a calendar based on the number of weeks
"""
square_path = 'img/square.jpg'
background_path = 'img/background.png'

square_size = (50, 50)
cols = 48
padding = 40
Expand All @@ -61,7 +59,7 @@ def generate_calendar(units: int, unit_type: str = 'weeks'):
rows, leftover = divmod(units / cols, 1)
rows = int(rows) + 1

with Image.open(square_path) as square, Image.open(background_path) as background:
with Image.open(constants.square_path) as square, Image.open(constants.background_path) as background:
print(background.format, background.size, background.mode)
print(square.format, square.size)
square = square.resize(square_size)
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ bs4
Pillow>=5.3.0
python-dateutil
pycountry>=18.12.8
requests
requests
svgwrite
6 changes: 5 additions & 1 deletion utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
female_life_expectancy_weeks = 3872.18071 # ~74.261 years
male_life_expectancy_weeks = 3647.54929 # ~69.953 years

# Image Paths
square_path = 'img/square.jpg'
background_path = 'img/background.png'

# Text Draw Utilities
dark_grey = (192, 192, 192)
macos_font_path = '/Library/Fonts/Arial.ttf'
windows_font_path = 'arial.ttf'
path = windows_font_path if system() == 'Windows' else macos_font_path
font = ImageFont.truetype(path, 24)
font = ImageFont.truetype(path, 24)

0 comments on commit 47fd702

Please sign in to comment.