1+ #!/usr/bin/env python3
2+ """
3+ Generate a 64x64 icon for the Sound Recorder app.
4+ Creates a microphone icon with transparent background.
5+
6+ Run this script to generate the icon:
7+ python3 generate_icon.py
8+
9+ The icon will be saved to res/mipmap-mdpi/icon_64x64.png
10+ """
11+
12+ import os
13+ from PIL import Image , ImageDraw
14+
15+ def generate_icon ():
16+ # Create a 64x64 image with transparent background
17+ size = 64
18+ img = Image .new ('RGBA' , (size , size ), (0 , 0 , 0 , 0 ))
19+ draw = ImageDraw .Draw (img )
20+
21+ # Colors
22+ mic_color = (220 , 50 , 50 , 255 ) # Red microphone
23+ mic_dark = (180 , 40 , 40 , 255 ) # Darker red for shading
24+ stand_color = (80 , 80 , 80 , 255 ) # Gray stand
25+ highlight = (255 , 100 , 100 , 255 ) # Light red highlight
26+
27+ # Microphone head (rounded rectangle / ellipse)
28+ mic_top = 8
29+ mic_bottom = 36
30+ mic_left = 20
31+ mic_right = 44
32+
33+ # Draw microphone body (rounded top)
34+ draw .ellipse ([mic_left , mic_top , mic_right , mic_top + 16 ], fill = mic_color )
35+ draw .rectangle ([mic_left , mic_top + 8 , mic_right , mic_bottom ], fill = mic_color )
36+ draw .ellipse ([mic_left , mic_bottom - 8 , mic_right , mic_bottom + 8 ], fill = mic_color )
37+
38+ # Microphone grille lines (horizontal lines on mic head)
39+ for y in range (mic_top + 6 , mic_bottom - 4 , 4 ):
40+ draw .line ([(mic_left + 4 , y ), (mic_right - 4 , y )], fill = mic_dark , width = 1 )
41+
42+ # Highlight on left side of mic
43+ draw .arc ([mic_left + 2 , mic_top + 2 , mic_left + 10 , mic_top + 18 ],
44+ start = 120 , end = 240 , fill = highlight , width = 2 )
45+
46+ # Microphone stand (curved arc under the mic)
47+ stand_top = mic_bottom + 4
48+ stand_width = 8
49+
50+ # Vertical stem from mic
51+ stem_x = size // 2
52+ draw .rectangle ([stem_x - 2 , mic_bottom , stem_x + 2 , stand_top + 8 ], fill = stand_color )
53+
54+ # Curved holder around mic bottom
55+ draw .arc ([mic_left - 4 , mic_bottom - 8 , mic_right + 4 , mic_bottom + 16 ],
56+ start = 0 , end = 180 , fill = stand_color , width = 3 )
57+
58+ # Stand base
59+ base_y = 54
60+ draw .rectangle ([stem_x - 2 , stand_top + 8 , stem_x + 2 , base_y ], fill = stand_color )
61+ draw .ellipse ([stem_x - 12 , base_y - 2 , stem_x + 12 , base_y + 6 ], fill = stand_color )
62+
63+ # Recording indicator (red dot with glow effect)
64+ dot_x , dot_y = 52 , 12
65+ dot_radius = 5
66+
67+ # Glow effect
68+ for r in range (dot_radius + 3 , dot_radius , - 1 ):
69+ alpha = int (100 * (dot_radius + 3 - r ) / 3 )
70+ glow_color = (255 , 0 , 0 , alpha )
71+ draw .ellipse ([dot_x - r , dot_y - r , dot_x + r , dot_y + r ], fill = glow_color )
72+
73+ # Solid red dot
74+ draw .ellipse ([dot_x - dot_radius , dot_y - dot_radius ,
75+ dot_x + dot_radius , dot_y + dot_radius ],
76+ fill = (255 , 50 , 50 , 255 ))
77+
78+ # White highlight on dot
79+ draw .ellipse ([dot_x - 2 , dot_y - 2 , dot_x , dot_y ], fill = (255 , 200 , 200 , 255 ))
80+
81+ # Ensure output directory exists
82+ output_dir = 'res/mipmap-mdpi'
83+ os .makedirs (output_dir , exist_ok = True )
84+
85+ # Save the icon
86+ output_path = os .path .join (output_dir , 'icon_64x64.png' )
87+ img .save (output_path , 'PNG' )
88+ print (f"Icon saved to { output_path } " )
89+
90+ return img
91+
92+ if __name__ == '__main__' :
93+ generate_icon ()
0 commit comments