You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.3 KiB
82 lines
2.3 KiB
#!/usr/bin/env python3
|
|
"""
|
|
Generate PWA icons from SVG or create simple placeholder icons
|
|
"""
|
|
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
import os
|
|
|
|
def create_icon(size):
|
|
"""Create a simple app icon with the specified size."""
|
|
# Create a new image with a green background
|
|
img = Image.new('RGBA', (size, size), color='#4CAF50')
|
|
draw = ImageDraw.Draw(img)
|
|
|
|
# Draw a white mountain shape
|
|
mountain_color = 'white'
|
|
# Mountain 1 (left)
|
|
mountain1 = [
|
|
(size * 0.1, size * 0.7),
|
|
(size * 0.35, size * 0.3),
|
|
(size * 0.6, size * 0.7)
|
|
]
|
|
draw.polygon(mountain1, fill=mountain_color)
|
|
|
|
# Mountain 2 (right, slightly overlapping)
|
|
mountain2 = [
|
|
(size * 0.4, size * 0.7),
|
|
(size * 0.65, size * 0.4),
|
|
(size * 0.9, size * 0.7)
|
|
]
|
|
draw.polygon(mountain2, fill='#E8F5E9')
|
|
|
|
# Draw a location pin at the peak
|
|
pin_center = (int(size * 0.65), int(size * 0.4))
|
|
pin_radius = int(size * 0.05)
|
|
|
|
# Pin circle
|
|
draw.ellipse(
|
|
[pin_center[0] - pin_radius, pin_center[1] - pin_radius,
|
|
pin_center[0] + pin_radius, pin_center[1] + pin_radius],
|
|
fill='#FF5722'
|
|
)
|
|
|
|
# Pin point
|
|
draw.polygon([
|
|
(pin_center[0] - pin_radius, pin_center[1]),
|
|
(pin_center[0] + pin_radius, pin_center[1]),
|
|
(pin_center[0], pin_center[1] + pin_radius * 2)
|
|
], fill='#FF5722')
|
|
|
|
# Add "HM" text at the bottom
|
|
try:
|
|
# Try to use a default font, fall back to PIL default if not available
|
|
font_size = int(size * 0.15)
|
|
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", font_size)
|
|
except:
|
|
font = ImageFont.load_default()
|
|
|
|
text = "HM"
|
|
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 = int(size * 0.75)
|
|
|
|
draw.text((text_x, text_y), text, fill='white', font=font)
|
|
|
|
return img
|
|
|
|
# Icon sizes needed for PWA
|
|
sizes = [72, 96, 128, 144, 152, 192, 384, 512]
|
|
|
|
print("Generating HikeMap PWA icons...")
|
|
|
|
for size in sizes:
|
|
icon = create_icon(size)
|
|
filename = f"icon-{size}x{size}.png"
|
|
icon.save(filename, "PNG")
|
|
print(f"Created {filename}")
|
|
|
|
print("\nAll icons generated successfully!")
|
|
print("Icons feature a mountain landscape with location pin design.")
|