animpy 1.0.0__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.0.0/PKG-INFO +175 -0
- animpy-1.0.0/README.md +167 -0
- animpy-1.0.0/animpy.egg-info/PKG-INFO +175 -0
- animpy-1.0.0/animpy.egg-info/SOURCES.txt +7 -0
- animpy-1.0.0/animpy.egg-info/dependency_links.txt +1 -0
- animpy-1.0.0/animpy.egg-info/top_level.txt +1 -0
- animpy-1.0.0/animpy.py +105 -0
- animpy-1.0.0/pyproject.toml +14 -0
- animpy-1.0.0/setup.cfg +4 -0
animpy-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: animpy
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A simple terminal animation library
|
|
5
|
+
Author: yourname
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
Animpy is a simple animation library for creating cool terminal animations. It gives you everything you need to make text-based animations with colors, movement, and frame-by-frame control. Perfect for CLI projects, games, or just having fun in the terminal!
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
The particle simulator shown above was made entirely with Animpy.
|
|
14
|
+
|
|
15
|
+
## What Can You Do?
|
|
16
|
+
|
|
17
|
+
- **Add colors and styling** to your terminal text (16 colors, bright versions, backgrounds, bold, underline, etc.)
|
|
18
|
+
- **Move text around** the screen wherever you want
|
|
19
|
+
- **Create frame-by-frame animations** with multiple text frames that you can cycle through
|
|
20
|
+
- **Build complex scenes** with multiple text elements rendered together
|
|
21
|
+
- **Control animations** smoothly and precisely
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
Copy the `animpy` folder to your project directory and import it:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
import animpy
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
Here's a simple example to get you started:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
import animpy
|
|
37
|
+
|
|
38
|
+
# Create a new scene
|
|
39
|
+
scene = animpy.Scene()
|
|
40
|
+
|
|
41
|
+
# Create some text at position (10, 5)
|
|
42
|
+
hello = animpy.Text("Hello, World!", 10, 5)
|
|
43
|
+
|
|
44
|
+
# Add it to the scene
|
|
45
|
+
scene.add(hello)
|
|
46
|
+
|
|
47
|
+
# Render it to the screen
|
|
48
|
+
scene.render()
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Complete Guide
|
|
52
|
+
|
|
53
|
+
### `addFrame()`
|
|
54
|
+
|
|
55
|
+
This is the simplest way to clear the terminal screen. It returns an ANSI code that clears everything and moves the cursor back to the top-left corner. Great if you're building your own animation loop.
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
print(animpy.addFrame()) # Clears the screen
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Colors and Styling with `ANSI`
|
|
62
|
+
|
|
63
|
+
The `ANSI` dictionary has everything you need for styling text. Just add the code before your text and use `'reset'` to go back to normal.
|
|
64
|
+
|
|
65
|
+
**Available colors:**
|
|
66
|
+
- **Regular**: black, red, green, yellow, blue, magenta, cyan, white
|
|
67
|
+
- **Bright**: bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white
|
|
68
|
+
- **Backgrounds**: bg_black, bg_red, bg_green, bg_yellow, bg_blue, bg_magenta, bg_cyan, bg_white
|
|
69
|
+
- **Bright backgrounds**: bg_bright_black, bg_bright_red, bg_bright_green, bg_bright_yellow, bg_bright_blue, bg_bright_magenta, bg_bright_cyan, bg_bright_white
|
|
70
|
+
- **Text styles**: bold, dim, italic, underline, blink, reverse, hidden, strikethrough
|
|
71
|
+
|
|
72
|
+
**Example:**
|
|
73
|
+
```python
|
|
74
|
+
import animpy
|
|
75
|
+
|
|
76
|
+
# Simple color example
|
|
77
|
+
text = animpy.ANSI['red'] + 'Error!' + animpy.ANSI['reset']
|
|
78
|
+
print(text)
|
|
79
|
+
|
|
80
|
+
# Combining styles
|
|
81
|
+
fancy = animpy.ANSI['bold'] + animpy.ANSI['bright_blue'] + 'AWESOME' + animpy.ANSI['reset']
|
|
82
|
+
print(fancy)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### The `Text` Class
|
|
86
|
+
|
|
87
|
+
This is where the animation magic happens. `Text` objects represent text that you can position and animate.
|
|
88
|
+
|
|
89
|
+
**Creating text:**
|
|
90
|
+
```python
|
|
91
|
+
# Simple static text at position (x=10, y=5)
|
|
92
|
+
text = animpy.Text("Hello", 10, 5)
|
|
93
|
+
|
|
94
|
+
# Or create animation frames with a list of strings
|
|
95
|
+
animation = animpy.Text(["Frame 1", "Frame 2", "Frame 3"], 10, 5)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Methods:**
|
|
99
|
+
|
|
100
|
+
- **`moveX(newX)`** – Move the text to a new X position
|
|
101
|
+
```python
|
|
102
|
+
text.moveX(20) # Move to x=20
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
- **`moveY(newY)`** – Move the text to a new Y position
|
|
106
|
+
```python
|
|
107
|
+
text.moveY(10) # Move to y=10
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- **`change_frame()`** – Go to the next frame in a frame-by-frame animation (only works if you created it with a list)
|
|
111
|
+
```python
|
|
112
|
+
animation.change_frame() # Switch to the next frame
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### The `Scene` Class
|
|
116
|
+
|
|
117
|
+
A scene holds all your text elements and renders them to the screen at once.
|
|
118
|
+
|
|
119
|
+
**Creating and using:**
|
|
120
|
+
```python
|
|
121
|
+
scene = animpy.Scene()
|
|
122
|
+
|
|
123
|
+
# Add multiple text objects
|
|
124
|
+
text1 = animpy.Text("First", 5, 2)
|
|
125
|
+
text2 = animpy.Text("Second", 10, 5)
|
|
126
|
+
|
|
127
|
+
scene.add(text1, text2)
|
|
128
|
+
|
|
129
|
+
# Render everything to the screen
|
|
130
|
+
scene.render()
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Methods:**
|
|
134
|
+
|
|
135
|
+
- **`add(*items)`** – Add one or more Text objects to the scene
|
|
136
|
+
```python
|
|
137
|
+
scene.add(text1, text2, text3) # Add multiple at once
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
- **`render()`** – Draw all text objects to the screen in their current positions
|
|
141
|
+
```python
|
|
142
|
+
scene.render() # Shows everything on screen
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Full Animation Example
|
|
146
|
+
|
|
147
|
+
Here's a complete example showing how to create a simple animation:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
import animpy
|
|
151
|
+
import time
|
|
152
|
+
|
|
153
|
+
# Create a scene
|
|
154
|
+
scene = animpy.Scene()
|
|
155
|
+
|
|
156
|
+
# Create animated text (multiple frames)
|
|
157
|
+
frames = ["Moving...", " Moving...", " Moving...", " Moving..."]
|
|
158
|
+
moving_text = animpy.Text(frames, 1, 5)
|
|
159
|
+
|
|
160
|
+
# Create a title that stays still
|
|
161
|
+
title = animpy.Text(animpy.ANSI['bold'] + animpy.ANSI['cyan'] + "Animation Demo" + animpy.ANSI['reset'], 5, 1)
|
|
162
|
+
|
|
163
|
+
# Add both to the scene
|
|
164
|
+
scene.add(title, moving_text)
|
|
165
|
+
|
|
166
|
+
# Animation loop
|
|
167
|
+
for i in range(20):
|
|
168
|
+
scene.render()
|
|
169
|
+
moving_text.change_frame() # Next frame
|
|
170
|
+
time.sleep(0.2) # Wait 200ms
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
See LICENSE for details.
|
animpy-1.0.0/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
Animpy is a simple animation library for creating cool terminal animations. It gives you everything you need to make text-based animations with colors, movement, and frame-by-frame control. Perfect for CLI projects, games, or just having fun in the terminal!
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
The particle simulator shown above was made entirely with Animpy.
|
|
6
|
+
|
|
7
|
+
## What Can You Do?
|
|
8
|
+
|
|
9
|
+
- **Add colors and styling** to your terminal text (16 colors, bright versions, backgrounds, bold, underline, etc.)
|
|
10
|
+
- **Move text around** the screen wherever you want
|
|
11
|
+
- **Create frame-by-frame animations** with multiple text frames that you can cycle through
|
|
12
|
+
- **Build complex scenes** with multiple text elements rendered together
|
|
13
|
+
- **Control animations** smoothly and precisely
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Copy the `animpy` folder to your project directory and import it:
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import animpy
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
Here's a simple example to get you started:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
import animpy
|
|
29
|
+
|
|
30
|
+
# Create a new scene
|
|
31
|
+
scene = animpy.Scene()
|
|
32
|
+
|
|
33
|
+
# Create some text at position (10, 5)
|
|
34
|
+
hello = animpy.Text("Hello, World!", 10, 5)
|
|
35
|
+
|
|
36
|
+
# Add it to the scene
|
|
37
|
+
scene.add(hello)
|
|
38
|
+
|
|
39
|
+
# Render it to the screen
|
|
40
|
+
scene.render()
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Complete Guide
|
|
44
|
+
|
|
45
|
+
### `addFrame()`
|
|
46
|
+
|
|
47
|
+
This is the simplest way to clear the terminal screen. It returns an ANSI code that clears everything and moves the cursor back to the top-left corner. Great if you're building your own animation loop.
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
print(animpy.addFrame()) # Clears the screen
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Colors and Styling with `ANSI`
|
|
54
|
+
|
|
55
|
+
The `ANSI` dictionary has everything you need for styling text. Just add the code before your text and use `'reset'` to go back to normal.
|
|
56
|
+
|
|
57
|
+
**Available colors:**
|
|
58
|
+
- **Regular**: black, red, green, yellow, blue, magenta, cyan, white
|
|
59
|
+
- **Bright**: bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white
|
|
60
|
+
- **Backgrounds**: bg_black, bg_red, bg_green, bg_yellow, bg_blue, bg_magenta, bg_cyan, bg_white
|
|
61
|
+
- **Bright backgrounds**: bg_bright_black, bg_bright_red, bg_bright_green, bg_bright_yellow, bg_bright_blue, bg_bright_magenta, bg_bright_cyan, bg_bright_white
|
|
62
|
+
- **Text styles**: bold, dim, italic, underline, blink, reverse, hidden, strikethrough
|
|
63
|
+
|
|
64
|
+
**Example:**
|
|
65
|
+
```python
|
|
66
|
+
import animpy
|
|
67
|
+
|
|
68
|
+
# Simple color example
|
|
69
|
+
text = animpy.ANSI['red'] + 'Error!' + animpy.ANSI['reset']
|
|
70
|
+
print(text)
|
|
71
|
+
|
|
72
|
+
# Combining styles
|
|
73
|
+
fancy = animpy.ANSI['bold'] + animpy.ANSI['bright_blue'] + 'AWESOME' + animpy.ANSI['reset']
|
|
74
|
+
print(fancy)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### The `Text` Class
|
|
78
|
+
|
|
79
|
+
This is where the animation magic happens. `Text` objects represent text that you can position and animate.
|
|
80
|
+
|
|
81
|
+
**Creating text:**
|
|
82
|
+
```python
|
|
83
|
+
# Simple static text at position (x=10, y=5)
|
|
84
|
+
text = animpy.Text("Hello", 10, 5)
|
|
85
|
+
|
|
86
|
+
# Or create animation frames with a list of strings
|
|
87
|
+
animation = animpy.Text(["Frame 1", "Frame 2", "Frame 3"], 10, 5)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Methods:**
|
|
91
|
+
|
|
92
|
+
- **`moveX(newX)`** – Move the text to a new X position
|
|
93
|
+
```python
|
|
94
|
+
text.moveX(20) # Move to x=20
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
- **`moveY(newY)`** – Move the text to a new Y position
|
|
98
|
+
```python
|
|
99
|
+
text.moveY(10) # Move to y=10
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
- **`change_frame()`** – Go to the next frame in a frame-by-frame animation (only works if you created it with a list)
|
|
103
|
+
```python
|
|
104
|
+
animation.change_frame() # Switch to the next frame
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### The `Scene` Class
|
|
108
|
+
|
|
109
|
+
A scene holds all your text elements and renders them to the screen at once.
|
|
110
|
+
|
|
111
|
+
**Creating and using:**
|
|
112
|
+
```python
|
|
113
|
+
scene = animpy.Scene()
|
|
114
|
+
|
|
115
|
+
# Add multiple text objects
|
|
116
|
+
text1 = animpy.Text("First", 5, 2)
|
|
117
|
+
text2 = animpy.Text("Second", 10, 5)
|
|
118
|
+
|
|
119
|
+
scene.add(text1, text2)
|
|
120
|
+
|
|
121
|
+
# Render everything to the screen
|
|
122
|
+
scene.render()
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Methods:**
|
|
126
|
+
|
|
127
|
+
- **`add(*items)`** – Add one or more Text objects to the scene
|
|
128
|
+
```python
|
|
129
|
+
scene.add(text1, text2, text3) # Add multiple at once
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
- **`render()`** – Draw all text objects to the screen in their current positions
|
|
133
|
+
```python
|
|
134
|
+
scene.render() # Shows everything on screen
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Full Animation Example
|
|
138
|
+
|
|
139
|
+
Here's a complete example showing how to create a simple animation:
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
import animpy
|
|
143
|
+
import time
|
|
144
|
+
|
|
145
|
+
# Create a scene
|
|
146
|
+
scene = animpy.Scene()
|
|
147
|
+
|
|
148
|
+
# Create animated text (multiple frames)
|
|
149
|
+
frames = ["Moving...", " Moving...", " Moving...", " Moving..."]
|
|
150
|
+
moving_text = animpy.Text(frames, 1, 5)
|
|
151
|
+
|
|
152
|
+
# Create a title that stays still
|
|
153
|
+
title = animpy.Text(animpy.ANSI['bold'] + animpy.ANSI['cyan'] + "Animation Demo" + animpy.ANSI['reset'], 5, 1)
|
|
154
|
+
|
|
155
|
+
# Add both to the scene
|
|
156
|
+
scene.add(title, moving_text)
|
|
157
|
+
|
|
158
|
+
# Animation loop
|
|
159
|
+
for i in range(20):
|
|
160
|
+
scene.render()
|
|
161
|
+
moving_text.change_frame() # Next frame
|
|
162
|
+
time.sleep(0.2) # Wait 200ms
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
See LICENSE for details.
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: animpy
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A simple terminal animation library
|
|
5
|
+
Author: yourname
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
Animpy is a simple animation library for creating cool terminal animations. It gives you everything you need to make text-based animations with colors, movement, and frame-by-frame control. Perfect for CLI projects, games, or just having fun in the terminal!
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
The particle simulator shown above was made entirely with Animpy.
|
|
14
|
+
|
|
15
|
+
## What Can You Do?
|
|
16
|
+
|
|
17
|
+
- **Add colors and styling** to your terminal text (16 colors, bright versions, backgrounds, bold, underline, etc.)
|
|
18
|
+
- **Move text around** the screen wherever you want
|
|
19
|
+
- **Create frame-by-frame animations** with multiple text frames that you can cycle through
|
|
20
|
+
- **Build complex scenes** with multiple text elements rendered together
|
|
21
|
+
- **Control animations** smoothly and precisely
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
Copy the `animpy` folder to your project directory and import it:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
import animpy
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
Here's a simple example to get you started:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
import animpy
|
|
37
|
+
|
|
38
|
+
# Create a new scene
|
|
39
|
+
scene = animpy.Scene()
|
|
40
|
+
|
|
41
|
+
# Create some text at position (10, 5)
|
|
42
|
+
hello = animpy.Text("Hello, World!", 10, 5)
|
|
43
|
+
|
|
44
|
+
# Add it to the scene
|
|
45
|
+
scene.add(hello)
|
|
46
|
+
|
|
47
|
+
# Render it to the screen
|
|
48
|
+
scene.render()
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Complete Guide
|
|
52
|
+
|
|
53
|
+
### `addFrame()`
|
|
54
|
+
|
|
55
|
+
This is the simplest way to clear the terminal screen. It returns an ANSI code that clears everything and moves the cursor back to the top-left corner. Great if you're building your own animation loop.
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
print(animpy.addFrame()) # Clears the screen
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Colors and Styling with `ANSI`
|
|
62
|
+
|
|
63
|
+
The `ANSI` dictionary has everything you need for styling text. Just add the code before your text and use `'reset'` to go back to normal.
|
|
64
|
+
|
|
65
|
+
**Available colors:**
|
|
66
|
+
- **Regular**: black, red, green, yellow, blue, magenta, cyan, white
|
|
67
|
+
- **Bright**: bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white
|
|
68
|
+
- **Backgrounds**: bg_black, bg_red, bg_green, bg_yellow, bg_blue, bg_magenta, bg_cyan, bg_white
|
|
69
|
+
- **Bright backgrounds**: bg_bright_black, bg_bright_red, bg_bright_green, bg_bright_yellow, bg_bright_blue, bg_bright_magenta, bg_bright_cyan, bg_bright_white
|
|
70
|
+
- **Text styles**: bold, dim, italic, underline, blink, reverse, hidden, strikethrough
|
|
71
|
+
|
|
72
|
+
**Example:**
|
|
73
|
+
```python
|
|
74
|
+
import animpy
|
|
75
|
+
|
|
76
|
+
# Simple color example
|
|
77
|
+
text = animpy.ANSI['red'] + 'Error!' + animpy.ANSI['reset']
|
|
78
|
+
print(text)
|
|
79
|
+
|
|
80
|
+
# Combining styles
|
|
81
|
+
fancy = animpy.ANSI['bold'] + animpy.ANSI['bright_blue'] + 'AWESOME' + animpy.ANSI['reset']
|
|
82
|
+
print(fancy)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### The `Text` Class
|
|
86
|
+
|
|
87
|
+
This is where the animation magic happens. `Text` objects represent text that you can position and animate.
|
|
88
|
+
|
|
89
|
+
**Creating text:**
|
|
90
|
+
```python
|
|
91
|
+
# Simple static text at position (x=10, y=5)
|
|
92
|
+
text = animpy.Text("Hello", 10, 5)
|
|
93
|
+
|
|
94
|
+
# Or create animation frames with a list of strings
|
|
95
|
+
animation = animpy.Text(["Frame 1", "Frame 2", "Frame 3"], 10, 5)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Methods:**
|
|
99
|
+
|
|
100
|
+
- **`moveX(newX)`** – Move the text to a new X position
|
|
101
|
+
```python
|
|
102
|
+
text.moveX(20) # Move to x=20
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
- **`moveY(newY)`** – Move the text to a new Y position
|
|
106
|
+
```python
|
|
107
|
+
text.moveY(10) # Move to y=10
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- **`change_frame()`** – Go to the next frame in a frame-by-frame animation (only works if you created it with a list)
|
|
111
|
+
```python
|
|
112
|
+
animation.change_frame() # Switch to the next frame
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### The `Scene` Class
|
|
116
|
+
|
|
117
|
+
A scene holds all your text elements and renders them to the screen at once.
|
|
118
|
+
|
|
119
|
+
**Creating and using:**
|
|
120
|
+
```python
|
|
121
|
+
scene = animpy.Scene()
|
|
122
|
+
|
|
123
|
+
# Add multiple text objects
|
|
124
|
+
text1 = animpy.Text("First", 5, 2)
|
|
125
|
+
text2 = animpy.Text("Second", 10, 5)
|
|
126
|
+
|
|
127
|
+
scene.add(text1, text2)
|
|
128
|
+
|
|
129
|
+
# Render everything to the screen
|
|
130
|
+
scene.render()
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Methods:**
|
|
134
|
+
|
|
135
|
+
- **`add(*items)`** – Add one or more Text objects to the scene
|
|
136
|
+
```python
|
|
137
|
+
scene.add(text1, text2, text3) # Add multiple at once
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
- **`render()`** – Draw all text objects to the screen in their current positions
|
|
141
|
+
```python
|
|
142
|
+
scene.render() # Shows everything on screen
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Full Animation Example
|
|
146
|
+
|
|
147
|
+
Here's a complete example showing how to create a simple animation:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
import animpy
|
|
151
|
+
import time
|
|
152
|
+
|
|
153
|
+
# Create a scene
|
|
154
|
+
scene = animpy.Scene()
|
|
155
|
+
|
|
156
|
+
# Create animated text (multiple frames)
|
|
157
|
+
frames = ["Moving...", " Moving...", " Moving...", " Moving..."]
|
|
158
|
+
moving_text = animpy.Text(frames, 1, 5)
|
|
159
|
+
|
|
160
|
+
# Create a title that stays still
|
|
161
|
+
title = animpy.Text(animpy.ANSI['bold'] + animpy.ANSI['cyan'] + "Animation Demo" + animpy.ANSI['reset'], 5, 1)
|
|
162
|
+
|
|
163
|
+
# Add both to the scene
|
|
164
|
+
scene.add(title, moving_text)
|
|
165
|
+
|
|
166
|
+
# Animation loop
|
|
167
|
+
for i in range(20):
|
|
168
|
+
scene.render()
|
|
169
|
+
moving_text.change_frame() # Next frame
|
|
170
|
+
time.sleep(0.2) # Wait 200ms
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
See LICENSE for details.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
animpy
|
animpy-1.0.0/animpy.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import os, sys, time, atexit
|
|
2
|
+
|
|
3
|
+
sys.stdout.write("\033[?25l")
|
|
4
|
+
atexit.register(lambda: (sys.stdout.write("\033[?25h"), sys.stdout.flush()))
|
|
5
|
+
|
|
6
|
+
def addFrame():
|
|
7
|
+
return "\033[2J\033[H"
|
|
8
|
+
|
|
9
|
+
ANSI = {
|
|
10
|
+
# Reset
|
|
11
|
+
"reset": "\033[0m",
|
|
12
|
+
|
|
13
|
+
# Regular colors
|
|
14
|
+
"black": "\033[30m",
|
|
15
|
+
"red": "\033[31m",
|
|
16
|
+
"green": "\033[32m",
|
|
17
|
+
"yellow": "\033[33m",
|
|
18
|
+
"blue": "\033[34m",
|
|
19
|
+
"magenta": "\033[35m",
|
|
20
|
+
"cyan": "\033[36m",
|
|
21
|
+
"white": "\033[37m",
|
|
22
|
+
|
|
23
|
+
# Bright colors
|
|
24
|
+
"bright_black": "\033[90m",
|
|
25
|
+
"bright_red": "\033[91m",
|
|
26
|
+
"bright_green": "\033[92m",
|
|
27
|
+
"bright_yellow": "\033[93m",
|
|
28
|
+
"bright_blue": "\033[94m",
|
|
29
|
+
"bright_magenta": "\033[95m",
|
|
30
|
+
"bright_cyan": "\033[96m",
|
|
31
|
+
"bright_white": "\033[97m",
|
|
32
|
+
|
|
33
|
+
# Backgrounds
|
|
34
|
+
"bg_black": "\033[40m",
|
|
35
|
+
"bg_red": "\033[41m",
|
|
36
|
+
"bg_green": "\033[42m",
|
|
37
|
+
"bg_yellow": "\033[43m",
|
|
38
|
+
"bg_blue": "\033[44m",
|
|
39
|
+
"bg_magenta": "\033[45m",
|
|
40
|
+
"bg_cyan": "\033[46m",
|
|
41
|
+
"bg_white": "\033[47m",
|
|
42
|
+
|
|
43
|
+
# Bright backgrounds
|
|
44
|
+
"bg_bright_black": "\033[100m",
|
|
45
|
+
"bg_bright_red": "\033[101m",
|
|
46
|
+
"bg_bright_green": "\033[102m",
|
|
47
|
+
"bg_bright_yellow": "\033[103m",
|
|
48
|
+
"bg_bright_blue": "\033[104m",
|
|
49
|
+
"bg_bright_magenta": "\033[105m",
|
|
50
|
+
"bg_bright_cyan": "\033[106m",
|
|
51
|
+
"bg_bright_white": "\033[107m",
|
|
52
|
+
|
|
53
|
+
# Styles
|
|
54
|
+
"bold": "\033[1m",
|
|
55
|
+
"dim": "\033[2m",
|
|
56
|
+
"italic": "\033[3m",
|
|
57
|
+
"underline": "\033[4m",
|
|
58
|
+
"blink": "\033[5m",
|
|
59
|
+
"reverse": "\033[7m",
|
|
60
|
+
"hidden": "\033[8m",
|
|
61
|
+
"strikethrough": "\033[9m",
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
sys.stdout.write("\033[?25l")
|
|
65
|
+
atexit.register(lambda: (sys.stdout.write("\033[?25h"), sys.stdout.flush()))
|
|
66
|
+
|
|
67
|
+
class Text:
|
|
68
|
+
def __init__(self, text: str | list[str], x: int, y: int) -> None:
|
|
69
|
+
self.x = x
|
|
70
|
+
self.y = y
|
|
71
|
+
|
|
72
|
+
if isinstance(text, list):
|
|
73
|
+
self.text_list = text # store the list
|
|
74
|
+
self.current_frame = 0
|
|
75
|
+
self.text = text[0] # current visible text
|
|
76
|
+
else:
|
|
77
|
+
self.text_list = None
|
|
78
|
+
self.text = text
|
|
79
|
+
|
|
80
|
+
def moveX(self, newX: int) -> None:
|
|
81
|
+
self.x = newX
|
|
82
|
+
|
|
83
|
+
def moveY(self, newY: int) -> None:
|
|
84
|
+
self.y = newY
|
|
85
|
+
|
|
86
|
+
def change_frame(self) -> None:
|
|
87
|
+
if self.text_list:
|
|
88
|
+
self.current_frame = (self.current_frame + 1) % len(self.text_list)
|
|
89
|
+
self.text = self.text_list[self.current_frame]
|
|
90
|
+
|
|
91
|
+
class Scene:
|
|
92
|
+
def __init__(self) -> None:
|
|
93
|
+
self.items = []
|
|
94
|
+
|
|
95
|
+
def add(self, *items: Text) -> None:
|
|
96
|
+
for item in items:
|
|
97
|
+
self.items.append(item)
|
|
98
|
+
|
|
99
|
+
def render(self):
|
|
100
|
+
buf = []
|
|
101
|
+
buf.append("\033[2J\033[H")
|
|
102
|
+
for item in self.items:
|
|
103
|
+
buf.append(f"\033[{item.y + 1};{item.x + 1}H{item.text}")
|
|
104
|
+
sys.stdout.write("".join(buf))
|
|
105
|
+
sys.stdout.flush()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "animpy"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "A simple terminal animation library"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "yourname"}
|
|
7
|
+
]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.8"
|
|
10
|
+
license = {file = "LICENSE"}
|
|
11
|
+
|
|
12
|
+
[build-system]
|
|
13
|
+
requires = ["setuptools"]
|
|
14
|
+
build-backend = "setuptools.build_meta"
|
animpy-1.0.0/setup.cfg
ADDED