Refactor default.py to adjust profile card dimensions and layout, including conditional sizing for square cards, repositioning of the profile picture, and enhancements to the glass morphism effect for improved readability and aesthetics.
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run

This commit is contained in:
Valerie 2025-05-26 21:55:05 -04:00
parent 7b8b81c777
commit b3cf61b4ec

View file

@ -194,39 +194,43 @@ def generate_default_profile(
stroke_width = 1 # Reduced stroke width for cleaner look stroke_width = 1 # Reduced stroke width for cleaner look
# Card dimensions and layout # Card dimensions and layout
desired_card_size = (1050, 320) # Keep consistent size if square:
desired_card_size = (450, 450)
# Define profile picture size and positions - moved to right side else:
pfp_size = (220, 220) # Slightly smaller profile picture # Slightly increase height to accommodate larger fonts
pfp_x = desired_card_size[0] - pfp_size[0] - 50 # Right side positioning desired_card_size = (1050, 320)
# Define profile picture size and positions
pfp_size = (270, 270) # Slightly smaller profile picture
pfp_x = 55
pfp_y = (desired_card_size[1] - pfp_size[1]) // 2 pfp_y = (desired_card_size[1] - pfp_size[1]) // 2
circle_x = pfp_x circle_x = pfp_x
circle_y = pfp_y circle_y = pfp_y
# Define the stats area with a modern glass effect - adjusted for left side # Define the stats area to cover entire image
stats_area = ( stats_area = (
25, # x1 - Start from left edge with small padding 0, # x1 - Start from very left edge
20, # y1 - Start near top 0, # y1 - Start from very top
desired_card_size[0] - pfp_size[0] - 100, # x2 - End before profile picture desired_card_size[0], # x2 - End at right edge
desired_card_size[1] - 20 # y2 - End near bottom desired_card_size[1] # y2 - End at bottom
) )
# Create the stats layer with glass effect # Create the stats layer with glass effect
stats_layer = Image.new("RGBA", desired_card_size, (0, 0, 0, 0)) stats_layer = Image.new("RGBA", desired_card_size, (0, 0, 0, 0))
# Create a modern glass morphism effect # Create a darker glass morphism effect for entire background
glass = Image.new("RGBA", desired_card_size, (0, 0, 0, 0)) glass = Image.new("RGBA", desired_card_size, (0, 0, 0, 0))
glass_draw = ImageDraw.Draw(glass) glass_draw = ImageDraw.Draw(glass)
glass_draw.rounded_rectangle(stats_area, radius=25, fill=(0, 0, 0, 80)) # Lighter, more modern transparency glass_draw.rounded_rectangle(stats_area, radius=15, fill=(0, 0, 0, 160)) # Darker background for better readability
# Add a subtle gradient overlay for depth # Add a subtle gradient overlay for depth
gradient = Image.new("RGBA", desired_card_size, (0, 0, 0, 0)) gradient = Image.new("RGBA", desired_card_size, (0, 0, 0, 0))
gradient_draw = ImageDraw.Draw(gradient) gradient_draw = ImageDraw.Draw(gradient)
for i in range(40): for i in range(40):
opacity = int(25 * (1 - i/40)) # Even subtler effect opacity = int(35 * (1 - i/40)) # Reduced opacity for subtler effect
gradient_draw.rounded_rectangle( gradient_draw.rounded_rectangle(
(stats_area[0], stats_area[1]+i, stats_area[2], stats_area[3]), (stats_area[0], stats_area[1]+i, stats_area[2], stats_area[3]),
radius=25, radius=15,
fill=(255, 255, 255, opacity) fill=(255, 255, 255, opacity)
) )