-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_icon.py
More file actions
131 lines (106 loc) · 4.08 KB
/
Copy pathcreate_icon.py
File metadata and controls
131 lines (106 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env python3
"""
Create app icon for German Learning Tools
"""
try:
from PIL import Image, ImageDraw, ImageFont
except ImportError:
import subprocess
import sys
print("Installing Pillow...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "Pillow"])
from PIL import Image, ImageDraw, ImageFont
import os
def create_icon():
"""Create a German-themed app icon"""
# Create directory
os.makedirs("docs/images", exist_ok=True)
# Create 1024x1024 icon (high resolution)
size = 1024
img = Image.new('RGBA', (size, size), (0, 0, 0, 0))
draw = ImageDraw.Draw(img)
# German flag colors
black = (0, 0, 0, 255)
red = (221, 0, 0, 255)
gold = (255, 206, 0, 255)
# Background circle with gradient effect
center = size // 2
radius = size // 2 - 20
# Draw background circle
draw.ellipse([20, 20, size-20, size-20], fill=(45, 45, 45, 255))
# Draw German flag stripes in circle
stripe_height = radius * 2 // 3
y_start = center - stripe_height // 2
# Black stripe
draw.rectangle([60, y_start, size-60, y_start + stripe_height//3], fill=black)
# Red stripe
draw.rectangle([60, y_start + stripe_height//3, size-60, y_start + 2*stripe_height//3], fill=red)
# Gold stripe
draw.rectangle([60, y_start + 2*stripe_height//3, size-60, y_start + stripe_height], fill=gold)
# Add "DE" text with better contrast
try:
# Try to use a bold system font
font_size = 280
font = ImageFont.truetype("/System/Library/Fonts/Arial Bold.ttf", font_size)
except:
try:
font = ImageFont.truetype("/System/Library/Fonts/Helvetica.ttc", font_size)
except:
font = ImageFont.load_default()
# Draw "DE" text
text = "DE"
bbox = draw.textbbox((0, 0), text, font=font)
text_width = bbox[2] - bbox[0]
text_height = bbox[3] - bbox[1]
text_x = (size - text_width) // 2
text_y = (size - text_height) // 2 + 100
# Thick black outline for better contrast
outline_width = 8
for dx in range(-outline_width, outline_width + 1):
for dy in range(-outline_width, outline_width + 1):
if dx != 0 or dy != 0:
draw.text((text_x + dx, text_y + dy), text, font=font, fill=(0, 0, 0, 255))
# White text with shadow
draw.text((text_x + 3, text_y + 3), text, font=font, fill=(128, 128, 128, 255)) # Shadow
draw.text((text_x, text_y), text, font=font, fill=(255, 255, 255, 255)) # White text
# Add book/learning symbol
book_x = center - 40
book_y = center - 120
book_width = 80
book_height = 60
# Book outline
draw.rectangle([book_x, book_y, book_x + book_width, book_y + book_height],
fill=(255, 255, 255, 255), outline=black, width=3)
# Book pages
for i in range(3):
y = book_y + 15 + i * 10
draw.line([book_x + 10, y, book_x + book_width - 10, y], fill=black, width=2)
# Save as PNG first
png_path = "docs/images/app_icon.png"
img.save(png_path, "PNG")
print(f"✅ Created PNG icon: {png_path}")
# Convert to ICO for Windows compatibility
ico_path = "docs/images/app_icon.ico"
# Create multiple sizes for ICO
sizes = [16, 32, 48, 64, 128, 256, 512]
ico_images = []
for ico_size in sizes:
ico_img = img.resize((ico_size, ico_size), Image.Resampling.LANCZOS)
ico_images.append(ico_img)
# Save ICO file
ico_images[0].save(ico_path, format='ICO', sizes=[(s, s) for s in sizes])
print(f"✅ Created ICO icon: {ico_path}")
# Create ICNS for macOS
try:
icns_path = "docs/images/app_icon.icns"
# Use sips command on macOS to create ICNS
import subprocess
subprocess.run([
"sips", "-s", "format", "icns", png_path, "--out", icns_path
], check=True)
print(f"✅ Created ICNS icon: {icns_path}")
except:
print("⚠️ Could not create ICNS (macOS only)")
return ico_path
if __name__ == "__main__":
create_icon()