From 8b8d30da2778c63511c34cf029ab81659f976777 Mon Sep 17 00:00:00 2001 From: Sorin Savu Date: Tue, 28 Jul 2026 00:17:26 +0300 Subject: [PATCH] milestones --- faster.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/faster.py b/faster.py index 46f6538..b5f6f58 100644 --- a/faster.py +++ b/faster.py @@ -58,14 +58,14 @@ def draw_clock_digits(x, y, size ,hours, minutes, blink_second, color=(0, 255, 0 draw_digits(x, y, size, current_time, color) -def draw_digits(x, y, size, digits, color=(0, 255, 0)): +def draw_digits(x, y, size, digits, color=(0, 255, 0), anchor='la'): """ Draws clock digits at the specified position. """ font_path = "/usr/share/fonts/truetype/dseg/DSEG14Classic-BoldItalic.ttf" font = ImageFont.truetype(font_path, int(CLOCK_HEIGHT_PIXELS * size)) - - draw.text((x, y), digits, font=font, fill=color) + + draw.text((x, y), digits, font=font, fill=color, anchor=anchor) def status_clock_position(order): """ @@ -88,17 +88,17 @@ def draw_clock(): #draw_label('Time:', x - MARGIN_PIXELS, y + CLOCK_HEIGHT_PIXELS) -def draw_death_clock(order): +def milestone_countdown(order, target_date, label): x, y = status_clock_position(order) + right_x = x + CLOCK_WIDTH_PIXELS * STATUS_SIZE_MULTIPLIER - death_date = datetime.strptime("08/23/2026", "%m/%d/%Y").date() today = datetime.today().date() - days_until_death = (death_date - today).days - + days_until = (target_date - today).days + color = (0, 255, 0) - - draw_digits(x, y, STATUS_SIZE_MULTIPLIER, f'{days_until_death:4}', color) - draw_label('death:', x - MARGIN_PIXELS, y + CLOCK_HEIGHT_PIXELS * STATUS_SIZE_MULTIPLIER) + + draw_digits(right_x, y, STATUS_SIZE_MULTIPLIER, f'{days_until}', color, anchor='ra') + draw_label(label, x - MARGIN_PIXELS, y + CLOCK_HEIGHT_PIXELS * STATUS_SIZE_MULTIPLIER) def draw_journal_minutes(status, order): x, y = status_clock_position(order) @@ -158,6 +158,8 @@ while True: draw_journal_minutes(status, order=0) draw_fasting(status, order=1) + milestone_countdown(order=5, target_date=datetime.strptime("09/01/2026", "%m/%d/%Y").date(), label='below 108kg:') + milestone_countdown(order=4, target_date=datetime.strptime("12/25/2026", "%m/%d/%Y").date(), label='below 95kg:') except RequestException as e: logging.error(f'Error fetching status data: {e}')