e2D 2.0.0__cp313-cp313-win_amd64.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.
e2D/vectors.py ADDED
@@ -0,0 +1,247 @@
1
+ """
2
+ High-level Python wrapper for Vector2D with additional utilities
3
+ Provides compatibility layer and convenience functions
4
+ """
5
+
6
+ try:
7
+ from .cvectors import (
8
+ Vector2D,
9
+ batch_add_inplace,
10
+ batch_scale_inplace,
11
+ batch_normalize_inplace,
12
+ vectors_to_array,
13
+ array_to_vectors,
14
+ )
15
+ _COMPILED = True
16
+ except ImportError:
17
+ print("WARNING: Compiled cvectors module not found. Please run: python setup.py build_ext --inplace")
18
+ print("Falling back to pure Python implementation (slower)")
19
+ _COMPILED = False
20
+
21
+ # Fallback implementation
22
+ import numpy as np
23
+
24
+ class Vector2D:
25
+ """Pure Python fallback (much slower than compiled version)"""
26
+ def __init__(self, x=0.0, y=0.0):
27
+ self.data = np.array([x, y], dtype=np.float64)
28
+
29
+ @property
30
+ def x(self):
31
+ return self.data[0]
32
+
33
+ @x.setter
34
+ def x(self, value):
35
+ self.data[0] = value
36
+
37
+ @property
38
+ def y(self):
39
+ return self.data[1]
40
+
41
+ @y.setter
42
+ def y(self, value):
43
+ self.data[1] = value
44
+
45
+ @property
46
+ def length(self):
47
+ return np.linalg.norm(self.data)
48
+
49
+ @property
50
+ def length_sqrd(self):
51
+ return np.dot(self.data, self.data)
52
+
53
+ def copy(self):
54
+ return Vector2D(self.x, self.y)
55
+
56
+ def __add__(self, other):
57
+ if isinstance(other, Vector2D):
58
+ return Vector2D(self.x + other.x, self.y + other.y)
59
+ return Vector2D(self.x + other, self.y + other)
60
+
61
+ def __sub__(self, other):
62
+ if isinstance(other, Vector2D):
63
+ return Vector2D(self.x - other.x, self.y - other.y)
64
+ return Vector2D(self.x - other, self.y - other)
65
+
66
+ def __mul__(self, other):
67
+ if isinstance(other, Vector2D):
68
+ return Vector2D(self.x * other.x, self.y * other.y)
69
+ return Vector2D(self.x * other, self.y * other)
70
+
71
+ def __repr__(self):
72
+ return f"Vector2D({self.x}, {self.y})"
73
+
74
+
75
+ # Convenience aliases
76
+ V2 = Vector2D
77
+ Vec2 = Vector2D
78
+
79
+
80
+ # Pre-defined common vectors (reusable instances for performance)
81
+ class CommonVectors:
82
+ """Pre-allocated common vectors (do not modify these!)"""
83
+ ZERO = Vector2D(0.0, 0.0)
84
+ ONE = Vector2D(1.0, 1.0)
85
+ UP = Vector2D(0.0, 1.0)
86
+ DOWN = Vector2D(0.0, -1.0)
87
+ LEFT = Vector2D(-1.0, 0.0)
88
+ RIGHT = Vector2D(1.0, 0.0)
89
+
90
+ @staticmethod
91
+ def zero():
92
+ """Create new zero vector"""
93
+ return Vector2D(0.0, 0.0)
94
+
95
+ @staticmethod
96
+ def one():
97
+ """Create new one vector"""
98
+ return Vector2D(1.0, 1.0)
99
+
100
+ @staticmethod
101
+ def up():
102
+ """Create new up vector"""
103
+ return Vector2D(0.0, 1.0)
104
+
105
+ @staticmethod
106
+ def down():
107
+ """Create new down vector"""
108
+ return Vector2D(0.0, -1.0)
109
+
110
+ @staticmethod
111
+ def left():
112
+ """Create new left vector"""
113
+ return Vector2D(-1.0, 0.0)
114
+
115
+ @staticmethod
116
+ def right():
117
+ """Create new right vector"""
118
+ return Vector2D(1.0, 0.0)
119
+
120
+
121
+ # Export all public API
122
+ __all__ = [
123
+ 'Vector2D',
124
+ 'V2',
125
+ 'Vec2',
126
+ 'CommonVectors',
127
+ 'batch_add_inplace',
128
+ 'batch_scale_inplace',
129
+ 'batch_normalize_inplace',
130
+ 'vectors_to_array',
131
+ 'array_to_vectors',
132
+ ]
133
+
134
+
135
+ # Additional utility functions
136
+ def lerp(start, end, t):
137
+ """Linear interpolation between two values"""
138
+ return start + (end - start) * t
139
+
140
+
141
+ def create_grid(width, height, spacing=1.0):
142
+ """
143
+ Create a grid of vectors
144
+
145
+ Args:
146
+ width: Number of columns
147
+ height: Number of rows
148
+ spacing: Distance between points
149
+
150
+ Returns:
151
+ List of Vector2D objects
152
+ """
153
+ vectors = []
154
+ for y in range(height):
155
+ for x in range(width):
156
+ vectors.append(Vector2D(x * spacing, y * spacing))
157
+ return vectors
158
+
159
+
160
+ def create_circle(radius, num_points):
161
+ """
162
+ Create vectors arranged in a circle
163
+
164
+ Args:
165
+ radius: Circle radius
166
+ num_points: Number of points
167
+
168
+ Returns:
169
+ List of Vector2D objects
170
+ """
171
+ import math
172
+ vectors = []
173
+ angle_step = 2 * math.pi / num_points
174
+ for i in range(num_points):
175
+ angle = i * angle_step
176
+ x = radius * math.cos(angle)
177
+ y = radius * math.sin(angle)
178
+ vectors.append(Vector2D(x, y))
179
+ return vectors
180
+
181
+
182
+ # Performance benchmark function
183
+ def benchmark(num_iterations=100000):
184
+ """
185
+ Run a simple benchmark to test vector performance
186
+ """
187
+ import time
188
+
189
+ print(f"Vector2D Benchmark ({num_iterations} iterations)")
190
+ print("=" * 50)
191
+
192
+ # Test 1: Vector creation
193
+ start = time.perf_counter()
194
+ for i in range(num_iterations):
195
+ v = Vector2D(1.0, 2.0)
196
+ end = time.perf_counter()
197
+ print(f"Creation: {(end - start) * 1000:.2f} ms")
198
+
199
+ # Test 2: Addition
200
+ v1 = Vector2D(1.0, 2.0)
201
+ v2 = Vector2D(3.0, 4.0)
202
+ start = time.perf_counter()
203
+ for i in range(num_iterations):
204
+ v3 = v1 + v2
205
+ end = time.perf_counter()
206
+ print(f"Addition: {(end - start) * 1000:.2f} ms")
207
+
208
+ # Test 3: In-place addition
209
+ v1 = Vector2D(1.0, 2.0)
210
+ v2 = Vector2D(3.0, 4.0)
211
+ start = time.perf_counter()
212
+ for i in range(num_iterations):
213
+ v1 += v2
214
+ v1 -= v2 # Keep value constant
215
+ end = time.perf_counter()
216
+ print(f"In-place add: {(end - start) * 1000:.2f} ms")
217
+
218
+ # Test 4: Normalization
219
+ vectors = [Vector2D(i, i+1) for i in range(1000)]
220
+ start = time.perf_counter()
221
+ for i in range(num_iterations // 1000):
222
+ for v in vectors:
223
+ v.normalize()
224
+ end = time.perf_counter()
225
+ print(f"Normalize: {(end - start) * 1000:.2f} ms")
226
+
227
+ # Test 5: Batch operations
228
+ if _COMPILED:
229
+ vectors = [Vector2D(i, i+1) for i in range(1000)]
230
+ displacement = Vector2D(1.0, 1.0)
231
+ start = time.perf_counter()
232
+ for i in range(num_iterations // 1000):
233
+ batch_add_inplace(vectors, displacement)
234
+ end = time.perf_counter()
235
+ print(f"Batch add: {(end - start) * 1000:.2f} ms")
236
+
237
+ print("=" * 50)
238
+ if _COMPILED:
239
+ print("✓ Using compiled Cython extension (optimal performance)")
240
+ else:
241
+ print("⚠ Using pure Python fallback (compile for better performance)")
242
+
243
+
244
+ if __name__ == "__main__":
245
+ # Run benchmark when executed directly
246
+ benchmark()
247
+
@@ -0,0 +1,260 @@
1
+ Metadata-Version: 2.4
2
+ Name: e2D
3
+ Version: 2.0.0
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
+ Provides-Extra: dev
37
+ Requires-Dist: build; extra == "dev"
38
+ Requires-Dist: twine; extra == "dev"
39
+ Requires-Dist: pytest; extra == "dev"
40
+ Requires-Dist: black; extra == "dev"
41
+ Requires-Dist: mypy; extra == "dev"
42
+ Provides-Extra: performance
43
+ Requires-Dist: cython>=0.29.0; extra == "performance"
44
+ Dynamic: license-file
45
+
46
+ # e2D - High-Performance 2D Graphics and Math Library
47
+
48
+ ![Python](https://img.shields.io/badge/python-3.9+-blue.svg)
49
+ ![License](https://img.shields.io/badge/license-MIT-green.svg)
50
+ ![Status](https://img.shields.io/badge/status-beta-orange.svg)
51
+
52
+ **e2D** combines ultra-optimized vector mathematics with modern OpenGL rendering for high-performance 2D applications. Perfect for games, simulations, and real-time graphics.
53
+
54
+ ## ✨ Features
55
+
56
+ ### 🚀 Optimized Vector Operations
57
+ - **Cython-compiled** Vector2D class (10-500x faster than pure Python)
58
+ - **Batch operations** for processing thousands of vectors efficiently
59
+ - **Direct memory access** with zero-copy operations
60
+ - **NumPy integration** for seamless GPU data upload
61
+
62
+ ### 🎮 Modern Graphics
63
+ - **ModernGL** rendering pipeline
64
+ - **Shape rendering** with instancing support
65
+ - **Text rendering** with custom styles
66
+ - **GLFW window management**
67
+
68
+ ### 🎯 Game Development Tools
69
+ - **Keyboard and mouse input** handling
70
+ - **Collision detection**
71
+ - **Color manipulation**
72
+ - **Vector mathematics**
73
+
74
+ ## 📦 Installation
75
+
76
+ ```bash
77
+ pip install e2D
78
+ ```
79
+
80
+ 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.
81
+
82
+ ### Requirements
83
+ - Python 3.9+
84
+ - NumPy
85
+ - ModernGL
86
+ - GLFW
87
+ - Pygame
88
+
89
+ ## 🚀 Quick Start
90
+
91
+ ### Optimized Vector Operations
92
+
93
+ ```python
94
+ from e2D import Vector2D, batch_add_inplace, vectors_to_array
95
+
96
+ # Create vectors
97
+ v1 = Vector2D(3.0, 4.0)
98
+ v2 = Vector2D(1.0, 2.0)
99
+
100
+ # Basic operations
101
+ v3 = v1 + v2
102
+ length = v1.length
103
+ dot = v1.dot_product(v2)
104
+
105
+ # In-place operations (faster!)
106
+ v1.iadd(v2)
107
+ v1.normalize()
108
+ v1.irotate(0.1)
109
+
110
+ # Process thousands of vectors instantly
111
+ positions = [Vector2D.random(-10, 10) for _ in range(10000)]
112
+ displacement = Vector2D(1.0, 0.5)
113
+ batch_add_inplace(positions, displacement) # 🚀 Lightning fast!
114
+
115
+ # Convert to numpy for GPU upload
116
+ pos_array = vectors_to_array(positions)
117
+ ```
118
+
119
+ ### Graphics Rendering
120
+
121
+ ```python
122
+ from e2D import RootEnv
123
+
124
+ class MyApp(RootEnv):
125
+ def __init__(self):
126
+ super().__init__(
127
+ window_size=(1920, 1080),
128
+ target_fps=60,
129
+ vsync=True
130
+ )
131
+
132
+ def update(self):
133
+ # Your game logic here
134
+ pass
135
+
136
+ def draw(self):
137
+ # Your rendering code here
138
+ pass
139
+
140
+ app = MyApp()
141
+ app.run()
142
+ ```
143
+
144
+ ## 📊 Performance
145
+
146
+ Vector2D benchmark (100,000 operations):
147
+
148
+ | Operation | Time | vs Pure Python |
149
+ |-----------|------|----------------|
150
+ | Creation | 42 ms | 10x faster |
151
+ | Addition | 64 ms | 15x faster |
152
+ | In-place ops | 3.8 ms | **100x faster** |
153
+ | Normalization | 1.9 ms | **200x faster** |
154
+ | Batch operations | 0.17 ms | **500x+ faster** 🔥 |
155
+
156
+ Perfect for:
157
+ - Particle systems (10,000+ particles)
158
+ - Physics simulations
159
+ - Collision detection
160
+ - Path finding
161
+ - Real-time graphics
162
+
163
+ ## 📚 Documentation
164
+
165
+ - **[Quick Start Guide](QUICKSTART.md)** - Get up and running in minutes
166
+ - **[API Reference](https://github.com/marick-py/e2D)** - Full API documentation
167
+ - **[Examples](examples/)** - Working code examples
168
+
169
+ ## 🎯 Use Cases
170
+
171
+ ### Particle System
172
+ ```python
173
+ from e2D import Vector2D, batch_add_inplace, vectors_to_array
174
+
175
+ positions = [Vector2D.random(-10, 10) for _ in range(10000)]
176
+ velocities = [Vector2D.random(-1, 1) for _ in range(10000)]
177
+
178
+ def update(dt):
179
+ # Update all particles in milliseconds
180
+ for i in range(len(positions)):
181
+ temp = velocities[i].mul(dt)
182
+ positions[i].iadd(temp)
183
+
184
+ def render():
185
+ # Upload to GPU
186
+ pos_array = vectors_to_array(positions).astype(np.float32)
187
+ vbo.write(pos_array)
188
+ ```
189
+
190
+ ### Physics Simulation
191
+ ```python
192
+ from e2D import Vector2D
193
+
194
+ class RigidBody:
195
+ def __init__(self, pos, vel):
196
+ self.position = Vector2D(*pos)
197
+ self.velocity = Vector2D(*vel)
198
+ self.acceleration = Vector2D(0, -9.8)
199
+
200
+ def update(self, dt):
201
+ # Optimized in-place physics
202
+ temp = self.acceleration.mul(dt)
203
+ self.velocity.iadd(temp)
204
+
205
+ temp = self.velocity.mul(dt)
206
+ self.position.iadd(temp)
207
+ ```
208
+
209
+ ## 🔧 Development
210
+
211
+ ### Building from Source
212
+
213
+ ```bash
214
+ git clone https://github.com/marick-py/e2D.git
215
+ cd e2D
216
+ pip install -e .[dev]
217
+ ```
218
+
219
+ ### Running Tests
220
+
221
+ ```bash
222
+ pytest
223
+ ```
224
+
225
+ ### Building Distribution
226
+
227
+ ```bash
228
+ python -m build
229
+ ```
230
+
231
+ ## 🤝 Contributing
232
+
233
+ Contributions are welcome! Please feel free to submit a Pull Request.
234
+
235
+ ## 📄 License
236
+
237
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
238
+
239
+ ## 👤 Author
240
+
241
+ **Riccardo Mariani**
242
+ - Email: ricomari2006@gmail.com
243
+ - GitHub: [@marick-py](https://github.com/marick-py)
244
+
245
+ ## 🙏 Acknowledgments
246
+
247
+ - Built with [ModernGL](https://github.com/moderngl/moderngl)
248
+ - Optimized with [Cython](https://cython.org/)
249
+ - Inspired by the need for high-performance 2D mathematics in Python
250
+
251
+ ## 📈 Version History
252
+
253
+ - **2.0.0** - Added ultra-optimized Vector2D with Cython compilation
254
+ - **1.4.24** - Previous stable release with pure Python vectors
255
+
256
+ ---
257
+
258
+ **Made with ❤️ for high-performance 2D development**
259
+
260
+
@@ -0,0 +1,26 @@
1
+ e2D/__init__.py,sha256=rNGyv9X8ZdmTJvgjXaO8SKGTnQlrvhtIBF8PP3VpBFA,18054
2
+ e2D/commons.py,sha256=vs6UqYGtm2-oHfv5kCSjMaQ243Xq6OqWh4Jt520H6Ho,2522
3
+ e2D/cvectors.c,sha256=Rqj99mKXScJ2OMc4y5KSBXhjLyuV4bP7T5v-nOgEooY,1222782
4
+ e2D/cvectors.cp313-win_amd64.pyd,sha256=_gzGIOVkH7XbiEr2fQ_QjCkuOytuzPqWgscRqUL2xmE,228864
5
+ e2D/cvectors.pxd,sha256=7y2VUafKkVFezGQioTlF66dy4g5aNbGnGLhLtHZpuM4,2137
6
+ e2D/cvectors.pyx,sha256=xJW6dD6JikkUXy0cuytgIijZJLcTpzJ0NpJ-aIErdzg,19048
7
+ e2D/devices.py,sha256=iAUNXSSD0wEqLqHV6ET3dcqx4C62ifxaXcN_8xaV7sI,2440
8
+ e2D/plots.py,sha256=gaCnnA-gUY1Hnmgquo7mqWlxSzAY4swTfwoPmw9ZF2k,21272
9
+ e2D/shapes.py,sha256=PY2G0EFCLqERTR0UfK8jqSanh5wwIBTYRPA5a6LRs7w,45450
10
+ e2D/text_renderer.py,sha256=u3i0qxnqgnVGUB6f0bKb1QtElVe535cDIIpjtRRcLAY,19752
11
+ e2D/vectors.py,sha256=WXNzaA1bLjM5movVWOn7gDy73H1xA0cavlP7djO1FSc,6781
12
+ e2D/shaders/curve_fragment.glsl,sha256=tKI3rDSlJPrWrQiATn6Rf4bJv7YGWVF6sgU9Y5H5qOk,94
13
+ e2D/shaders/curve_vertex.glsl,sha256=uEp9OwcTSB_EfJhQRkNPalpT6jvJ2FO42vnPeKZl9J8,324
14
+ e2D/shaders/line_instanced_vertex.glsl,sha256=r4XUNFogDH-Q9d_uXZQcT47iuiO8LeYXbEbqzRCFKSo,1049
15
+ e2D/shaders/plot_grid_fragment.glsl,sha256=rOKW6Bold7d9Bunaf1SJeLYOgbsHfKk_UVFGMpkMq4c,1338
16
+ e2D/shaders/plot_grid_vertex.glsl,sha256=-t8E3D0KBjaxIFbhZl87A0_4TzJ7fmajyLXoAaLu7_M,139
17
+ e2D/shaders/segment_fragment.glsl,sha256=tKI3rDSlJPrWrQiATn6Rf4bJv7YGWVF6sgU9Y5H5qOk,94
18
+ e2D/shaders/segment_vertex.glsl,sha256=I-hgbl2SnR5tWH9KRhz3CCj3ZZ7poz_gUfph1ydisaQ,233
19
+ e2D/shaders/stream_fragment.glsl,sha256=EBI2wXv_LjoikQ3sbPtRw5gA5lIeLimNBUSoU6UWSqM,246
20
+ e2D/shaders/stream_shift_compute.glsl,sha256=nwTD8IJjsFpl2XUXInc8IBDdW-DOmvaMLygLdquidyg,290
21
+ e2D/shaders/stream_vertex.glsl,sha256=Wxa8YtgxlMNL7OYq5LwqoOA_B4iRilC5_ArznyT018Y,608
22
+ e2d-2.0.0.dist-info/licenses/LICENSE,sha256=hbjljn38VVW9en51B0qzRK-v2FBDijqRWbZIVTk7ipU,1094
23
+ e2d-2.0.0.dist-info/METADATA,sha256=EKooTJt_akYAd3s_-S7pvJlmnogTloMGmR-pFnutUMc,7117
24
+ e2d-2.0.0.dist-info/WHEEL,sha256=T5i2ODeLs0s2las6bzoWK6w-WYjxkhtXh7SRJsBsjo4,102
25
+ e2d-2.0.0.dist-info/top_level.txt,sha256=3vKZ-CGzNlTCpzVMmM0Ht76krCofKw7hZ0wBf-dnKdM,4
26
+ e2d-2.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.1)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313-win_amd64
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Riccardo Mariani
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ e2D