Refactor default.py to standardize top padding for text elements in profile card rendering, ensuring consistent alignment of balance and level text. Move level text positioning to improve layout aesthetics and readability.
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run
This commit is contained in:
parent
1c55a00e60
commit
3ecf002c37
1 changed files with 9 additions and 8 deletions
|
@ -218,13 +218,14 @@ def generate_default_profile(
|
|||
# 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
|
||||
top_padding = 40 # Consistent top padding for all text
|
||||
|
||||
# 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 - back on the right side
|
||||
balance_y = 40
|
||||
balance_y = top_padding
|
||||
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))
|
||||
|
||||
|
@ -237,6 +238,13 @@ def generate_default_profile(
|
|||
xp_text = f"XP: {humanize_number(current_xp)} / {humanize_number(next_xp)}"
|
||||
draw.text((stats_x, xp_y), xp_text, font=value_font, fill=(255, 255, 255))
|
||||
|
||||
# Level text - aligned with balance text
|
||||
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, top_padding), level_text, font=level_font, fill=user_color or (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
|
||||
progress = max(0, min(1, progress)) # Ensure progress is between 0 and 1
|
||||
|
@ -264,13 +272,6 @@ def generate_default_profile(
|
|||
# Draw percentage
|
||||
draw.text((percent_x, percent_y), percent_text, font=percent_font, fill=(255, 255, 255))
|
||||
|
||||
# Level text - starts after profile picture
|
||||
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))
|
||||
|
||||
# Composite the layers
|
||||
if not render_gif or (not pfp_animated and not bg_animated):
|
||||
if card.mode != "RGBA":
|
||||
|
|
Loading…
Add table
Reference in a new issue