bagsy/scripts/generate-app-icon.py
bananabas 88701de549 chore: clean up project structure
- Remove duplicate iOS app folder (ShopList/ → consolidated to Bagsy/)
- Remove build artifacts from git tracking
- Remove stale documentation files
- Remove old React Native mobile code
- Add PROJECT_STATUS.md for clear project overview

iOS app is now clearly organized under apps/ios/Bagsy/ with single Xcode project (Bagsy.xcodeproj)
2026-04-13 17:16:11 +01:00

90 lines
3 KiB
Python

#!/usr/bin/env python3
"""
Generate Bagsy app icon with branding colors and typography
Creates a 1024x1024 PNG icon with the Bagsy logo and colors
"""
from PIL import Image, ImageDraw, ImageFont
import os
def generate_bagsy_icon(output_path: str = None) -> None:
"""Generate Bagsy app icon"""
if output_path is None:
output_path = os.path.join(
os.path.dirname(__file__),
'../apps/mobile/ios/Bagsy/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png'
)
# Create a new image with Bagsy brand background (dark blue)
size = 1024
img = Image.new('RGBA', (size, size), (0, 79, 137, 255)) # Dark blue background
# Create a drawing context
draw = ImageDraw.Draw(img)
# Draw a gradient-like effect by creating a circle in the center with teal
# This creates a modern, branded look
center = size // 2
radius = size // 2.5
# Draw teal circle (secondary color)
circle_color = (26, 188, 156, 255) # Teal
x0, y0 = center - radius, center - radius
x1, y1 = center + radius, center + radius
draw.ellipse([x0, y0, x1, y1], fill=circle_color)
# Draw orange accent circle (primary color) - smaller
orange_color = (255, 107, 53, 255) # Orange
accent_radius = radius * 0.4
x0, y0 = center - accent_radius, center - accent_radius
x1, y1 = center + accent_radius, center + accent_radius
draw.ellipse([x0, y0, x1, y1], fill=orange_color)
# Try to add text "B" for Bagsy
try:
# Try to use a system font with large size
font_size = int(size * 0.35)
font_paths = [
'/System/Library/Fonts/Helvetica.ttc',
'/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf',
'/System/Library/Fonts/Avenir.ttc',
]
font = None
for font_path in font_paths:
if os.path.exists(font_path):
try:
font = ImageFont.truetype(font_path, font_size)
break
except:
continue
if font is None:
font = ImageFont.load_default()
# Draw white "B" in the center
text = "B"
text_color = (255, 255, 255, 255) # White
# Use textbbox to calculate text position for centering
bbox = draw.textbbox((0, 0), text, font=font)
text_width = bbox[2] - bbox[0]
text_height = bbox[3] - bbox[1]
text_x = center - text_width // 2
text_y = center - text_height // 2
draw.text((text_x, text_y), text, fill=text_color, font=font)
except Exception as e:
print(f"Warning: Could not render text: {e}")
# Create output directory if it doesn't exist
os.makedirs(os.path.dirname(output_path), exist_ok=True)
# Save the image
img.save(output_path, 'PNG')
print(f"✓ App icon generated: {output_path}")
if __name__ == "__main__":
generate_bagsy_icon()