Skip to content

Commit 207822f

Browse files
authored
Update and rename tes.py to generate_gifs.py
1 parent a720e01 commit 207822f

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
from PIL import Image, ImageDraw
3+
4+
# ---------------- CREATE IMAGES FOLDER ---------------- #
5+
folder = "images"
6+
if not os.path.exists(folder):
7+
os.makedirs(folder)
8+
9+
# ---------------- PET NAMES AND BASE COLORS ---------------- #
10+
animals = ["cat", "dog", "rabbit", "hamster", "parrot"]
11+
# Colors for moods: High energy / Medium / Low
12+
mood_colors = [
13+
("#4CAF50", "#FFD700", "#FF4C4C"), # green, yellow, red
14+
("#8B4513", "#DAA520", "#CD5C5C"), # brown variants
15+
("#808080", "#FFFF66", "#FF6666"), # gray variants
16+
("#FFFF00", "#FFD700", "#FF6347"), # yellow variants
17+
("#00FF00", "#ADFF2F", "#FF4500") # green variants
18+
]
19+
20+
# ---------------- CREATE ANIMATED GIFS ---------------- #
21+
for idx, name in enumerate(animals):
22+
colors = mood_colors[idx]
23+
frames = []
24+
25+
# Each pet will have 9 frames: 3 frames per mood cycling
26+
for state_color in colors:
27+
for i in range(3): # 3 frames per mood for animation
28+
img = Image.new("RGBA", (80, 80), (0, 0, 0, 0))
29+
draw = ImageDraw.Draw(img)
30+
# draw a circle that slightly changes size per frame
31+
draw.ellipse([10+i*2, 10+i*2, 70-i*2, 70-i*2], fill=state_color)
32+
frames.append(img)
33+
34+
gif_path = os.path.join(folder, f"{name}.gif")
35+
frames[0].save(gif_path, save_all=True, append_images=frames[1:], loop=0, duration=200)
36+
37+
print(f"All mood-aware GIFs created in folder '{folder}' successfully!")

189-Virtual-Pet/images/tes.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)