counts showing

This commit is contained in:
Tyrel Souza 2018-08-28 21:16:21 -04:00
parent 5fc486ec39
commit c1e0f8bbaf

26
good.py
View File

@ -46,13 +46,13 @@ def get_goodreads_stats():
def get_stats(pages, books): def get_stats(pages, books):
coords = { coords = {
"year": [ "year": [
(55, 17),(109,17),(163,17) (53, 17),(107,17),(161,17)
], ],
"books": [ "books": [
(55, 45),(109,45),(163,45) (53, 45),(107,45),(161,45)
], ],
"pages": [ "pages": [
(55, 75),(109,75),(163,75) (53, 75),(107,75),(161,75)
], ],
} }
_stats = [] _stats = []
@ -71,17 +71,23 @@ def draw(stats):
inkyphat.set_colour(colour) inkyphat.set_colour(colour)
inkyphat.set_border(inkyphat.RED) inkyphat.set_border(inkyphat.RED)
inkyphat.set_image("./background.png") inkyphat.set_image("./background.png")
font = ImageFont.truetype(inkyphat.fonts.AmaticSCBold, 18)
for column in ('year', 'books', 'pages'): draw_row('year', stats, 12)
for year in stats: draw_row('books', stats, 14)
count = year[column][0] draw_row('pages', stats, 10)
x,y = year[column][1]
w, h = font.getsize(count)
inkyphat.text((x, y), count, inkyphat.BLACK, font)
inkyphat.show() inkyphat.show()
def draw_row(row, stats, size):
#font = ImageFont.truetype(inkyphat.fonts.PressStart2P, size)
font = ImageFont.truetype(inkyphat.fonts.FredokaOne, size)
#font = ImageFont.truetype(inkyphat.fonts.AmaticSC, size)
for year in stats:
count = year[row][0]
x,y = year[row][1]
w, h = font.getsize(count)
inkyphat.text((x, y), count, inkyphat.BLACK, font)
if __name__ == "__main__": if __name__ == "__main__":
main() main()