XMWAI 0.4.23__py3-none-any.whl → 0.4.73__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of XMWAI might be problematic. Click here for more details.

XMWAI/__init__.py CHANGED
@@ -4,8 +4,11 @@ from .bomb_core import bomb # 从子模块导入函数到顶层
4
4
  from .idiom_core import idiom, searchIdiom, get_json_path # 从子模块导入函数到顶层
5
5
  from .trial_class import make, get_file_content_as_base64, save_pic, detect_scale, open_image, get_file_content_as_base64_2, cartoon # 从子模块导入函数到顶层
6
6
  from .web_core import burger, cookbook # 从子模块导入函数到顶层
7
+ from .effects_core import effects # 从子模块导入函数到顶层
8
+
7
9
 
8
10
  __all__ = ["story", "photo", "reply", "poem", 'birthday', 'bomb',
9
11
  "idiom", "searchIdiom", "get_json_path", "crack", "show",
10
12
  "make", "get_file_content_as_base64", "save_pic", "detect_scale", "open_image",
11
- "get_file_content_as_base64_2", "cartoon", "burger", "cookbook"] # 可选:明确导出的内容
13
+ "get_file_content_as_base64_2", "cartoon", "burger", "cookbook",
14
+ "effects"] # 可选:明确导出的内容
XMWAI/assets/like.png ADDED
Binary file
XMWAI/effects_core.py ADDED
@@ -0,0 +1,205 @@
1
+ import turtle
2
+ import random
3
+ import time
4
+ import math
5
+ import tkinter as tk
6
+ from importlib.resources import files
7
+ from pathlib import Path
8
+
9
+ # ---------------------------
10
+ # 高亮色彩库
11
+ # ---------------------------
12
+ _ALL_VIBRANT_COLORS = [
13
+ "#FF0000", "#FF4500", "#FF8C00", "#FFD700", "#ADFF2F", "#00FF7F",
14
+ "#00FA9A", "#00FFFF", "#1E90FF", "#7B68EE", "#9932CC", "#FF69B4",
15
+ "#FF1493", "#FF00FF", "#FF7F50", "#FFA500", "#40E0D0", "#7FFF00",
16
+ "#FF5733", "#FFC300", "#DAF7A6", "#C70039", "#900C3F", "#581845"
17
+ ]
18
+
19
+ # ---------------------------
20
+ # 资源文件获取函数
21
+ # ---------------------------
22
+
23
+
24
+ def get_resource_path(filename: str) -> str:
25
+ """返回包内资源的绝对路径"""
26
+ return str(files("XMWAI.assets").joinpath(filename))
27
+
28
+ # ---------------------------
29
+ # 特效函数
30
+ # ---------------------------
31
+
32
+
33
+ def _effect_stars(screen):
34
+ """炫彩星星闪烁"""
35
+ t = turtle.Turtle(visible=False)
36
+ t.speed(0)
37
+ t.hideturtle()
38
+ screen.tracer(False)
39
+
40
+ stars = [(random.randint(-250, 250), random.randint(-180, 200),
41
+ random.randint(10, 30)) for _ in range(30)]
42
+
43
+ for _ in range(12): # 闪烁次数
44
+ t.clear()
45
+ for x, y, size in stars:
46
+ t.penup()
47
+ t.goto(x, y)
48
+ t.pendown()
49
+ t.color(random.choice(_ALL_VIBRANT_COLORS))
50
+ t.begin_fill()
51
+ for _ in range(5):
52
+ t.forward(size)
53
+ t.right(144)
54
+ t.end_fill()
55
+ screen.update()
56
+ time.sleep(0.07)
57
+
58
+ t.clear()
59
+ screen.update()
60
+
61
+
62
+ def _effect_like(screen, img_path=None, flash_times=1, flash_interval=0.2):
63
+ """点赞动画"""
64
+ screen.tracer(False)
65
+ canvas = screen.getcanvas()
66
+ img_path = img_path or get_resource_path("like.png")
67
+
68
+ tk_img = tk.PhotoImage(file=img_path)
69
+ screen._tk_img_ref = tk_img # 保持引用
70
+
71
+ w = screen.window_width()
72
+ h = screen.window_height()
73
+ img_id = canvas.create_image(w//4, h//4, image=tk_img)
74
+
75
+ for _ in range(flash_times * 2):
76
+ canvas.itemconfigure(img_id, state='normal')
77
+ screen.update()
78
+ time.sleep(flash_interval)
79
+ canvas.itemconfigure(img_id, state='hidden')
80
+ screen.update()
81
+ time.sleep(flash_interval)
82
+
83
+ canvas.delete(img_id)
84
+ screen.update()
85
+
86
+
87
+ def _effect_fireworks(screen):
88
+ """极速瞬爆烟花"""
89
+ t = turtle.Turtle(visible=False)
90
+ t.speed(0)
91
+ t.hideturtle()
92
+ screen.tracer(False)
93
+
94
+ fireworks = []
95
+ for _ in range(random.randint(3, 6)):
96
+ start_x = random.randint(-300, 300)
97
+ peak_y = random.randint(150, 280)
98
+ fireworks.append({
99
+ "x": start_x,
100
+ "y": peak_y,
101
+ "particles": [
102
+ (random.uniform(0, 360), random.uniform(
103
+ 80, 220), random.choice(_ALL_VIBRANT_COLORS))
104
+ for _ in range(random.randint(100, 180))
105
+ ],
106
+ "color": random.choice(["white", "gold", "yellow"])
107
+ })
108
+
109
+ for y in range(-250, 0, 80):
110
+ t.clear()
111
+ for fw in fireworks:
112
+ t.penup()
113
+ t.goto(fw["x"], y)
114
+ t.dot(8, "white")
115
+ screen.update()
116
+ time.sleep(0.01)
117
+
118
+ steps = 12
119
+ for step in range(1, steps + 1):
120
+ t.clear()
121
+ scale = step / steps
122
+ fade = 1 - scale * 0.7
123
+ for fw in fireworks:
124
+ for angle, dist, color in fw["particles"]:
125
+ r, g, b = screen.cv.winfo_rgb(color)
126
+ r, g, b = int((r / 256) * fade), int((g / 256)
127
+ * fade), int((b / 256) * fade)
128
+ fade_color = f"#{r:02x}{g:02x}{b:02x}"
129
+ x = fw["x"] + math.cos(math.radians(angle)) * \
130
+ (dist * scale ** 1.5)
131
+ y = fw["y"] + math.sin(math.radians(angle)) * \
132
+ (dist * scale ** 1.5)
133
+ t.penup()
134
+ t.goto(x, y)
135
+ if random.random() > 0.1:
136
+ t.dot(max(2, 10 - step * 0.3), fade_color)
137
+ if step < 4:
138
+ t.penup()
139
+ t.goto(fw["x"], fw["y"])
140
+ t.dot(40 - step * 4, fw["color"])
141
+ screen.update()
142
+ time.sleep(0.03)
143
+
144
+ for i in range(3):
145
+ t.clear()
146
+ for fw in fireworks:
147
+ t.penup()
148
+ t.goto(fw["x"], fw["y"])
149
+ if i % 2 == 0:
150
+ t.dot(25, "white")
151
+ else:
152
+ t.dot(18, "gold")
153
+ screen.update()
154
+ time.sleep(0.05)
155
+
156
+ t.clear()
157
+ screen.update()
158
+
159
+
160
+ def _effect_heart(screen):
161
+ """快速跳动的爱心效果"""
162
+ t = turtle.Turtle(visible=False)
163
+ t.speed(0)
164
+ screen.tracer(False)
165
+ t.color("red", "red")
166
+
167
+ for s in [0.5, 0.7, 0.9, 1.1, 0.9, 1.1, 0.9, 0.7, 0.5]:
168
+ t.clear()
169
+ t.begin_fill()
170
+ t.setheading(140)
171
+ t.forward(120 * s)
172
+ t.circle(-60 * s, 200)
173
+ t.left(120)
174
+ t.circle(-60 * s, 200)
175
+ t.forward(120 * s)
176
+ t.end_fill()
177
+ screen.update()
178
+ time.sleep(0.05)
179
+
180
+ t.clear()
181
+ t.penup()
182
+ t.goto(0, -100)
183
+ t.pendown()
184
+ t.color("black")
185
+ t.write("点赞!", align="center", font=("Arial", 24, "bold"))
186
+ screen.update()
187
+ time.sleep(0.5)
188
+ t.clear()
189
+ screen.update()
190
+
191
+
192
+ # ---------------------------
193
+ # 统一接口
194
+ # ---------------------------
195
+ def effects(screen, effect_name: str):
196
+ if effect_name == "stars":
197
+ _effect_stars(screen)
198
+ elif effect_name == "like":
199
+ _effect_like(screen)
200
+ elif effect_name == "fireworks":
201
+ _effect_fireworks(screen)
202
+ elif effect_name == "heart":
203
+ _effect_heart(screen)
204
+ else:
205
+ print(f"未知特效: {effect_name}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: XMWAI
3
- Version: 0.4.23
3
+ Version: 0.4.73
4
4
  Summary: Small code King AI related library
5
5
  Home-page: https://github.com/Tonykai88/XMWAI.git
6
6
  Author: pydevelopment
@@ -17,6 +17,7 @@ Requires-Dist: opencv-python>=3.4.18.65
17
17
  Requires-Dist: numpy>=1.26.0
18
18
  Requires-Dist: flask>=3.1.0
19
19
  Requires-Dist: pyecharts>=2.0.8
20
+ Requires-Dist: cvzone>=1.6.1
20
21
  Dynamic: author
21
22
  Dynamic: author-email
22
23
  Dynamic: classifier
@@ -1,10 +1,12 @@
1
- XMWAI/__init__.py,sha256=pQEXlJlAbe4PvWoWDJb0NW1C4Z0pQve3FT1SB6epSEI,918
1
+ XMWAI/__init__.py,sha256=WS_kRg5ATxxV1N-nBqdxnDx3PI3sNTLoXbEvtlxtacs,1015
2
2
  XMWAI/bomb_core.py,sha256=h2ZPH3SuoG2L_XOf1dcK8p3lhw5QzhneWl2yMLj1RiU,1819
3
3
  XMWAI/core.py,sha256=rOXj7FnewSdnzBcFLjpnBtrOTCsvMfiycIcdPDagxho,10012
4
+ XMWAI/effects_core.py,sha256=QDcU08HZ6ODLRD7l_wZ2M_UtC6Iayg2vt3oFcY6bsHk,5915
4
5
  XMWAI/idiom_core.py,sha256=yU-VHhqqoutVm6GVikcjL3m9yuB1hUsFBpPYvwY4n5g,1689
5
6
  XMWAI/magic_core.py,sha256=Ms4b12PJ8rjsmceg1VUqWCWx2ebvdhLp4sIF6K_Vaok,3491
6
7
  XMWAI/trial_class.py,sha256=fPsl7BZvhzch2FOIG4azr999kjtoly53Acm3LqL8f98,9724
7
8
  XMWAI/web_core.py,sha256=7awPg1kYW3lYrbgylqJvUF3g050bn6H21PgmQ7Kv1wA,10927
9
+ XMWAI/assets/like.png,sha256=KOdVR3AXLSHTD-fZ0Efspr52qUpN3QrVjoTmww9AyRw,41801
8
10
  XMWAI/file/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
11
  XMWAI/file/idiom.json,sha256=HUtPRUzhxBbWoasjadbmbA_5ngQ5AXLu9weQSZ4hzhk,10319857
10
12
  XMWAI/gif/0.gif,sha256=LGpAReVTyZEb1J-bWYTpxxHbIxmLJ-3wA0lw4cBqdsY,303
@@ -107,8 +109,8 @@ XMWAI/static/images/tomato.png,sha256=FEOEAOdUhW_BDFgTpxOkYc0I5Iu29_gtHb3RIPEej0
107
109
  XMWAI/templates/burger.html,sha256=vDnxpSW8phetyScySsalScZnFKl3LNpy5lJjKxGXgbI,3320
108
110
  XMWAI/templates/nutrition_pie.html,sha256=yJVXI28i-UfvF0xOXGSNLMb8oCJNhh2J3zoRDr5_7DM,5567
109
111
  XMWAI/templates/创意菜谱.html,sha256=RcDgH58QLyUJ9A59wobu3wvchGBY1snVsXcZQZam5M0,4805
110
- xmwai-0.4.23.dist-info/licenses/LICENSE.txt,sha256=bcaIQMrIhdQ3O-PoZlexjmW6h-wLGvHxh5Oksl4ohtc,1066
111
- xmwai-0.4.23.dist-info/METADATA,sha256=RzOFoDRfC_5-Oe_cX_-fQ8qRLoJzJ5RhqI1-8E2OtRA,1198
112
- xmwai-0.4.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
113
- xmwai-0.4.23.dist-info/top_level.txt,sha256=yvGcDI-sggK5jqd9wz0saipZvk3oIE3hNGHlqUjxf0c,6
114
- xmwai-0.4.23.dist-info/RECORD,,
112
+ xmwai-0.4.73.dist-info/licenses/LICENSE.txt,sha256=bcaIQMrIhdQ3O-PoZlexjmW6h-wLGvHxh5Oksl4ohtc,1066
113
+ xmwai-0.4.73.dist-info/METADATA,sha256=NKe9OKFFmYiNbRObHMI39JAUWTbjqPU-bsFHZ_6GL1Q,1228
114
+ xmwai-0.4.73.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
115
+ xmwai-0.4.73.dist-info/top_level.txt,sha256=yvGcDI-sggK5jqd9wz0saipZvk3oIE3hNGHlqUjxf0c,6
116
+ xmwai-0.4.73.dist-info/RECORD,,
File without changes