| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import os
- from PIL import Image, ImageDraw, ImageFont
- def create_icon(name, color, text_symbol, filename):
- size = (81, 81)
- img = Image.new('RGBA', size, (255, 255, 255, 0))
- draw = ImageDraw.Draw(img)
-
- # Draw a simple shape or text
- # Since we don't have a guaranteed font, we'll draw shapes
-
- # Center
- cx, cy = size[0] // 2, size[1] // 2
- r = 30
-
- if 'home' in name:
- # Draw a house
- points = [(cx, cy-r), (cx-r, cy), (cx+r, cy)]
- draw.polygon(points, fill=color)
- draw.rectangle([cx-r+10, cy, cx+r-10, cy+r], fill=color)
- elif 'order' in name:
- # Draw a document
- draw.rectangle([cx-20, cy-30, cx+20, cy+30], fill=color)
- # Lines
- draw.line([cx-10, cy-10, cx+10, cy-10], fill=(255,255,255,255), width=3)
- draw.line([cx-10, cy+10, cx+10, cy+10], fill=(255,255,255,255), width=3)
- elif 'mine' in name:
- # Draw a person
- draw.ellipse([cx-15, cy-35, cx+15, cy-5], fill=color)
- draw.pieslice([cx-30, cy, cx+30, cy+60], 180, 360, fill=color)
-
- img.save(filename)
- print(f"Generated {filename}")
- def main():
- base_dir = r"C:\Users\admin\Desktop\宠物需求\宠物管理系统\performer_app\static\tabbar"
- if not os.path.exists(base_dir):
- os.makedirs(base_dir)
-
- gray = (153, 153, 153, 255) # #999999
- orange = (255, 87, 34, 255) # #FF5722
-
- create_icon("home", gray, "H", os.path.join(base_dir, "home.png"))
- create_icon("home-active", orange, "H", os.path.join(base_dir, "home-active.png"))
-
- create_icon("order", gray, "O", os.path.join(base_dir, "order.png"))
- create_icon("order-active", orange, "O", os.path.join(base_dir, "order-active.png"))
-
- create_icon("mine", gray, "M", os.path.join(base_dir, "mine.png"))
- create_icon("mine-active", orange, "M", os.path.join(base_dir, "mine-active.png"))
- if __name__ == "__main__":
- main()
|