animpy 1.2__tar.gz → 1.3__tar.gz
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.
- {animpy-1.2 → animpy-1.3}/PKG-INFO +76 -5
- {animpy-1.2 → animpy-1.3}/README.md +75 -4
- {animpy-1.2 → animpy-1.3}/animpy.egg-info/PKG-INFO +76 -5
- {animpy-1.2 → animpy-1.3}/animpy.py +45 -30
- {animpy-1.2 → animpy-1.3}/pyproject.toml +2 -2
- {animpy-1.2 → animpy-1.3}/LICENSE +0 -0
- {animpy-1.2 → animpy-1.3}/animpy.egg-info/SOURCES.txt +0 -0
- {animpy-1.2 → animpy-1.3}/animpy.egg-info/dependency_links.txt +0 -0
- {animpy-1.2 → animpy-1.3}/animpy.egg-info/top_level.txt +0 -0
- {animpy-1.2 → animpy-1.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: animpy
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3
|
|
4
4
|
Summary: A simple terminal animation library
|
|
5
5
|
Author: Samin Riyaz
|
|
6
6
|
License: MIT License
|
|
@@ -47,11 +47,11 @@ Animpy is a simple animation library for creating cool terminal animations. It g
|
|
|
47
47
|
|
|
48
48
|
The particle simulator shown above was made entirely with Animpy.
|
|
49
49
|
|
|
50
|
-
## What's New in 1.
|
|
50
|
+
## What's New in 1.3
|
|
51
51
|
|
|
52
|
-
- **
|
|
53
|
-
- **
|
|
54
|
-
- **
|
|
52
|
+
- **Enhanced RGB Color Effects** – Improved support for vibrant RGB color animations; new examples show how to create gradient and rainbow text effects
|
|
53
|
+
- **Audio Support** – New Audio class for loading and playing sound effects with pygame mixer integration
|
|
54
|
+
- **Clean Ctrl+C Exit** – Graceful interrupt handling that cleanly exits without showing messy error messages
|
|
55
55
|
|
|
56
56
|
## What Can You Do?
|
|
57
57
|
|
|
@@ -212,6 +212,44 @@ scene.render()
|
|
|
212
212
|
scene.render() # Shows everything on screen
|
|
213
213
|
```
|
|
214
214
|
|
|
215
|
+
### The `Audio` Class
|
|
216
|
+
|
|
217
|
+
The Audio class lets you load and play sound effects in your animations using pygame mixer.
|
|
218
|
+
|
|
219
|
+
**Creating and using:**
|
|
220
|
+
```python
|
|
221
|
+
audio = animpy.Audio()
|
|
222
|
+
|
|
223
|
+
# Load sound files
|
|
224
|
+
audio.load("jump", "sounds/jump.wav")
|
|
225
|
+
audio.load("background", "sounds/music.mp3")
|
|
226
|
+
|
|
227
|
+
# Play sounds
|
|
228
|
+
audio.play("jump") # Play once
|
|
229
|
+
audio.play("background", loop=-1) # Loop infinitely
|
|
230
|
+
|
|
231
|
+
# Stop all sounds
|
|
232
|
+
audio.stop_all()
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Methods:**
|
|
236
|
+
|
|
237
|
+
- **`load(name, file_path)`** – Load a sound file and give it a name
|
|
238
|
+
```python
|
|
239
|
+
audio.load("explosion", "sounds/boom.wav")
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
- **`play(name, loop=0)`** – Play a loaded sound (loop=0 plays once, loop=-1 loops infinitely)
|
|
243
|
+
```python
|
|
244
|
+
audio.play("explosion") # Play once
|
|
245
|
+
audio.play("background", loop=-1) # Loop infinitely
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
- **`stop_all()`** – Stop all currently playing sounds
|
|
249
|
+
```python
|
|
250
|
+
audio.stop_all()
|
|
251
|
+
```
|
|
252
|
+
|
|
215
253
|
## Full Animation Example
|
|
216
254
|
|
|
217
255
|
Here's a complete example showing how to create animations with the new v1.2 features:
|
|
@@ -252,6 +290,39 @@ for i in range(20):
|
|
|
252
290
|
time.sleep(0.2)
|
|
253
291
|
```
|
|
254
292
|
|
|
293
|
+
## Rainbow Text Example
|
|
294
|
+
|
|
295
|
+
Here's a fun example creating rainbow-colored text using RGB values:
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
import animpy
|
|
299
|
+
import time
|
|
300
|
+
|
|
301
|
+
scene = animpy.Scene()
|
|
302
|
+
|
|
303
|
+
# Rainbow colors (RGB)
|
|
304
|
+
rainbow_colors = [
|
|
305
|
+
(255, 0, 0), # Red
|
|
306
|
+
(255, 127, 0), # Orange
|
|
307
|
+
(255, 255, 0), # Yellow
|
|
308
|
+
(0, 255, 0), # Green
|
|
309
|
+
(0, 0, 255), # Blue
|
|
310
|
+
(75, 0, 130), # Indigo
|
|
311
|
+
(148, 0, 211), # Violet
|
|
312
|
+
]
|
|
313
|
+
|
|
314
|
+
# Create rainbow text - each character in a different color
|
|
315
|
+
text_str = "Rainbow!!!!!"
|
|
316
|
+
for i, char in enumerate(text_str):
|
|
317
|
+
color = rainbow_colors[i % len(rainbow_colors)]
|
|
318
|
+
char_text = animpy.Text(char, i, 0, r=color[0], g=color[1], b=color[2])
|
|
319
|
+
scene.add(char_text)
|
|
320
|
+
|
|
321
|
+
# Render the rainbow text
|
|
322
|
+
scene.render()
|
|
323
|
+
time.sleep(2)
|
|
324
|
+
```
|
|
325
|
+
|
|
255
326
|
## License
|
|
256
327
|
|
|
257
328
|
See LICENSE for details.
|
|
@@ -12,11 +12,11 @@ Animpy is a simple animation library for creating cool terminal animations. It g
|
|
|
12
12
|
|
|
13
13
|
The particle simulator shown above was made entirely with Animpy.
|
|
14
14
|
|
|
15
|
-
## What's New in 1.
|
|
15
|
+
## What's New in 1.3
|
|
16
16
|
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
17
|
+
- **Enhanced RGB Color Effects** – Improved support for vibrant RGB color animations; new examples show how to create gradient and rainbow text effects
|
|
18
|
+
- **Audio Support** – New Audio class for loading and playing sound effects with pygame mixer integration
|
|
19
|
+
- **Clean Ctrl+C Exit** – Graceful interrupt handling that cleanly exits without showing messy error messages
|
|
20
20
|
|
|
21
21
|
## What Can You Do?
|
|
22
22
|
|
|
@@ -177,6 +177,44 @@ scene.render()
|
|
|
177
177
|
scene.render() # Shows everything on screen
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
+
### The `Audio` Class
|
|
181
|
+
|
|
182
|
+
The Audio class lets you load and play sound effects in your animations using pygame mixer.
|
|
183
|
+
|
|
184
|
+
**Creating and using:**
|
|
185
|
+
```python
|
|
186
|
+
audio = animpy.Audio()
|
|
187
|
+
|
|
188
|
+
# Load sound files
|
|
189
|
+
audio.load("jump", "sounds/jump.wav")
|
|
190
|
+
audio.load("background", "sounds/music.mp3")
|
|
191
|
+
|
|
192
|
+
# Play sounds
|
|
193
|
+
audio.play("jump") # Play once
|
|
194
|
+
audio.play("background", loop=-1) # Loop infinitely
|
|
195
|
+
|
|
196
|
+
# Stop all sounds
|
|
197
|
+
audio.stop_all()
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Methods:**
|
|
201
|
+
|
|
202
|
+
- **`load(name, file_path)`** – Load a sound file and give it a name
|
|
203
|
+
```python
|
|
204
|
+
audio.load("explosion", "sounds/boom.wav")
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
- **`play(name, loop=0)`** – Play a loaded sound (loop=0 plays once, loop=-1 loops infinitely)
|
|
208
|
+
```python
|
|
209
|
+
audio.play("explosion") # Play once
|
|
210
|
+
audio.play("background", loop=-1) # Loop infinitely
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
- **`stop_all()`** – Stop all currently playing sounds
|
|
214
|
+
```python
|
|
215
|
+
audio.stop_all()
|
|
216
|
+
```
|
|
217
|
+
|
|
180
218
|
## Full Animation Example
|
|
181
219
|
|
|
182
220
|
Here's a complete example showing how to create animations with the new v1.2 features:
|
|
@@ -217,6 +255,39 @@ for i in range(20):
|
|
|
217
255
|
time.sleep(0.2)
|
|
218
256
|
```
|
|
219
257
|
|
|
258
|
+
## Rainbow Text Example
|
|
259
|
+
|
|
260
|
+
Here's a fun example creating rainbow-colored text using RGB values:
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
import animpy
|
|
264
|
+
import time
|
|
265
|
+
|
|
266
|
+
scene = animpy.Scene()
|
|
267
|
+
|
|
268
|
+
# Rainbow colors (RGB)
|
|
269
|
+
rainbow_colors = [
|
|
270
|
+
(255, 0, 0), # Red
|
|
271
|
+
(255, 127, 0), # Orange
|
|
272
|
+
(255, 255, 0), # Yellow
|
|
273
|
+
(0, 255, 0), # Green
|
|
274
|
+
(0, 0, 255), # Blue
|
|
275
|
+
(75, 0, 130), # Indigo
|
|
276
|
+
(148, 0, 211), # Violet
|
|
277
|
+
]
|
|
278
|
+
|
|
279
|
+
# Create rainbow text - each character in a different color
|
|
280
|
+
text_str = "Rainbow!!!!!"
|
|
281
|
+
for i, char in enumerate(text_str):
|
|
282
|
+
color = rainbow_colors[i % len(rainbow_colors)]
|
|
283
|
+
char_text = animpy.Text(char, i, 0, r=color[0], g=color[1], b=color[2])
|
|
284
|
+
scene.add(char_text)
|
|
285
|
+
|
|
286
|
+
# Render the rainbow text
|
|
287
|
+
scene.render()
|
|
288
|
+
time.sleep(2)
|
|
289
|
+
```
|
|
290
|
+
|
|
220
291
|
## License
|
|
221
292
|
|
|
222
293
|
See LICENSE for details.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: animpy
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3
|
|
4
4
|
Summary: A simple terminal animation library
|
|
5
5
|
Author: Samin Riyaz
|
|
6
6
|
License: MIT License
|
|
@@ -47,11 +47,11 @@ Animpy is a simple animation library for creating cool terminal animations. It g
|
|
|
47
47
|
|
|
48
48
|
The particle simulator shown above was made entirely with Animpy.
|
|
49
49
|
|
|
50
|
-
## What's New in 1.
|
|
50
|
+
## What's New in 1.3
|
|
51
51
|
|
|
52
|
-
- **
|
|
53
|
-
- **
|
|
54
|
-
- **
|
|
52
|
+
- **Enhanced RGB Color Effects** – Improved support for vibrant RGB color animations; new examples show how to create gradient and rainbow text effects
|
|
53
|
+
- **Audio Support** – New Audio class for loading and playing sound effects with pygame mixer integration
|
|
54
|
+
- **Clean Ctrl+C Exit** – Graceful interrupt handling that cleanly exits without showing messy error messages
|
|
55
55
|
|
|
56
56
|
## What Can You Do?
|
|
57
57
|
|
|
@@ -212,6 +212,44 @@ scene.render()
|
|
|
212
212
|
scene.render() # Shows everything on screen
|
|
213
213
|
```
|
|
214
214
|
|
|
215
|
+
### The `Audio` Class
|
|
216
|
+
|
|
217
|
+
The Audio class lets you load and play sound effects in your animations using pygame mixer.
|
|
218
|
+
|
|
219
|
+
**Creating and using:**
|
|
220
|
+
```python
|
|
221
|
+
audio = animpy.Audio()
|
|
222
|
+
|
|
223
|
+
# Load sound files
|
|
224
|
+
audio.load("jump", "sounds/jump.wav")
|
|
225
|
+
audio.load("background", "sounds/music.mp3")
|
|
226
|
+
|
|
227
|
+
# Play sounds
|
|
228
|
+
audio.play("jump") # Play once
|
|
229
|
+
audio.play("background", loop=-1) # Loop infinitely
|
|
230
|
+
|
|
231
|
+
# Stop all sounds
|
|
232
|
+
audio.stop_all()
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Methods:**
|
|
236
|
+
|
|
237
|
+
- **`load(name, file_path)`** – Load a sound file and give it a name
|
|
238
|
+
```python
|
|
239
|
+
audio.load("explosion", "sounds/boom.wav")
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
- **`play(name, loop=0)`** – Play a loaded sound (loop=0 plays once, loop=-1 loops infinitely)
|
|
243
|
+
```python
|
|
244
|
+
audio.play("explosion") # Play once
|
|
245
|
+
audio.play("background", loop=-1) # Loop infinitely
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
- **`stop_all()`** – Stop all currently playing sounds
|
|
249
|
+
```python
|
|
250
|
+
audio.stop_all()
|
|
251
|
+
```
|
|
252
|
+
|
|
215
253
|
## Full Animation Example
|
|
216
254
|
|
|
217
255
|
Here's a complete example showing how to create animations with the new v1.2 features:
|
|
@@ -252,6 +290,39 @@ for i in range(20):
|
|
|
252
290
|
time.sleep(0.2)
|
|
253
291
|
```
|
|
254
292
|
|
|
293
|
+
## Rainbow Text Example
|
|
294
|
+
|
|
295
|
+
Here's a fun example creating rainbow-colored text using RGB values:
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
import animpy
|
|
299
|
+
import time
|
|
300
|
+
|
|
301
|
+
scene = animpy.Scene()
|
|
302
|
+
|
|
303
|
+
# Rainbow colors (RGB)
|
|
304
|
+
rainbow_colors = [
|
|
305
|
+
(255, 0, 0), # Red
|
|
306
|
+
(255, 127, 0), # Orange
|
|
307
|
+
(255, 255, 0), # Yellow
|
|
308
|
+
(0, 255, 0), # Green
|
|
309
|
+
(0, 0, 255), # Blue
|
|
310
|
+
(75, 0, 130), # Indigo
|
|
311
|
+
(148, 0, 211), # Violet
|
|
312
|
+
]
|
|
313
|
+
|
|
314
|
+
# Create rainbow text - each character in a different color
|
|
315
|
+
text_str = "Rainbow!!!!!"
|
|
316
|
+
for i, char in enumerate(text_str):
|
|
317
|
+
color = rainbow_colors[i % len(rainbow_colors)]
|
|
318
|
+
char_text = animpy.Text(char, i, 0, r=color[0], g=color[1], b=color[2])
|
|
319
|
+
scene.add(char_text)
|
|
320
|
+
|
|
321
|
+
# Render the rainbow text
|
|
322
|
+
scene.render()
|
|
323
|
+
time.sleep(2)
|
|
324
|
+
```
|
|
325
|
+
|
|
255
326
|
## License
|
|
256
327
|
|
|
257
328
|
See LICENSE for details.
|
|
@@ -3,6 +3,7 @@ import os, sys, time, atexit, shutil
|
|
|
3
3
|
sys.stdout.write("\033[?25l")
|
|
4
4
|
atexit.register(lambda: (sys.stdout.write("\033[?25h"), sys.stdout.flush()))
|
|
5
5
|
terminal_size = shutil.get_terminal_size()
|
|
6
|
+
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
|
6
7
|
|
|
7
8
|
def addFrame():
|
|
8
9
|
return "\033[2J\033[H"
|
|
@@ -65,22 +66,37 @@ ANSI = {
|
|
|
65
66
|
sys.stdout.write("\033[?25l")
|
|
66
67
|
atexit.register(lambda: (sys.stdout.write("\033[?25h"), sys.stdout.flush()))
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
def __init__(self, text: str | list[str], x: int, y: int, r=255, g=255, b=255) -> None:
|
|
70
|
-
self.x = x
|
|
71
|
-
self.y = y
|
|
69
|
+
from pygame import mixer
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
class Audio:
|
|
72
|
+
def __init__(self):
|
|
73
|
+
mixer.init()
|
|
74
|
+
self.sounds = {}
|
|
76
75
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
self.
|
|
83
|
-
|
|
76
|
+
def load(self, name, file_path):
|
|
77
|
+
self.sounds[name] = mixer.Sound(file_path)
|
|
78
|
+
|
|
79
|
+
def play(self, name, loop=0):
|
|
80
|
+
if name in self.sounds:
|
|
81
|
+
self.sounds[name].play(loops=loop)
|
|
82
|
+
|
|
83
|
+
def stop_all(self):
|
|
84
|
+
mixer.stop()
|
|
85
|
+
|
|
86
|
+
class Text:
|
|
87
|
+
def __init__(self, text, x, y, r=255, g=255, b=255):
|
|
88
|
+
# If 'text' is a list, we store it for frames; otherwise, it's just a string
|
|
89
|
+
self.frames = text if isinstance(text, list) else [text]
|
|
90
|
+
self.current_frame_idx = 0
|
|
91
|
+
self.text = self.frames[0] # The current string for the renderer
|
|
92
|
+
|
|
93
|
+
self.x, self.y = x, y
|
|
94
|
+
self.r, self.g, self.b = r, g, b
|
|
95
|
+
|
|
96
|
+
def change_frame(self):
|
|
97
|
+
"""Cycles through the list of frames"""
|
|
98
|
+
self.current_frame_idx = (self.current_frame_idx + 1) % len(self.frames)
|
|
99
|
+
self.text = self.frames[self.current_frame_idx]
|
|
84
100
|
|
|
85
101
|
def moveX(self, newX: int) -> None:
|
|
86
102
|
self.x = newX
|
|
@@ -94,11 +110,6 @@ class Text:
|
|
|
94
110
|
def centerY(self):
|
|
95
111
|
self.y = terminal_size.lines // 2
|
|
96
112
|
|
|
97
|
-
def change_frame(self) -> None:
|
|
98
|
-
if self.text_list:
|
|
99
|
-
self.current_frame = (self.current_frame + 1) % len(self.text_list)
|
|
100
|
-
self.text = self.text_list[self.current_frame]
|
|
101
|
-
|
|
102
113
|
def change_rgb_values(self, r, g, b):
|
|
103
114
|
self.r = r
|
|
104
115
|
self.g = g
|
|
@@ -127,14 +138,18 @@ class Scene:
|
|
|
127
138
|
self.items.append(item)
|
|
128
139
|
|
|
129
140
|
def render(self):
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
try:
|
|
142
|
+
buf = []
|
|
143
|
+
buf.append("\033[H")
|
|
144
|
+
buf.append("\033[J")
|
|
145
|
+
|
|
146
|
+
for item in self.items:
|
|
147
|
+
color = f"\033[38;2;{item.r};{item.g};{item.b}m"
|
|
148
|
+
# Standard X, Y positioning
|
|
149
|
+
pos = f"\033[{int(item.y)+1};{int(item.x)+1}H"
|
|
150
|
+
buf.append(f"{pos}{color}{item.text}\033[0m")
|
|
151
|
+
|
|
152
|
+
sys.stdout.write("".join(buf))
|
|
153
|
+
sys.stdout.flush()
|
|
154
|
+
except KeyboardInterrupt:
|
|
155
|
+
sys.exit()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "animpy"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.3"
|
|
4
4
|
description = "A simple terminal animation library"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Samin Riyaz"}
|
|
@@ -10,7 +10,7 @@ requires-python = ">=3.8"
|
|
|
10
10
|
license = {file = "LICENSE"}
|
|
11
11
|
|
|
12
12
|
[build-system]
|
|
13
|
-
requires = ["setuptools"]
|
|
13
|
+
requires = ["setuptools", "wheel", "pygame-ce"]
|
|
14
14
|
build-backend = "setuptools.build_meta"
|
|
15
15
|
|
|
16
16
|
[project.urls]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|