""" Generate a custom icon for the Voice Recorder application. Creates a modern microphone icon with the app's color scheme. """ from PIL import Image, ImageDraw, ImageFont import os def create_voice_recorder_icon(): """Create a modern microphone icon.""" # Icon sizes for Windows ICO (multiple sizes) sizes = [16, 32, 48, 64, 128, 256] # Colors matching the app theme bg_color = (13, 17, 23) # #0d1117 accent_red = (248, 81, 73) # #f85149 accent_purple = (163, 113, 247) # #a371f7 white = (230, 237, 243) # #e6edf3 images = [] for size in sizes: # Create image with transparent background img = Image.new('RGBA', (size, size), (0, 0, 0, 0)) draw = ImageDraw.Draw(img) # Draw circular background padding = int(size * 0.05) draw.ellipse( [padding, padding, size - padding, size - padding], fill=bg_color ) # Calculate proportional dimensions center_x = size // 2 center_y = size // 2 # Microphone body (rounded rectangle) mic_width = int(size * 0.28) mic_height = int(size * 0.38) mic_top = int(size * 0.18) mic_left = center_x - mic_width // 2 mic_right = center_x + mic_width // 2 mic_bottom = mic_top + mic_height # Draw microphone head (pill shape) radius = mic_width // 2 draw.ellipse( [mic_left, mic_top, mic_right, mic_top + mic_width], fill=accent_red ) draw.rectangle( [mic_left, mic_top + radius, mic_right, mic_bottom], fill=accent_red ) draw.ellipse( [mic_left, mic_bottom - radius, mic_right, mic_bottom + radius], fill=accent_red ) # Microphone lines (detail) if size >= 48: line_color = (*bg_color, 100) line_y1 = mic_top + int(mic_height * 0.35) line_y2 = mic_top + int(mic_height * 0.55) line_y3 = mic_top + int(mic_height * 0.75) line_margin = int(mic_width * 0.25) for line_y in [line_y1, line_y2, line_y3]: draw.line( [(mic_left + line_margin, line_y), (mic_right - line_margin, line_y)], fill=bg_color, width=max(1, size // 32) ) # Microphone stand curve stand_top = mic_bottom + int(size * 0.02) stand_width = int(size * 0.4) stand_left = center_x - stand_width // 2 stand_right = center_x + stand_width // 2 # Draw arc for stand arc_height = int(size * 0.12) draw.arc( [stand_left, stand_top - arc_height, stand_right, stand_top + arc_height], start=0, end=180, fill=accent_purple, width=max(2, size // 16) ) # Draw vertical stand stand_line_top = stand_top + arc_height // 2 stand_line_bottom = int(size * 0.78) line_width = max(2, size // 16) draw.line( [(center_x, stand_line_top), (center_x, stand_line_bottom)], fill=accent_purple, width=line_width ) # Draw base base_width = int(size * 0.3) base_y = stand_line_bottom draw.line( [(center_x - base_width // 2, base_y), (center_x + base_width // 2, base_y)], fill=accent_purple, width=line_width ) images.append(img) # Save as ICO script_dir = os.path.dirname(os.path.abspath(__file__)) ico_path = os.path.join(script_dir, "voice_recorder.ico") # Save with multiple sizes images[0].save( ico_path, format='ICO', sizes=[(s, s) for s in sizes], append_images=images[1:] ) print(f"Icon created: {ico_path}") return ico_path if __name__ == "__main__": create_voice_recorder_icon()