import base64 import os # --- Configuration --- WIDTH = 1200 # Image width HEIGHT = 675 # Image height BG_COLOR = "#282a36" # Aider code background color PRIMARY_COLOR = "#14b014" # Aider terminal green TEXT_COLOR = "#FFFFFF" # White for contrast GRID_COLOR = "#3b3d4a" # Slightly lighter than background for grid pattern FONT_SIZE_LARGE = 110 FONT_SIZE_MEDIUM = 55 FONT_SIZE_SMALL = 30 OUTPUT_FILENAME = "aider_30k_stars_celebration.svg" # Font families - SVG will try these in order. Prioritize Inter, then fall back. FONT_FAMILY_BOLD = ( "'Inter Bold', 'DejaVu Sans Bold', 'Arial Bold', 'Helvetica Bold', sans-serif-bold, sans-serif" ) FONT_FAMILY_REGULAR = "'Inter', 'DejaVu Sans', 'Arial', 'Helvetica', sans-serif" # Use Bold for Medium for consistency and visual weight FONT_FAMILY_MEDIUM = FONT_FAMILY_BOLD # --- Paths (Adjust if needed) --- # Assumes the script is run from the root of the aider repo LOGO_PATH = "aider/website/assets/logo.svg" # --- Text Content --- line1 = "Thank You to Our Community!" line2 = "30,000" line3 = "GitHub Stars" line4 = "github.com/Aider-AI/aider" # --- Load and Encode Logo --- logo_data_uri = None logo_width = 200 # Default width from logo.svg logo_height = 60 # Default height from logo.svg try: if os.path.exists(LOGO_PATH): with open(LOGO_PATH, "rb") as f: logo_content = f.read() encoded_logo = base64.b64encode(logo_content).decode("utf-8") logo_data_uri = f"data:image/svg+xml;base64,{encoded_logo}" print(f"Logo loaded and encoded from {LOGO_PATH}") # Optional: Could parse SVG to get width/height, but using defaults is simpler else: print(f"Warning: Logo not found at {LOGO_PATH}, skipping logo.") except Exception as e: print(f"Warning: Could not load or encode logo: {e}") # --- Calculate Positions --- center_x = WIDTH / 2 logo_y_pos = HEIGHT * 0.15 logo_x_pos = center_x - (logo_width / 2) # Adjust text start based on whether logo is present text_start_y = ( logo_y_pos + logo_height + 30 if logo_data_uri else HEIGHT * 0.2 ) # Slightly reduced gap current_y = text_start_y # Calculate Y positions for each line (using dominant-baseline="middle" for vertical centering) line1_y = current_y + FONT_SIZE_MEDIUM / 2 current_y += FONT_SIZE_MEDIUM + 25 # Reduced gap line2_y = current_y + FONT_SIZE_LARGE / 2 current_y += FONT_SIZE_LARGE + 10 # Reduced gap line3_y = current_y + FONT_SIZE_MEDIUM / 2 # Removed large gap calculation here, line4_y is positioned from bottom # Position line 4 relative to the bottom edge line4_y = ( HEIGHT - FONT_SIZE_SMALL - 25 + FONT_SIZE_SMALL / 2 ) # Position near bottom, slightly higher # --- Generate SVG Content --- svg_elements = [] # Background with terminal-like pattern and subtle code svg_elements.append(f""" $ git commit -m "Initial commit" $ aider --model gpt-4 def hello_world(): print("Hello from Aider!") """) # Background with code pattern svg_elements.append(f'') # Terminal-like border with more authentic styling svg_elements.append( f'' ) # Add GitHub logo in corner svg_elements.append( f'' ) # Logo with glow if logo_data_uri: svg_elements.append( f'' ) # Text Lines # Adjust font size for longer text svg_elements.append( f'{line1}' ) # Add animated star decorations around the 30,000 number star_colors = ["#FFD700", "#FFA500", "#FF6347", "#FF69B4", "#00FFFF"] for i in range(8): # Left side stars x_left = center_x - 320 + (i * 70) y_left = line2_y - 60 + (i % 3 * 10) size_factor = 0.4 + (i % 4) * 0.2 # More size variation rotation = i * 15 # Different rotations color = star_colors[i % len(star_colors)] svg_elements.append( f'' ) # Right side stars x_right = center_x + 180 + (i * 70) y_right = line2_y - 50 - (i % 3 * 10) size_factor = 0.3 + (i % 4) * 0.25 # More size variation rotation = i * 20 # Different rotations color = star_colors[(i + 2) % len(star_colors)] svg_elements.append( f'' ) # Enhanced 30,000 number with multi-layer glow and GitHub reference svg_elements.append( f'{line2}' ) # Add GitHub reference text svg_elements.append( f'GitHub Stars' ) svg_elements.append( f'{line3}' ) svg_elements.append( f'{line4}' ) # Combine into final SVG svg_content = f"""\ {''.join(svg_elements)} """ # --- Save SVG Image --- try: with open(OUTPUT_FILENAME, "w", encoding="utf-8") as f: f.write(svg_content) print(f"Celebration SVG image saved as '{OUTPUT_FILENAME}'") except Exception as e: print(f"Error saving SVG image: {e}")