|
| 1 | +#!/usr/bin/env python3 |
| 2 | +import sys |
| 3 | +from PIL import Image, ImageDraw, ImageFont |
| 4 | + |
| 5 | +def create_background(output_path): |
| 6 | + width, height = 700, 500 |
| 7 | + background_color = (240, 240, 240) # Light gray |
| 8 | + arrow_color = (100, 100, 100) # Dark gray |
| 9 | + text_color = (80, 80, 80) # Darker gray |
| 10 | + |
| 11 | + # Create image |
| 12 | + img = Image.new('RGB', (width, height), color=background_color) |
| 13 | + draw = ImageDraw.Draw(img) |
| 14 | + |
| 15 | + # Coordinates |
| 16 | + icon_y = 225 + 70 # Center of icon (roughly) |
| 17 | + start_x = 180 + 70 + 20 # Right edge of app icon |
| 18 | + end_x = 520 - 20 # Left edge of Applications icon |
| 19 | + |
| 20 | + # Draw arrow |
| 21 | + # Line |
| 22 | + draw.line([(start_x, icon_y), (end_x, icon_y)], fill=arrow_color, width=4) |
| 23 | + # Arrowhead |
| 24 | + arrow_head = [(end_x, icon_y), (end_x - 15, icon_y - 10), (end_x - 15, icon_y + 10)] |
| 25 | + draw.polygon(arrow_head, fill=arrow_color) |
| 26 | + |
| 27 | + # Add text |
| 28 | + text = "Drag CopyShot to Applications" |
| 29 | + try: |
| 30 | + # Try to use a system font |
| 31 | + font = ImageFont.truetype("/System/Library/Fonts/Helvetica.ttc", 24) |
| 32 | + except IOError: |
| 33 | + # Fallback to default if system font not found (e.g. on Linux runner) |
| 34 | + font = ImageFont.load_default() |
| 35 | + |
| 36 | + # Calculate text position (centered above arrow) |
| 37 | + text_bbox = draw.textbbox((0, 0), text, font=font) |
| 38 | + text_width = text_bbox[2] - text_bbox[0] |
| 39 | + text_x = start_x + (end_x - start_x - text_width) // 2 |
| 40 | + text_y = icon_y - 40 |
| 41 | + |
| 42 | + draw.text((text_x, text_y), text, fill=text_color, font=font) |
| 43 | + |
| 44 | + # Save |
| 45 | + img.save(output_path) |
| 46 | + print(f"Background saved to {output_path}") |
| 47 | + |
| 48 | +if __name__ == "__main__": |
| 49 | + if len(sys.argv) < 2: |
| 50 | + print("Usage: generate_background.py <output_path>") |
| 51 | + sys.exit(1) |
| 52 | + |
| 53 | + create_background(sys.argv[1]) |
0 commit comments