rotate the maths
This commit is contained in:
parent
8454fe6aec
commit
7d576552fd
|
@ -1,9 +1,5 @@
|
|||
import datetime
|
||||
import requests
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from selenium import webdriver
|
||||
from collections import defaultdict
|
||||
from PIL import ImageFont, Image
|
||||
import inkyphat
|
||||
|
@ -29,7 +25,7 @@ def print_digit(position, digit):
|
|||
|
||||
sprite = text_mask.crop((s_x, 0, s_x + num_width, num_height))
|
||||
|
||||
inkyphat.paste(inkyphat.WHITE, (o_x, o_y), sprite)
|
||||
inkyphat.paste(inkyphat.BLACK, (o_x, o_y), sprite)
|
||||
|
||||
def print_number(position, number):
|
||||
"""Prints a number using the sprite sheet."""
|
||||
|
@ -48,6 +44,7 @@ def main():
|
|||
|
||||
|
||||
def get_goodreads_stats():
|
||||
from selenium import webdriver
|
||||
payload = {
|
||||
'email': os.environ.get('EMAIL'),
|
||||
'password': os.environ.get('PASSW'),
|
||||
|
@ -73,47 +70,39 @@ def get_goodreads_stats():
|
|||
return pages, books
|
||||
|
||||
def get_stats(pages, books):
|
||||
size = 3
|
||||
size = 5
|
||||
|
||||
coords = defaultdict(list)
|
||||
|
||||
columns = ["year", "books", "pages"]
|
||||
|
||||
start_x, start_y = 12, 25
|
||||
column_offset = [0,70,140]
|
||||
column_offset = [0,78,140]
|
||||
year_offset = 15
|
||||
|
||||
for idy, year in enumerate(pages.keys()):
|
||||
for idx, column in enumerate(columns):
|
||||
coords[year].append((
|
||||
start_x + column_offset[idx],
|
||||
start_y + (year_offset * idy)
|
||||
))
|
||||
|
||||
_stats = []
|
||||
for idx, year in enumerate(list(reversed(sorted(books.keys())))[:size]):
|
||||
page_count = pages[year]
|
||||
book_count = books[year]
|
||||
_stats.append({
|
||||
'year': [str(year), coords['year'][idx]],
|
||||
'books': [str(book_count), coords['books'][idx]],
|
||||
'pages': [str(page_count), coords['pages'][idx]],
|
||||
})
|
||||
|
||||
for idy, year in enumerate(sorted(pages.keys(), key=lambda yr: -int(yr))):
|
||||
row = {}
|
||||
col_data = {'year':year, 'pages': pages[year], 'books': books[year]}
|
||||
y = start_y + (year_offset * idy)
|
||||
for idx, column in enumerate(columns):
|
||||
x = start_x + column_offset[idx]
|
||||
row[column] = (col_data[column], (x,y))
|
||||
_stats.append(row)
|
||||
return _stats
|
||||
|
||||
def draw(stats):
|
||||
colour = 'red'
|
||||
inkyphat.set_colour(colour)
|
||||
inkyphat.set_colour('red')
|
||||
inkyphat.set_border(inkyphat.WHITE)
|
||||
inkyphat.set_image("./background.png")
|
||||
|
||||
draw_row('year', stats, 12)
|
||||
draw_row('books', stats, 18)
|
||||
draw_row('pages', stats, 12)
|
||||
draw_row('year', stats)
|
||||
draw_row('books', stats)
|
||||
draw_row('pages', stats)
|
||||
|
||||
inkyphat.show()
|
||||
|
||||
def draw_row(row, stats, size):
|
||||
def draw_row(row, stats):
|
||||
for year in stats:
|
||||
count = year[row][0]
|
||||
x,y = year[row][1]
|
||||
|
|
Loading…
Reference in New Issue
Block a user