Refactor default.py to reposition stats and level text in profile card rendering, aligning elements consistently on the right side for improved readability. Adjust calculations for text placement and enhance overall layout aesthetics.
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run

This commit is contained in:
Valerie 2025-05-26 22:10:24 -04:00
parent 173f3b2cc4
commit c840311f42

View file

@ -215,26 +215,27 @@ def generate_default_profile(
stats_layer = Image.new("RGBA", desired_card_size, (0, 0, 0, 0))
draw = ImageDraw.Draw(stats_layer)
# Stats positioning - everything starts AFTER the profile picture
left_edge = pfp_x + pfp_size[0] + 30 # Start everything after profile picture
# Stats positioning - progress bar starts after profile, stats on right
left_edge = pfp_x + pfp_size[0] + 30 # Start progress bar after profile picture
stats_x = desired_card_size[0] - 400 # Right side stats position
# Draw stats with consistent spacing
title_font = ImageFont.truetype(str(font_path or imgtools.DEFAULT_FONT), 32)
value_font = ImageFont.truetype(str(font_path or imgtools.DEFAULT_FONT), 32)
# Balance and Rank stats
# Balance and Rank stats - back on the right side
balance_y = 40
draw.text((left_edge, balance_y), "BALANCE:", font=title_font, fill=(200, 200, 200))
draw.text((left_edge + 150, balance_y), f"{humanize_number(balance)} CREDITS", font=value_font, fill=stat_color or (255, 255, 255))
draw.text((stats_x, balance_y), "BALANCE:", font=title_font, fill=(200, 200, 200))
draw.text((stats_x + 150, balance_y), f"{humanize_number(balance)} CREDITS", font=value_font, fill=stat_color or (255, 255, 255))
rank_y = balance_y + 50
draw.text((left_edge, rank_y), "RANK:", font=title_font, fill=(200, 200, 200))
draw.text((left_edge + 150, rank_y), f"#{humanize_number(position)}", font=value_font, fill=stat_color or (255, 255, 255))
draw.text((stats_x, rank_y), "RANK:", font=title_font, fill=(200, 200, 200))
draw.text((stats_x + 150, rank_y), f"#{humanize_number(position)}", font=value_font, fill=stat_color or (255, 255, 255))
# XP Text
# XP Text - back on the right
xp_y = rank_y + 50
xp_text = f"XP: {humanize_number(current_xp)} / {humanize_number(next_xp)}"
draw.text((left_edge, xp_y), xp_text, font=value_font, fill=(255, 255, 255))
draw.text((stats_x, xp_y), xp_text, font=value_font, fill=(255, 255, 255))
# Progress bar - starts after profile picture
progress = (current_xp - previous_xp) / (next_xp - previous_xp) if next_xp > previous_xp else 0
@ -263,12 +264,12 @@ def generate_default_profile(
# Draw percentage
draw.text((percent_x, percent_y), percent_text, font=percent_font, fill=(255, 255, 255))
# Level text
# Level text - back at the left edge
level_font = ImageFont.truetype(str(font_path or imgtools.DEFAULT_FONT), 48)
level_text = f"LEVEL {level}"
if prestige > 0:
level_text = f"P{prestige}{level_text}"
draw.text((left_edge, 15), level_text, font=level_font, fill=user_color or (255, 255, 255))
draw.text((15, 15), level_text, font=level_font, fill=user_color or (255, 255, 255))
# Composite the layers
if not render_gif or (not pfp_animated and not bg_animated):