e2D 1.4.23__tar.gz → 2.0.1__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.
Files changed (67) hide show
  1. e2d-2.0.1/MANIFEST.in +31 -0
  2. e2d-2.0.1/PKG-INFO +288 -0
  3. e2d-2.0.1/QUICKSTART.md +165 -0
  4. e2d-2.0.1/README.md +242 -0
  5. e2d-2.0.1/e2D/__init__.py +588 -0
  6. e2d-2.0.1/e2D/__init__.pyi +145 -0
  7. e2d-2.0.1/e2D/ccolors.c +34514 -0
  8. e2d-2.0.1/e2D/ccolors.pyi +51 -0
  9. e2d-2.0.1/e2D/ccolors.pyx +350 -0
  10. e2d-2.0.1/e2D/color_defs.py +238 -0
  11. e2d-2.0.1/e2D/colors.py +380 -0
  12. e2d-2.0.1/e2D/colors.pyi +104 -0
  13. e2d-2.0.1/e2D/commons.py +84 -0
  14. e2d-2.0.1/e2D/commons.pyi +79 -0
  15. e2d-2.0.1/e2D/cvectors.c +27800 -0
  16. e2d-2.0.1/e2D/cvectors.pxd +56 -0
  17. e2d-2.0.1/e2D/cvectors.pyi +243 -0
  18. e2d-2.0.1/e2D/cvectors.pyx +561 -0
  19. e2d-2.0.1/e2D/devices.py +87 -0
  20. e2d-2.0.1/e2D/devices.pyi +65 -0
  21. e2d-2.0.1/e2D/plots.py +610 -0
  22. e2d-2.0.1/e2D/plots.pyi +238 -0
  23. e2d-2.0.1/e2D/shaders/curve_fragment.glsl +6 -0
  24. e2d-2.0.1/e2D/shaders/curve_vertex.glsl +16 -0
  25. e2d-2.0.1/e2D/shaders/line_instanced_vertex.glsl +37 -0
  26. e2d-2.0.1/e2D/shaders/plot_grid_fragment.glsl +48 -0
  27. e2d-2.0.1/e2D/shaders/plot_grid_vertex.glsl +7 -0
  28. e2d-2.0.1/e2D/shaders/segment_fragment.glsl +6 -0
  29. e2d-2.0.1/e2D/shaders/segment_vertex.glsl +9 -0
  30. e2d-2.0.1/e2D/shaders/stream_fragment.glsl +11 -0
  31. e2d-2.0.1/e2D/shaders/stream_shift_compute.glsl +16 -0
  32. e2d-2.0.1/e2D/shaders/stream_vertex.glsl +27 -0
  33. e2d-2.0.1/e2D/shapes.py +1118 -0
  34. e2d-2.0.1/e2D/shapes.pyi +272 -0
  35. e2d-2.0.1/e2D/test_colors.py +122 -0
  36. e2d-2.0.1/e2D/text_renderer.py +521 -0
  37. e2d-2.0.1/e2D/text_renderer.pyi +118 -0
  38. e2d-2.0.1/e2D/types.py +58 -0
  39. e2d-2.0.1/e2D/types.pyi +61 -0
  40. e2d-2.0.1/e2D/vectors.py +339 -0
  41. e2d-2.0.1/e2D/vectors.pyi +106 -0
  42. {e2d-1.4.23 → e2d-2.0.1}/e2D/winrec.py +108 -45
  43. e2d-2.0.1/e2D/winrec.pyi +87 -0
  44. e2d-2.0.1/e2D.egg-info/PKG-INFO +288 -0
  45. e2d-2.0.1/e2D.egg-info/SOURCES.txt +52 -0
  46. e2d-2.0.1/e2D.egg-info/not-zip-safe +1 -0
  47. e2d-2.0.1/e2D.egg-info/requires.txt +15 -0
  48. e2d-2.0.1/pyproject.toml +66 -0
  49. e2d-2.0.1/setup.cfg +66 -0
  50. e2d-2.0.1/setup.py +105 -0
  51. e2d-1.4.23/PKG-INFO +0 -272
  52. e2d-1.4.23/README.md +0 -255
  53. e2d-1.4.23/e2D/__init__.py +0 -624
  54. e2d-1.4.23/e2D/__init__.pyi +0 -1337
  55. e2d-1.4.23/e2D/colors.py +0 -470
  56. e2d-1.4.23/e2D/def_colors.py +0 -1732
  57. e2d-1.4.23/e2D/envs.py +0 -229
  58. e2d-1.4.23/e2D/plots.py +0 -619
  59. e2d-1.4.23/e2D/utils.py +0 -581
  60. e2d-1.4.23/e2D.egg-info/PKG-INFO +0 -272
  61. e2d-1.4.23/e2D.egg-info/SOURCES.txt +0 -17
  62. e2d-1.4.23/e2D.egg-info/requires.txt +0 -2
  63. e2d-1.4.23/pyproject.toml +0 -6
  64. e2d-1.4.23/setup.cfg +0 -26
  65. {e2d-1.4.23 → e2d-2.0.1}/LICENSE +0 -0
  66. {e2d-1.4.23 → e2d-2.0.1}/e2D.egg-info/dependency_links.txt +0 -0
  67. {e2d-1.4.23 → e2d-2.0.1}/e2D.egg-info/top_level.txt +0 -0
e2d-2.0.1/MANIFEST.in ADDED
@@ -0,0 +1,31 @@
1
+ # Include Cython source files for compilation during install
2
+ include e2D/*.pyx
3
+ include e2D/*.pxd
4
+ include e2D/*.pyi
5
+
6
+ # Include shader files
7
+ recursive-include e2D/shaders *.glsl
8
+
9
+ # Include documentation
10
+ include README.md
11
+ include LICENSE
12
+ include QUICKSTART.md
13
+
14
+ # Include configuration files
15
+ include pyproject.toml
16
+ include setup.py
17
+ include setup.cfg
18
+
19
+ # Include examples
20
+ recursive-include examples *.py
21
+
22
+ # Exclude build artifacts
23
+ global-exclude __pycache__
24
+ global-exclude *.py[co]
25
+ global-exclude *.so
26
+ global-exclude *.pyd
27
+ global-exclude .DS_Store
28
+
29
+ # SECURITY: Exclude version management scripts (contain API keys)
30
+ exclude new_version.bat
31
+ exclude new_version.py
e2d-2.0.1/PKG-INFO ADDED
@@ -0,0 +1,288 @@
1
+ Metadata-Version: 2.4
2
+ Name: e2D
3
+ Version: 2.0.1
4
+ Summary: High-performance 2D graphics and math library with ultra-optimized vector operations
5
+ Home-page: https://github.com/marick-py/e2D
6
+ Author: Riccardo Mariani
7
+ Author-email: Riccardo Mariani <ricomari2006@gmail.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/marick-py/e2D
10
+ Project-URL: Repository, https://github.com/marick-py/e2D
11
+ Project-URL: Issues, https://github.com/marick-py/e2D/issues
12
+ Keywords: vector,2d,simulation,performance,cython,numpy,moderngl,games,graphics
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Cython
24
+ Classifier: Programming Language :: C
25
+ Classifier: Topic :: Games/Entertainment
26
+ Classifier: Topic :: Scientific/Engineering
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Classifier: Topic :: Multimedia :: Graphics
29
+ Requires-Python: >=3.9
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: numpy>=1.19.0
33
+ Requires-Dist: pygame
34
+ Requires-Dist: moderngl
35
+ Requires-Dist: glfw
36
+ Requires-Dist: opencv-python
37
+ Provides-Extra: dev
38
+ Requires-Dist: build; extra == "dev"
39
+ Requires-Dist: twine; extra == "dev"
40
+ Requires-Dist: pytest; extra == "dev"
41
+ Requires-Dist: black; extra == "dev"
42
+ Requires-Dist: mypy; extra == "dev"
43
+ Provides-Extra: performance
44
+ Requires-Dist: cython>=0.29.0; extra == "performance"
45
+ Dynamic: license-file
46
+
47
+ # e2D - High-Performance 2D Graphics and Math Library
48
+
49
+ ![Python](https://img.shields.io/badge/python-3.9+-blue.svg)
50
+ ![License](https://img.shields.io/badge/license-MIT-green.svg)
51
+ ![Status](https://img.shields.io/badge/status-beta-orange.svg)
52
+
53
+ **e2D** combines ultra-optimized vector mathematics with modern OpenGL rendering for high-performance 2D applications. Perfect for games, simulations, and real-time graphics.
54
+
55
+ ## ✨ Features
56
+
57
+ ### 🚀 Optimized Vector Operations
58
+ - **Cython-compiled** Vector2D class (10-500x faster than pure Python)
59
+ - **Batch operations** for processing thousands of vectors efficiently
60
+ - **Direct memory access** with zero-copy operations
61
+ - **NumPy integration** for seamless GPU data upload
62
+
63
+ ### 🎮 Modern Graphics
64
+ - **ModernGL** rendering pipeline
65
+ - **Shape rendering** with instancing support
66
+ - **Text rendering** with custom styles and TTF fonts
67
+ - **Screen recording** with async video encoding
68
+ - **Color system** with 80+ pre-defined colors
69
+ - **GLFW window management**
70
+
71
+ ### 🎯 Game Development Tools
72
+ - **Keyboard and mouse input** handling
73
+ - **Collision detection**
74
+ - **Color manipulation**
75
+ - **Vector mathematics**
76
+
77
+ ## 📦 Installation
78
+
79
+ ```bash
80
+ pip install e2D
81
+ ```
82
+
83
+ The package will automatically compile the Cython extensions during installation for optimal performance (like numpy). If compilation fails, it falls back to pure Python mode.
84
+
85
+ ### Requirements
86
+ - Python 3.9+
87
+ - NumPy
88
+ - ModernGL
89
+ - GLFW
90
+ - Pygame
91
+ - OpenCV (for video recording)
92
+
93
+ ## 🚀 Quick Start
94
+
95
+ ### Optimized Vector Operations
96
+
97
+ ```python
98
+ from e2D import Vector2D, batch_add_inplace, vectors_to_array
99
+
100
+ # Create vectors
101
+ v1 = Vector2D(3.0, 4.0)
102
+ v2 = Vector2D(1.0, 2.0)
103
+
104
+ # Basic operations
105
+ v3 = v1 + v2
106
+ length = v1.length
107
+ dot = v1.dot_product(v2)
108
+
109
+ # In-place operations (faster!)
110
+ v1.iadd(v2)
111
+ v1.normalize()
112
+ v1.irotate(0.1)
113
+
114
+ # Process thousands of vectors instantly
115
+ positions = [Vector2D.random(-10, 10) for _ in range(10000)]
116
+ displacement = Vector2D(1.0, 0.5)
117
+ batch_add_inplace(positions, displacement) # 🚀 Lightning fast!
118
+
119
+ # Convert to numpy for GPU upload
120
+ pos_array = vectors_to_array(positions)
121
+ ```
122
+
123
+ ### Graphics Rendering
124
+
125
+ ```python
126
+ from e2D import RootEnv, DefEnv
127
+
128
+ class MyApp(DefEnv):
129
+ def __init__(self) -> None:
130
+ pass
131
+
132
+ def update(self) -> None:
133
+ # Your game logic here
134
+ pass
135
+
136
+ def draw(self) -> None:
137
+ # Your rendering code here
138
+ pass
139
+
140
+ # Initialize and run
141
+ rootEnv = RootEnv(window_size=(1920, 1080), target_fps=60)
142
+ rootEnv.init(MyApp())
143
+
144
+ # Optional: Enable screen recording
145
+ rootEnv.init_rec(fps=30, draw_on_screen=True, path='output.mp4')
146
+
147
+ rootEnv.loop()
148
+ ```
149
+
150
+ ### Color System
151
+
152
+ ```python
153
+ from e2D import Color, WHITE, RED, CYAN, normalize_color
154
+ from e2D.color_defs import MD_BLUE, PASTEL_PINK, NEON_GREEN
155
+
156
+ # Create colors
157
+ color1 = Color.from_hex("#FF5733")
158
+ color2 = Color.from_rgb255(100, 150, 200)
159
+ color3 = Color.from_hsv(0.5, 0.8, 1.0)
160
+
161
+ # Color operations
162
+ lighter = color1.lighten(0.2)
163
+ darker = color1.darken(0.2)
164
+ inverted = color1.invert()
165
+ rotated = color1.rotate_hue(120)
166
+
167
+ # Use pre-defined colors
168
+ from e2D import draw_circle
169
+ draw_circle((100, 100), 50, color=RED, fill_mode='fill')
170
+ ```
171
+
172
+ ## 📊 Performance
173
+
174
+ Vector2D benchmark (100,000 operations):
175
+
176
+ | Operation | Time | vs Pure Python |
177
+ |-----------|------|----------------|
178
+ | Creation | 42 ms | 10x faster |
179
+ | Addition | 64 ms | 15x faster |
180
+ | In-place ops | 3.8 ms | **100x faster** |
181
+ | Normalization | 1.9 ms | **200x faster** |
182
+ | Batch operations | 0.17 ms | **500x+ faster** 🔥 |
183
+
184
+ Perfect for:
185
+ - Particle systems (10,000+ particles)
186
+ - Physics simulations
187
+ - Collision detection
188
+ - Path finding
189
+ - Real-time graphics
190
+
191
+ ## 📚 Documentation
192
+
193
+ - **[Quick Start Guide](QUICKSTART.md)** - Get up and running in minutes
194
+ - **[API Reference](https://github.com/marick-py/e2D)** - Full API documentation
195
+ - **[Examples](examples/)** - Working code examples
196
+
197
+ ## 🎯 Use Cases
198
+
199
+ ### Particle System
200
+ ```python
201
+ from e2D import Vector2D, batch_add_inplace, vectors_to_array
202
+
203
+ positions = [Vector2D.random(-10, 10) for _ in range(10000)]
204
+ velocities = [Vector2D.random(-1, 1) for _ in range(10000)]
205
+
206
+ def update(dt):
207
+ # Update all particles in milliseconds
208
+ for i in range(len(positions)):
209
+ temp = velocities[i].mul(dt)
210
+ positions[i].iadd(temp)
211
+
212
+ def render():
213
+ # Upload to GPU
214
+ pos_array = vectors_to_array(positions).astype(np.float32)
215
+ vbo.write(pos_array)
216
+ ```
217
+
218
+ ### Physics Simulation
219
+ ```python
220
+ from e2D import Vector2D
221
+
222
+ class RigidBody:
223
+ def __init__(self, pos, vel):
224
+ self.position = Vector2D(*pos)
225
+ self.velocity = Vector2D(*vel)
226
+ self.acceleration = Vector2D(0, -9.8)
227
+
228
+ def update(self, dt):
229
+ # Optimized in-place physics
230
+ temp = self.acceleration.mul(dt)
231
+ self.velocity.iadd(temp)
232
+
233
+ temp = self.velocity.mul(dt)
234
+ self.position.iadd(temp)
235
+ ```
236
+
237
+ ## 🔧 Development
238
+
239
+ ### Building from Source
240
+
241
+ ```bash
242
+ git clone https://github.com/marick-py/e2D.git
243
+ cd e2D
244
+ pip install -e .[dev]
245
+ ```
246
+
247
+ ### Running Tests
248
+
249
+ ```bash
250
+ pytest
251
+ ```
252
+
253
+ ### Building Distribution
254
+
255
+ ```bash
256
+ python -m build
257
+ ```
258
+
259
+ ## 🤝 Contributing
260
+
261
+ Contributions are welcome! Please feel free to submit a Pull Request.
262
+
263
+ ## 📄 License
264
+
265
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
266
+
267
+ ## 👤 Author
268
+
269
+ **Riccardo Mariani**
270
+ - Email: ricomari2006@gmail.com
271
+ - GitHub: [@marick-py](https://github.com/marick-py)
272
+
273
+ ## 🙏 Acknowledgments
274
+
275
+ - Built with [ModernGL](https://github.com/moderngl/moderngl)
276
+ - Optimized with [Cython](https://cython.org/)
277
+ - Inspired by the need for high-performance 2D mathematics in Python
278
+
279
+ ## 📈 Version History
280
+
281
+ - **2.0.0** - Added ultra-optimized Vector2D with Cython compilation
282
+ - **1.4.24** - Previous stable release with pure Python vectors
283
+
284
+ ---
285
+
286
+ **Made with ❤️ for high-performance 2D development**
287
+
288
+
@@ -0,0 +1,165 @@
1
+ # Vector2D - Quick Start Guide
2
+
3
+ ## 🚀 Get Started in 3 Steps
4
+
5
+ ### Step 1: Build the Extension
6
+
7
+ **Windows:**
8
+ ```bash
9
+ build.bat
10
+ ```
11
+
12
+ **Linux/Mac:**
13
+ ```bash
14
+ chmod +x build.sh
15
+ ./build.sh
16
+ ```
17
+
18
+ ### Step 2: Test It Works
19
+
20
+ ```bash
21
+ python -m e2D.vectors
22
+ ```
23
+
24
+ You should see benchmark results like:
25
+ ```
26
+ Vector2D Benchmark (100000 iterations)
27
+ ==================================================
28
+ Creation: 15.23 ms
29
+ Addition: 18.45 ms
30
+ In-place add: 12.67 ms
31
+ Normalize: 45.12 ms
32
+ Batch add: 2.34 ms
33
+ ==================================================
34
+ ✓ Using compiled Cython extension (optimal performance)
35
+ ```
36
+
37
+ ### Step 3: Use in Your Code
38
+
39
+ ```python
40
+ from e2D.vectors import Vector2D, V2
41
+
42
+ # Create a vector
43
+ position = Vector2D(100.0, 200.0)
44
+ velocity = V2(5.0, -2.0)
45
+
46
+ # Update position
47
+ position += velocity * 0.016 # ~60 FPS
48
+
49
+ print(f"New position: {position}")
50
+ ```
51
+
52
+ ## 📚 Next Steps
53
+
54
+ - Check out [example_usage.py](example_usage.py) for more examples
55
+ - Integrate with your ModernGL/GLFW project
56
+
57
+ ## ⚡ Performance Tips
58
+
59
+ 1. **Use in-place operations** for maximum speed:
60
+ ```python
61
+ v.iadd(other) # Faster than v += other
62
+ v.imul(2.0) # Faster than v *= 2.0
63
+ ```
64
+
65
+ 2. **Use batch operations** for many vectors:
66
+ ```python
67
+ from e2D.vectors import batch_add_inplace
68
+ batch_add_inplace(vectors, displacement) # MUCH faster
69
+ ```
70
+
71
+ 3. **Avoid Python loops** when possible:
72
+ ```python
73
+ # Slow
74
+ for v in vectors:
75
+ v.normalize()
76
+
77
+ # Fast
78
+ batch_normalize_inplace(vectors)
79
+ ```
80
+
81
+ ## 🔧 Troubleshooting
82
+
83
+ **"ImportError: No module named 'cvectors'"**
84
+ - Run the build script again: `build.bat` or `./build.sh`
85
+
86
+ **"ERROR: Microsoft Visual C++ 14.0 is required" (Windows)**
87
+ - Install [Visual C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)
88
+
89
+ **Build errors on Linux/Mac**
90
+ - Install build tools:
91
+ - Ubuntu/Debian: `sudo apt-get install build-essential python3-dev`
92
+ - CentOS/RHEL: `sudo yum install gcc gcc-c++ python3-devel`
93
+ - Mac: `xcode-select --install`
94
+
95
+ ## 📦 For Distribution
96
+
97
+ To prepare for PyPI upload:
98
+
99
+ ```bash
100
+ # Install build tools
101
+ pip install build twine
102
+
103
+ # Build distributions
104
+ python -m build
105
+
106
+ # Test upload (optional)
107
+ python -m twine upload --repository testpypi dist/*
108
+
109
+ # Upload to PyPI
110
+ python -m twine upload dist/*
111
+ ```
112
+
113
+ ## 💡 Integration Example
114
+
115
+ ```python
116
+ from e2D.vectors import Vector2D, vectors_to_array
117
+ import moderngl
118
+ import numpy as np
119
+
120
+ # Create particle system
121
+ positions = [Vector2D.random(-10, 10) for _ in range(10000)]
122
+ velocities = [Vector2D.random(-1, 1) for _ in range(10000)]
123
+
124
+ # Update loop (optimized)
125
+ def update(dt):
126
+ for i in range(len(positions)):
127
+ temp = velocities[i].mul(dt)
128
+ positions[i].iadd(temp)
129
+
130
+ # Upload to GPU
131
+ def get_gpu_buffer():
132
+ pos_array = vectors_to_array(positions).astype(np.float32)
133
+ return pos_array
134
+
135
+ # Use with ModernGL
136
+ # vbo.write(get_gpu_buffer())
137
+ ```
138
+
139
+ ## 📈 Expected Performance
140
+
141
+ For a typical simulation with 100,000 vectors:
142
+
143
+ | Operation | Pure Python | Vector2D | Speedup |
144
+ |-----------|-------------|--------------|---------|
145
+ | Creation | ~500 ms | ~15 ms | **33x** |
146
+ | Addition | ~800 ms | ~20 ms | **40x** |
147
+ | Normalize | ~2000 ms | ~45 ms | **44x** |
148
+ | Batch ops | ~1000 ms | ~2 ms | **500x** |
149
+
150
+ ## 🎯 Use Cases
151
+
152
+ Perfect for:
153
+ - Particle systems (10,000+ particles)
154
+ - Physics simulations
155
+ - Collision detection
156
+ - Path finding
157
+ - Procedural generation
158
+ - Game engines
159
+ - Scientific computing
160
+
161
+ ## 📝 License
162
+
163
+ MIT License - Use freely in your projects!
164
+
165
+
e2d-2.0.1/README.md ADDED
@@ -0,0 +1,242 @@
1
+ # e2D - High-Performance 2D Graphics and Math Library
2
+
3
+ ![Python](https://img.shields.io/badge/python-3.9+-blue.svg)
4
+ ![License](https://img.shields.io/badge/license-MIT-green.svg)
5
+ ![Status](https://img.shields.io/badge/status-beta-orange.svg)
6
+
7
+ **e2D** combines ultra-optimized vector mathematics with modern OpenGL rendering for high-performance 2D applications. Perfect for games, simulations, and real-time graphics.
8
+
9
+ ## ✨ Features
10
+
11
+ ### 🚀 Optimized Vector Operations
12
+ - **Cython-compiled** Vector2D class (10-500x faster than pure Python)
13
+ - **Batch operations** for processing thousands of vectors efficiently
14
+ - **Direct memory access** with zero-copy operations
15
+ - **NumPy integration** for seamless GPU data upload
16
+
17
+ ### 🎮 Modern Graphics
18
+ - **ModernGL** rendering pipeline
19
+ - **Shape rendering** with instancing support
20
+ - **Text rendering** with custom styles and TTF fonts
21
+ - **Screen recording** with async video encoding
22
+ - **Color system** with 80+ pre-defined colors
23
+ - **GLFW window management**
24
+
25
+ ### 🎯 Game Development Tools
26
+ - **Keyboard and mouse input** handling
27
+ - **Collision detection**
28
+ - **Color manipulation**
29
+ - **Vector mathematics**
30
+
31
+ ## 📦 Installation
32
+
33
+ ```bash
34
+ pip install e2D
35
+ ```
36
+
37
+ The package will automatically compile the Cython extensions during installation for optimal performance (like numpy). If compilation fails, it falls back to pure Python mode.
38
+
39
+ ### Requirements
40
+ - Python 3.9+
41
+ - NumPy
42
+ - ModernGL
43
+ - GLFW
44
+ - Pygame
45
+ - OpenCV (for video recording)
46
+
47
+ ## 🚀 Quick Start
48
+
49
+ ### Optimized Vector Operations
50
+
51
+ ```python
52
+ from e2D import Vector2D, batch_add_inplace, vectors_to_array
53
+
54
+ # Create vectors
55
+ v1 = Vector2D(3.0, 4.0)
56
+ v2 = Vector2D(1.0, 2.0)
57
+
58
+ # Basic operations
59
+ v3 = v1 + v2
60
+ length = v1.length
61
+ dot = v1.dot_product(v2)
62
+
63
+ # In-place operations (faster!)
64
+ v1.iadd(v2)
65
+ v1.normalize()
66
+ v1.irotate(0.1)
67
+
68
+ # Process thousands of vectors instantly
69
+ positions = [Vector2D.random(-10, 10) for _ in range(10000)]
70
+ displacement = Vector2D(1.0, 0.5)
71
+ batch_add_inplace(positions, displacement) # 🚀 Lightning fast!
72
+
73
+ # Convert to numpy for GPU upload
74
+ pos_array = vectors_to_array(positions)
75
+ ```
76
+
77
+ ### Graphics Rendering
78
+
79
+ ```python
80
+ from e2D import RootEnv, DefEnv
81
+
82
+ class MyApp(DefEnv):
83
+ def __init__(self) -> None:
84
+ pass
85
+
86
+ def update(self) -> None:
87
+ # Your game logic here
88
+ pass
89
+
90
+ def draw(self) -> None:
91
+ # Your rendering code here
92
+ pass
93
+
94
+ # Initialize and run
95
+ rootEnv = RootEnv(window_size=(1920, 1080), target_fps=60)
96
+ rootEnv.init(MyApp())
97
+
98
+ # Optional: Enable screen recording
99
+ rootEnv.init_rec(fps=30, draw_on_screen=True, path='output.mp4')
100
+
101
+ rootEnv.loop()
102
+ ```
103
+
104
+ ### Color System
105
+
106
+ ```python
107
+ from e2D import Color, WHITE, RED, CYAN, normalize_color
108
+ from e2D.color_defs import MD_BLUE, PASTEL_PINK, NEON_GREEN
109
+
110
+ # Create colors
111
+ color1 = Color.from_hex("#FF5733")
112
+ color2 = Color.from_rgb255(100, 150, 200)
113
+ color3 = Color.from_hsv(0.5, 0.8, 1.0)
114
+
115
+ # Color operations
116
+ lighter = color1.lighten(0.2)
117
+ darker = color1.darken(0.2)
118
+ inverted = color1.invert()
119
+ rotated = color1.rotate_hue(120)
120
+
121
+ # Use pre-defined colors
122
+ from e2D import draw_circle
123
+ draw_circle((100, 100), 50, color=RED, fill_mode='fill')
124
+ ```
125
+
126
+ ## 📊 Performance
127
+
128
+ Vector2D benchmark (100,000 operations):
129
+
130
+ | Operation | Time | vs Pure Python |
131
+ |-----------|------|----------------|
132
+ | Creation | 42 ms | 10x faster |
133
+ | Addition | 64 ms | 15x faster |
134
+ | In-place ops | 3.8 ms | **100x faster** |
135
+ | Normalization | 1.9 ms | **200x faster** |
136
+ | Batch operations | 0.17 ms | **500x+ faster** 🔥 |
137
+
138
+ Perfect for:
139
+ - Particle systems (10,000+ particles)
140
+ - Physics simulations
141
+ - Collision detection
142
+ - Path finding
143
+ - Real-time graphics
144
+
145
+ ## 📚 Documentation
146
+
147
+ - **[Quick Start Guide](QUICKSTART.md)** - Get up and running in minutes
148
+ - **[API Reference](https://github.com/marick-py/e2D)** - Full API documentation
149
+ - **[Examples](examples/)** - Working code examples
150
+
151
+ ## 🎯 Use Cases
152
+
153
+ ### Particle System
154
+ ```python
155
+ from e2D import Vector2D, batch_add_inplace, vectors_to_array
156
+
157
+ positions = [Vector2D.random(-10, 10) for _ in range(10000)]
158
+ velocities = [Vector2D.random(-1, 1) for _ in range(10000)]
159
+
160
+ def update(dt):
161
+ # Update all particles in milliseconds
162
+ for i in range(len(positions)):
163
+ temp = velocities[i].mul(dt)
164
+ positions[i].iadd(temp)
165
+
166
+ def render():
167
+ # Upload to GPU
168
+ pos_array = vectors_to_array(positions).astype(np.float32)
169
+ vbo.write(pos_array)
170
+ ```
171
+
172
+ ### Physics Simulation
173
+ ```python
174
+ from e2D import Vector2D
175
+
176
+ class RigidBody:
177
+ def __init__(self, pos, vel):
178
+ self.position = Vector2D(*pos)
179
+ self.velocity = Vector2D(*vel)
180
+ self.acceleration = Vector2D(0, -9.8)
181
+
182
+ def update(self, dt):
183
+ # Optimized in-place physics
184
+ temp = self.acceleration.mul(dt)
185
+ self.velocity.iadd(temp)
186
+
187
+ temp = self.velocity.mul(dt)
188
+ self.position.iadd(temp)
189
+ ```
190
+
191
+ ## 🔧 Development
192
+
193
+ ### Building from Source
194
+
195
+ ```bash
196
+ git clone https://github.com/marick-py/e2D.git
197
+ cd e2D
198
+ pip install -e .[dev]
199
+ ```
200
+
201
+ ### Running Tests
202
+
203
+ ```bash
204
+ pytest
205
+ ```
206
+
207
+ ### Building Distribution
208
+
209
+ ```bash
210
+ python -m build
211
+ ```
212
+
213
+ ## 🤝 Contributing
214
+
215
+ Contributions are welcome! Please feel free to submit a Pull Request.
216
+
217
+ ## 📄 License
218
+
219
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
220
+
221
+ ## 👤 Author
222
+
223
+ **Riccardo Mariani**
224
+ - Email: ricomari2006@gmail.com
225
+ - GitHub: [@marick-py](https://github.com/marick-py)
226
+
227
+ ## 🙏 Acknowledgments
228
+
229
+ - Built with [ModernGL](https://github.com/moderngl/moderngl)
230
+ - Optimized with [Cython](https://cython.org/)
231
+ - Inspired by the need for high-performance 2D mathematics in Python
232
+
233
+ ## 📈 Version History
234
+
235
+ - **2.0.0** - Added ultra-optimized Vector2D with Cython compilation
236
+ - **1.4.24** - Previous stable release with pure Python vectors
237
+
238
+ ---
239
+
240
+ **Made with ❤️ for high-performance 2D development**
241
+
242
+