Skip to content

Commit 63dc49a

Browse files
add meme play_basketball (#255)
* add meme `play_basketball` 新表情打篮球 * style: auto fix by pre-commit hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9e81910 commit 63dc49a

39 files changed

Lines changed: 84 additions & 0 deletions
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
from datetime import datetime
2+
from pathlib import Path
3+
4+
from PIL.Image import Image as IMG
5+
from pil_utils import BuildImage
6+
7+
from meme_generator import add_meme
8+
from meme_generator.tags import MemeTags
9+
from meme_generator.utils import save_gif
10+
11+
img_dir = Path(__file__).parent / "images"
12+
13+
14+
def play_basketball(images: list[BuildImage], texts, args):
15+
img = images[0].convert("RGBA").square().resize((77, 77))
16+
17+
frames_info = [
18+
((297, 321), 0),
19+
((300, 327), -7.2),
20+
((308, 410), -5),
21+
((308, 412), -5),
22+
((301, 355), 0),
23+
((296, 317), 0),
24+
((296, 320), 0),
25+
((296, 320), 0),
26+
((352, 435), 0),
27+
(None, None),
28+
(None, None),
29+
(None, None),
30+
(None, None),
31+
((175, 343), -5),
32+
((173, 353), -5),
33+
((173, 353), -2),
34+
((171, 354), -2),
35+
((189, 158), 0),
36+
((213, 149), 0),
37+
((238, 139), 0),
38+
((245, 139), 0),
39+
((252, 139), 12),
40+
((257, 142), 12),
41+
((261, 142), 17),
42+
((265, 145), 17),
43+
((271, 148), 18),
44+
((279, 156), 18),
45+
((286, 163), 25),
46+
((287, 160), 25),
47+
((289, 159), 27),
48+
((286, 165), 27),
49+
((285, 167), 20),
50+
((285, 179), 20),
51+
((282, 192), -25),
52+
((284, 219), -25),
53+
((280, 242), -32),
54+
((283, 280), -32),
55+
((287, 315), -32),
56+
]
57+
58+
frames: list[IMG] = []
59+
for loc, rotation in frames_info:
60+
frame = BuildImage.open(img_dir / f"{len(frames)}.png")
61+
if loc is not None:
62+
x, y = loc
63+
current_img = img.copy()
64+
if rotation:
65+
current_img = current_img.rotate(
66+
rotation, expand=True, fillcolor=(0, 0, 0, 0)
67+
)
68+
w, h = current_img.size
69+
pos = (x - w // 2, y - h // 2)
70+
frame.paste(current_img, pos, below=True)
71+
frames.append(frame.image)
72+
return save_gif(frames, 0.08)
73+
74+
75+
add_meme(
76+
"play_basketball",
77+
play_basketball,
78+
min_images=1,
79+
max_images=1,
80+
keywords=["打篮球", "火柴人打篮球"],
81+
tags=MemeTags.stickman,
82+
date_created=datetime(2025, 4, 30),
83+
date_modified=datetime(2025, 4, 30),
84+
)
13.9 KB
Loading
14.2 KB
Loading
20.8 KB
Loading
11.5 KB
Loading
11.5 KB
Loading
16.5 KB
Loading
16.5 KB
Loading
16.4 KB
Loading
16.5 KB
Loading

0 commit comments

Comments
 (0)