e2D 1.4.13.1__tar.gz → 1.4.14__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.
- {e2d-1.4.13.1 → e2d-1.4.14}/PKG-INFO +4 -3
- {e2d-1.4.13.1 → e2d-1.4.14}/e2D/__init__.py +58 -55
- {e2d-1.4.13.1 → e2d-1.4.14}/e2D/__init__.pyi +49 -47
- {e2d-1.4.13.1 → e2d-1.4.14}/e2D/envs.py +1 -1
- {e2d-1.4.13.1 → e2d-1.4.14}/e2D/plots.py +3 -3
- {e2d-1.4.13.1 → e2d-1.4.14}/e2D/utils.py +7 -3
- {e2d-1.4.13.1 → e2d-1.4.14}/e2D/winrec.py +1 -1
- {e2d-1.4.13.1 → e2d-1.4.14}/e2D.egg-info/PKG-INFO +4 -3
- {e2d-1.4.13.1 → e2d-1.4.14}/e2D.egg-info/SOURCES.txt +1 -2
- e2d-1.4.14/pyproject.toml +6 -0
- e2d-1.4.14/setup.cfg +26 -0
- e2d-1.4.13.1/e2D/Cmain.c +0 -36338
- e2d-1.4.13.1/pyproject.toml +0 -23
- e2d-1.4.13.1/setup.cfg +0 -4
- e2d-1.4.13.1/setup.py +0 -18
- {e2d-1.4.13.1 → e2d-1.4.14}/LICENSE +0 -0
- {e2d-1.4.13.1 → e2d-1.4.14}/README.md +0 -0
- {e2d-1.4.13.1 → e2d-1.4.14}/e2D.egg-info/dependency_links.txt +0 -0
- {e2d-1.4.13.1 → e2d-1.4.14}/e2D.egg-info/requires.txt +0 -0
- {e2d-1.4.13.1 → e2d-1.4.14}/e2D.egg-info/top_level.txt +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: e2D
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.14
|
|
4
4
|
Summary: Python library for 2D games. Streamlines dev with keyboard/mouse input, vector calculations, color manipulation, and collision detection. Simplify game creation and unleash creativity!
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Home-page: https://github.com/marick-py/e2D
|
|
6
|
+
Author: Riccardo Mariani
|
|
7
|
+
Author-email: ricomari2006@gmail.com
|
|
7
8
|
Classifier: Programming Language :: Python :: 3
|
|
8
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
9
10
|
Classifier: Operating System :: OS Independent
|
|
@@ -35,10 +35,20 @@ class Vector2D:
|
|
|
35
35
|
def angle(self, new_angle) -> None:
|
|
36
36
|
self.rotate(new_angle - self.angle)
|
|
37
37
|
|
|
38
|
+
@property
|
|
39
|
+
def copy(self) -> "Vector2D":
|
|
40
|
+
return Vector2D(self.x, self.y)
|
|
41
|
+
|
|
38
42
|
@property
|
|
39
43
|
def sign(self) -> "Vector2D":
|
|
40
44
|
return Vector2D(sign(self.x), sign(self.y))
|
|
41
|
-
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def normalize(self) -> "Vector2D":
|
|
48
|
+
if (mag:=self.length) == 0:
|
|
49
|
+
return self.copy
|
|
50
|
+
return Vector2D(self.x / mag, self.y / mag)
|
|
51
|
+
|
|
42
52
|
@property
|
|
43
53
|
def length(self) -> float:
|
|
44
54
|
return (self.x ** 2 + self.y ** 2) ** .5
|
|
@@ -47,14 +57,6 @@ class Vector2D:
|
|
|
47
57
|
def length_sqrd(self) -> float:
|
|
48
58
|
return self.x ** 2 + self.y ** 2
|
|
49
59
|
|
|
50
|
-
def copy(self) -> "Vector2D":
|
|
51
|
-
return Vector2D(self.x, self.y)
|
|
52
|
-
|
|
53
|
-
def normalize(self) -> "Vector2D":
|
|
54
|
-
if (mag:=self.length) == 0:
|
|
55
|
-
return self.copy()
|
|
56
|
-
return Vector2D(self.x / mag, self.y / mag)
|
|
57
|
-
|
|
58
60
|
def floor(self, n=1) -> "Vector2D":
|
|
59
61
|
return self.__floor__(n)
|
|
60
62
|
|
|
@@ -163,20 +165,20 @@ class Vector2D:
|
|
|
163
165
|
def sub(self, both=.0, x=.0, y=.0) -> Vector2D:
|
|
164
166
|
return Vector2D(self.x - (x + both), self.y - (y + both))
|
|
165
167
|
|
|
166
|
-
def mult(self, both
|
|
167
|
-
return Vector2D(self.x *
|
|
168
|
+
def mult(self, both=1.0, x=1.0, y=1.0) -> Vector2D:
|
|
169
|
+
return Vector2D(self.x * x * both, self.y * y * both)
|
|
168
170
|
|
|
169
|
-
def pow(self, both
|
|
171
|
+
def pow(self, both=1.0, x=1.0, y=1.0) -> Vector2D:
|
|
170
172
|
return Vector2D(self.x ** (x + both), self.y ** (y + both))
|
|
171
173
|
|
|
172
|
-
def mod(self, both
|
|
174
|
+
def mod(self, both=1.0, x=1.0, y=1.0) -> Vector2D:
|
|
173
175
|
return Vector2D(self.x % (x + both), self.y % (y + both))
|
|
174
176
|
|
|
175
|
-
def div(self, both
|
|
176
|
-
return Vector2D(self.x /
|
|
177
|
+
def div(self, both=1.0, x=1.0, y=1.0) -> Vector2D:
|
|
178
|
+
return Vector2D(self.x / x / both, self.y / y / both)
|
|
177
179
|
|
|
178
|
-
def fdiv(self, both
|
|
179
|
-
return Vector2D(self.x //
|
|
180
|
+
def fdiv(self, both=1.0, x=1.0, y=1.0) -> Vector2D:
|
|
181
|
+
return Vector2D(self.x // x // both, self.y // y // both)
|
|
180
182
|
|
|
181
183
|
# fast inplace operations Vector2D.ioperation(both,x,y)
|
|
182
184
|
def set(self, both=.0, x=.0, y=.0) -> Vector2D:
|
|
@@ -194,29 +196,29 @@ class Vector2D:
|
|
|
194
196
|
self.y -= y + both
|
|
195
197
|
return self
|
|
196
198
|
|
|
197
|
-
def imult(self, both
|
|
198
|
-
self.x *= x
|
|
199
|
-
self.y *= y
|
|
199
|
+
def imult(self, both=1.0, x=1.0, y=1.0) -> Vector2D:
|
|
200
|
+
self.x *= x * both
|
|
201
|
+
self.y *= y * both
|
|
200
202
|
return self
|
|
201
203
|
|
|
202
|
-
def ipow(self, both
|
|
204
|
+
def ipow(self, both=1.0, x=1.0, y=1.0) -> Vector2D:
|
|
203
205
|
self.x **= x + both
|
|
204
206
|
self.y **= y + both
|
|
205
207
|
return self
|
|
206
208
|
|
|
207
|
-
def imod(self, both
|
|
209
|
+
def imod(self, both=1.0, x=1.0, y=1.0) -> Vector2D:
|
|
208
210
|
self.x %= x + both
|
|
209
211
|
self.y %= y + both
|
|
210
212
|
return self
|
|
211
213
|
|
|
212
|
-
def idiv(self, both
|
|
213
|
-
self.x /= x
|
|
214
|
-
self.y /= y
|
|
214
|
+
def idiv(self, both=1.0, x=1.0, y=1.0) -> Vector2D:
|
|
215
|
+
self.x /= x * both
|
|
216
|
+
self.y /= y * both
|
|
215
217
|
return self
|
|
216
218
|
|
|
217
|
-
def ifdiv(self, both
|
|
218
|
-
self.x //= x
|
|
219
|
-
self.y //= y
|
|
219
|
+
def ifdiv(self, both=1.0, x=1.0, y=1.0) -> Vector2D:
|
|
220
|
+
self.x //= x * both
|
|
221
|
+
self.y //= y * both
|
|
220
222
|
return self
|
|
221
223
|
|
|
222
224
|
# normal operations Vector2D + a
|
|
@@ -327,11 +329,9 @@ class Vector2D:
|
|
|
327
329
|
def __ne__(self, other) -> bool:
|
|
328
330
|
return not self.__eq__(other)
|
|
329
331
|
|
|
330
|
-
# absolute value
|
|
331
332
|
def __abs__(self) -> "Vector2D":
|
|
332
333
|
return Vector2D(abs(self.x), abs(self.y))
|
|
333
334
|
|
|
334
|
-
# rounding operations
|
|
335
335
|
def __round__(self, n=1) -> "Vector2D":
|
|
336
336
|
n = Vector2D.__normalize__(n)
|
|
337
337
|
return Vector2D(round(self.x / n.x) * n.x, round(self.y / n.y) * n.y)
|
|
@@ -416,47 +416,49 @@ class Vector2D:
|
|
|
416
416
|
def down_left_norm(cls) -> "Vector2D": return V2down_left_norm
|
|
417
417
|
|
|
418
418
|
@classmethod
|
|
419
|
-
def new_zero(cls) -> "Vector2D": return V2zero.copy
|
|
419
|
+
def new_zero(cls) -> "Vector2D": return V2zero.copy
|
|
420
420
|
@classmethod
|
|
421
|
-
def new_one(cls) -> "Vector2D": return V2one.copy
|
|
421
|
+
def new_one(cls) -> "Vector2D": return V2one.copy
|
|
422
422
|
@classmethod
|
|
423
|
-
def new_two(cls) -> "Vector2D": return V2two.copy
|
|
423
|
+
def new_two(cls) -> "Vector2D": return V2two.copy
|
|
424
424
|
@classmethod
|
|
425
|
-
def new_pi(cls) -> "Vector2D": return V2pi.copy
|
|
425
|
+
def new_pi(cls) -> "Vector2D": return V2pi.copy
|
|
426
426
|
@classmethod
|
|
427
|
-
def new_inf(cls) -> "Vector2D": return V2inf.copy
|
|
427
|
+
def new_inf(cls) -> "Vector2D": return V2inf.copy
|
|
428
428
|
@classmethod
|
|
429
|
-
def new_neg_one(cls) -> "Vector2D": return V2neg_one.copy
|
|
429
|
+
def new_neg_one(cls) -> "Vector2D": return V2neg_one.copy
|
|
430
430
|
@classmethod
|
|
431
|
-
def new_neg_two(cls) -> "Vector2D": return V2neg_two.copy
|
|
431
|
+
def new_neg_two(cls) -> "Vector2D": return V2neg_two.copy
|
|
432
432
|
@classmethod
|
|
433
|
-
def new_neg_pi(cls) -> "Vector2D": return V2neg_pi.copy
|
|
433
|
+
def new_neg_pi(cls) -> "Vector2D": return V2neg_pi.copy
|
|
434
434
|
@classmethod
|
|
435
|
-
def new_neg_inf(cls) -> "Vector2D": return V2neg_inf.copy
|
|
435
|
+
def new_neg_inf(cls) -> "Vector2D": return V2neg_inf.copy
|
|
436
436
|
@classmethod
|
|
437
|
-
def new_up(cls) -> "Vector2D": return V2up.copy
|
|
437
|
+
def new_up(cls) -> "Vector2D": return V2up.copy
|
|
438
438
|
@classmethod
|
|
439
|
-
def new_right(cls) -> "Vector2D": return V2right.copy
|
|
439
|
+
def new_right(cls) -> "Vector2D": return V2right.copy
|
|
440
440
|
@classmethod
|
|
441
|
-
def new_down(cls) -> "Vector2D": return V2down.copy
|
|
441
|
+
def new_down(cls) -> "Vector2D": return V2down.copy
|
|
442
442
|
@classmethod
|
|
443
|
-
def new_left(cls) -> "Vector2D": return V2left.copy
|
|
443
|
+
def new_left(cls) -> "Vector2D": return V2left.copy
|
|
444
444
|
@classmethod
|
|
445
|
-
def new_up_right(cls) -> "Vector2D": return V2up_right.copy
|
|
445
|
+
def new_up_right(cls) -> "Vector2D": return V2up_right.copy
|
|
446
446
|
@classmethod
|
|
447
|
-
def new_down_right(cls) -> "Vector2D": return V2down_right.copy
|
|
447
|
+
def new_down_right(cls) -> "Vector2D": return V2down_right.copy
|
|
448
448
|
@classmethod
|
|
449
|
-
def new_up_left(cls) -> "Vector2D": return V2up_left.copy
|
|
449
|
+
def new_up_left(cls) -> "Vector2D": return V2up_left.copy
|
|
450
450
|
@classmethod
|
|
451
|
-
def new_down_left(cls) -> "Vector2D": return V2down_left.copy
|
|
451
|
+
def new_down_left(cls) -> "Vector2D": return V2down_left.copy
|
|
452
452
|
@classmethod
|
|
453
|
-
def new_up_right_norm(cls) -> "Vector2D": return V2up_right_norm.copy
|
|
453
|
+
def new_up_right_norm(cls) -> "Vector2D": return V2up_right_norm.copy
|
|
454
454
|
@classmethod
|
|
455
|
-
def new_down_right_norm(cls) -> "Vector2D": return V2down_right_norm.copy
|
|
455
|
+
def new_down_right_norm(cls) -> "Vector2D": return V2down_right_norm.copy
|
|
456
456
|
@classmethod
|
|
457
|
-
def new_up_left_norm(cls) -> "Vector2D": return V2up_left_norm.copy
|
|
457
|
+
def new_up_left_norm(cls) -> "Vector2D": return V2up_left_norm.copy
|
|
458
458
|
@classmethod
|
|
459
|
-
def new_down_left_norm(cls) -> "Vector2D": return V2down_left_norm.copy
|
|
459
|
+
def new_down_left_norm(cls) -> "Vector2D": return V2down_left_norm.copy
|
|
460
|
+
|
|
461
|
+
from .cvb import *
|
|
460
462
|
|
|
461
463
|
V2 = Vector2D
|
|
462
464
|
|
|
@@ -482,10 +484,10 @@ V2down_right = Vector2D(1, -1)
|
|
|
482
484
|
V2up_left = Vector2D(-1, 1)
|
|
483
485
|
V2down_left = Vector2D(-1, -1)
|
|
484
486
|
|
|
485
|
-
V2up_right_norm = V2up_right.normalize
|
|
486
|
-
V2down_right_norm = V2down_right.normalize
|
|
487
|
-
V2up_left_norm = V2up_left.normalize
|
|
488
|
-
V2down_left_norm = V2down_left.normalize
|
|
487
|
+
V2up_right_norm = V2up_right.normalize
|
|
488
|
+
V2down_right_norm = V2down_right.normalize
|
|
489
|
+
V2up_left_norm = V2up_left.normalize
|
|
490
|
+
V2down_left_norm = V2down_left.normalize
|
|
489
491
|
|
|
490
492
|
VECTORS_4_DIRECTIONS = (V2right, V2down, V2left, V2up)
|
|
491
493
|
VECTORS_4_SEMIDIRECTIONS = (V2down_right, V2down_left, V2up_left, V2up_right)
|
|
@@ -493,6 +495,7 @@ VECTORS_4_SEMIDIRECTIONS_NORM = (V2down_right_norm, V2down_left_norm, V2up_left_
|
|
|
493
495
|
VECTORS_8_DIRECTIONS = (V2right, V2down_right, V2down, V2down_left, V2left, V2up_left, V2up, V2up_right)
|
|
494
496
|
VECTORS_8_DIRECTIONS_NORM = (V2right, V2down_right_norm, V2down, V2down_left_norm, V2left, V2up_left_norm, V2up, V2up_right_norm)
|
|
495
497
|
|
|
498
|
+
|
|
496
499
|
def rgb(r:float, g:float, b:float) -> tuple[float, float, float]:
|
|
497
500
|
return (r,g,b)
|
|
498
501
|
|
|
@@ -6,7 +6,7 @@ PI_HALF : float
|
|
|
6
6
|
PI_QUARTER : float
|
|
7
7
|
PI_DOUBLE : float
|
|
8
8
|
|
|
9
|
-
#
|
|
9
|
+
# regular expression to remove comments:
|
|
10
10
|
# """([\s\S]*?)"""
|
|
11
11
|
|
|
12
12
|
#
|
|
@@ -143,7 +143,31 @@ class Vector2D:
|
|
|
143
143
|
def angle(self:"Vector2D") -> int|float: ...
|
|
144
144
|
|
|
145
145
|
@angle.setter
|
|
146
|
-
def angle(self:"Vector2D",
|
|
146
|
+
def angle(self:"Vector2D", argv) -> None: ...
|
|
147
|
+
|
|
148
|
+
@property
|
|
149
|
+
def copy(self:"Vector2D") -> "Vector2D":
|
|
150
|
+
"""
|
|
151
|
+
# Create a copy of the current Vector2D other.
|
|
152
|
+
|
|
153
|
+
## Returns:
|
|
154
|
+
Vector2D: A new Vector2D other with the same x and y coordinates as the current other.
|
|
155
|
+
|
|
156
|
+
## Example:
|
|
157
|
+
point1 = Vector2D(1, 2)
|
|
158
|
+
|
|
159
|
+
point2 = point1.copy()
|
|
160
|
+
|
|
161
|
+
print(point2.x, point2.y)
|
|
162
|
+
|
|
163
|
+
This will print the x and y coordinates of the copied Vector2D other (1, 2).
|
|
164
|
+
|
|
165
|
+
## Explanation:
|
|
166
|
+
The function creates a new Vector2D other with the same x and y coordinates as the current other.
|
|
167
|
+
|
|
168
|
+
The result is returned as a new Vector2D other, effectively making a copy of the original other.
|
|
169
|
+
"""
|
|
170
|
+
...
|
|
147
171
|
|
|
148
172
|
@property
|
|
149
173
|
def sign(self:"Vector2D") -> "Vector2D":
|
|
@@ -186,38 +210,8 @@ class Vector2D:
|
|
|
186
210
|
vector points in the same direction as the original vector but has non-negative components.
|
|
187
211
|
"""
|
|
188
212
|
...
|
|
189
|
-
|
|
190
|
-
@property
|
|
191
|
-
def length(self:"Vector2D") -> float:
|
|
192
|
-
...
|
|
193
|
-
|
|
194
|
-
@property
|
|
195
|
-
def length_sqrd(self:"Vector2D") -> float:
|
|
196
|
-
...
|
|
197
|
-
|
|
198
|
-
def copy(self:"Vector2D") -> "Vector2D":
|
|
199
|
-
"""
|
|
200
|
-
# Create a copy of the current Vector2D other.
|
|
201
|
-
|
|
202
|
-
## Returns:
|
|
203
|
-
Vector2D: A new Vector2D other with the same x and y coordinates as the current other.
|
|
204
|
-
|
|
205
|
-
## Example:
|
|
206
|
-
point1 = Vector2D(1, 2)
|
|
207
|
-
|
|
208
|
-
point2 = point1.copy()
|
|
209
|
-
|
|
210
|
-
print(point2.x, point2.y)
|
|
211
|
-
|
|
212
|
-
This will print the x and y coordinates of the copied Vector2D other (1, 2).
|
|
213
|
-
|
|
214
|
-
## Explanation:
|
|
215
|
-
The function creates a new Vector2D other with the same x and y coordinates as the current other.
|
|
216
|
-
|
|
217
|
-
The result is returned as a new Vector2D other, effectively making a copy of the original other.
|
|
218
|
-
"""
|
|
219
|
-
...
|
|
220
213
|
|
|
214
|
+
@property
|
|
221
215
|
def normalize(self:"Vector2D") -> "Vector2D":
|
|
222
216
|
"""
|
|
223
217
|
# Vector Normalization
|
|
@@ -248,6 +242,14 @@ class Vector2D:
|
|
|
248
242
|
"""
|
|
249
243
|
...
|
|
250
244
|
|
|
245
|
+
@property
|
|
246
|
+
def length(self:"Vector2D") -> float:
|
|
247
|
+
...
|
|
248
|
+
|
|
249
|
+
@property
|
|
250
|
+
def length_sqrd(self:"Vector2D") -> float:
|
|
251
|
+
...
|
|
252
|
+
|
|
251
253
|
def floor(self:"Vector2D", n:"int|float|Vector2D"=1) -> "Vector2D":
|
|
252
254
|
...
|
|
253
255
|
|
|
@@ -491,7 +493,7 @@ class Vector2D:
|
|
|
491
493
|
If None, the vector is rotated around the origin (0, 0).
|
|
492
494
|
|
|
493
495
|
## Returns:
|
|
494
|
-
|
|
496
|
+
None
|
|
495
497
|
|
|
496
498
|
## Example:
|
|
497
499
|
v = Vector2D(3, 4)
|
|
@@ -579,32 +581,32 @@ class Vector2D:
|
|
|
579
581
|
|
|
580
582
|
def sub(self, both:int|float=.0, x:int|float=.0, y:int|float=.0) -> Vector2D: ...
|
|
581
583
|
|
|
582
|
-
def mult(self, both:int|float
|
|
584
|
+
def mult(self, both:int|float=1.0, x:int|float=1.0, y:int|float=1.0) -> Vector2D: ...
|
|
583
585
|
|
|
584
|
-
def pow(self, both:int|float
|
|
586
|
+
def pow(self, both:int|float=1.0, x:int|float=1.0, y:int|float=1.0) -> Vector2D: ...
|
|
585
587
|
|
|
586
|
-
def mod(self, both:int|float
|
|
588
|
+
def mod(self, both:int|float=1.0, x:int|float=1.0, y:int|float=1.0) -> Vector2D: ...
|
|
587
589
|
|
|
588
|
-
def div(self, both:int|float
|
|
590
|
+
def div(self, both:int|float=1.0, x:int|float=1.0, y:int|float=1.0) -> Vector2D: ...
|
|
589
591
|
|
|
590
|
-
def fdiv(self, both:int|float
|
|
592
|
+
def fdiv(self, both:int|float=1.0, x:int|float=1.0, y:int|float=1.0) -> Vector2D: ...
|
|
591
593
|
|
|
592
594
|
# fast inplace operations Vector2D.ioperation(both,x,y)
|
|
593
|
-
def set(self, both
|
|
595
|
+
def set(self, both:int|float=.0, x:int|float=.0, y:int|float=.0) -> Vector2D: ...
|
|
594
596
|
|
|
595
|
-
def iadd(self, both:int|float, x:int|float, y
|
|
597
|
+
def iadd(self, both:int|float=.0, x:int|float=.0, y:int|float=.0) -> Vector2D: ...
|
|
596
598
|
|
|
597
|
-
def isub(self, both:int|float, x:int|float, y
|
|
599
|
+
def isub(self, both:int|float=.0, x:int|float=.0, y:int|float=.0) -> Vector2D: ...
|
|
598
600
|
|
|
599
|
-
def imult(self, both:int|float, x:int|float, y
|
|
601
|
+
def imult(self, both:int|float=1.0, x:int|float=1.0, y:int|float=1.0) -> Vector2D: ...
|
|
600
602
|
|
|
601
|
-
def ipow(self, both:int|float, x:int|float, y
|
|
603
|
+
def ipow(self, both:int|float=1.0, x:int|float=1.0, y:int|float=1.0) -> Vector2D: ...
|
|
602
604
|
|
|
603
|
-
def imod(self, both:int|float, x:int|float, y
|
|
605
|
+
def imod(self, both:int|float=1.0, x:int|float=1.0, y:int|float=1.0) -> Vector2D: ...
|
|
604
606
|
|
|
605
|
-
def idiv(self, both:int|float, x:int|float, y
|
|
607
|
+
def idiv(self, both:int|float=1.0, x:int|float=1.0, y:int|float=1.0) -> Vector2D: ...
|
|
606
608
|
|
|
607
|
-
def ifdiv(self, both:int|float, x:int|float, y
|
|
609
|
+
def ifdiv(self, both:int|float=1.0, x:int|float=1.0, y:int|float=1.0) -> Vector2D: ...
|
|
608
610
|
|
|
609
611
|
# normal operations Vector2D + a
|
|
610
612
|
def __add__(self:"Vector2D", other:"int|float|Vector2D|list|tuple") -> "Vector2D": ...
|
|
@@ -127,8 +127,8 @@ class MathFunction(Function):
|
|
|
127
127
|
id:int|str,
|
|
128
128
|
function:Callable[[int|float, int|float], int|float],
|
|
129
129
|
domain:list[float]=[-np.inf, np.inf],
|
|
130
|
-
codomain:list[float]=[-np.inf, np.inf],
|
|
131
|
-
:list[float]|tuple[float,float,float]=(255,255,255)) -> None:
|
|
130
|
+
codomain:list[float]=[-np.inf, np.inf],
|
|
131
|
+
color:list[float]|tuple[float,float,float]=(255,255,255)) -> None:
|
|
132
132
|
super().__init__()
|
|
133
133
|
self.id = id
|
|
134
134
|
self.color = color
|
|
@@ -398,7 +398,7 @@ class Plot:
|
|
|
398
398
|
self.focus_using_corners(top_left_plot_coord, bottom_right_plot_coord)
|
|
399
399
|
|
|
400
400
|
def set_borders_by_position_and_zoom(self) -> None:
|
|
401
|
-
self.top_left_plot_coord = self.current_offset - 2**(
|
|
401
|
+
self.top_left_plot_coord = self.current_offset - 2**(self.current_zoom.mult(-.1)) * self.__y_axis_multiplier__
|
|
402
402
|
self.bottom_right_plot_coord = self.current_offset + 2**(-.1*self.current_zoom) * self.__y_axis_multiplier__
|
|
403
403
|
self.top_left_x, self.top_left_y = self.top_left_plot_coord
|
|
404
404
|
self.bottom_right_x, self.bottom_right_y = self.bottom_right_plot_coord
|
|
@@ -3,6 +3,8 @@ from typing import Any, Callable, Literal
|
|
|
3
3
|
import pygame as pg
|
|
4
4
|
from e2D import *
|
|
5
5
|
|
|
6
|
+
import math as _mt
|
|
7
|
+
|
|
6
8
|
pg.font.init()
|
|
7
9
|
|
|
8
10
|
__KEY_MODE_TYPES_DICT__ = dict(zip(["pressed", "just_pressed", "just_released"], range(3)))
|
|
@@ -95,6 +97,7 @@ class Util:
|
|
|
95
97
|
self.rootEnv = None
|
|
96
98
|
self.surface : pg.Surface
|
|
97
99
|
self.id : int|str
|
|
100
|
+
self.is_hovered :bool= False
|
|
98
101
|
def draw(self) -> None: pass
|
|
99
102
|
def update(self) -> None: pass
|
|
100
103
|
|
|
@@ -153,14 +156,15 @@ class InputCell(Util):
|
|
|
153
156
|
if self.border_width:
|
|
154
157
|
pg.draw.rect(self.text_surface, self.border_color, self.margin_rect, self.border_width, -1, *self.border_radius)
|
|
155
158
|
else:
|
|
156
|
-
pg.draw.rect(self.text_surface, [127 + 127 * _mt.sin(self.rootEnv.
|
|
159
|
+
pg.draw.rect(self.text_surface, [127 + 127 * _mt.sin(self.rootEnv.runtime_seconds * 10)]*3, self.margin_rect, self.border_width if self.border_width else 10, -1, *self.border_radius)
|
|
157
160
|
|
|
158
161
|
self.surface.blit(self.text_surface, self.position())
|
|
159
162
|
|
|
160
163
|
def update(self) -> None:
|
|
164
|
+
self.is_hovered = self.position.x < self.rootEnv.mouse.position.x < self.position.x + self.size.x and\
|
|
165
|
+
self.position.y < self.rootEnv.mouse.position.y < self.position.y + self.size.y
|
|
161
166
|
if self.rootEnv.mouse.get_key(0, "just_pressed"):
|
|
162
|
-
if self.
|
|
163
|
-
self.position.y < self.rootEnv.mouse.position.y < self.position.y + self.size.y:
|
|
167
|
+
if self.is_hovered:
|
|
164
168
|
self.rootEnv.selected_util = self if self.rootEnv.selected_util != self else None
|
|
165
169
|
self.update_text()
|
|
166
170
|
if self.rootEnv.selected_util == self:
|
|
@@ -18,7 +18,7 @@ class WinRec:
|
|
|
18
18
|
return self.rootEnv.current_frame/self.fps
|
|
19
19
|
|
|
20
20
|
def draw(self, draw_on_screen=False) -> None:
|
|
21
|
-
text = f"[cfps:{self.rootEnv.current_frame} || realtime:{round(self.get_rec_seconds(),2)} || apptime:{round(self.rootEnv.
|
|
21
|
+
text = f"[cfps:{self.rootEnv.current_frame} || realtime:{round(self.get_rec_seconds(),2)} || apptime:{round(self.rootEnv.runtime_seconds,2)}]"
|
|
22
22
|
pg.display.set_caption(text)
|
|
23
23
|
if draw_on_screen: self.rootEnv.print(text, self.rootEnv.screen_size, pivot_position='bottom_right')
|
|
24
24
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: e2D
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.14
|
|
4
4
|
Summary: Python library for 2D games. Streamlines dev with keyboard/mouse input, vector calculations, color manipulation, and collision detection. Simplify game creation and unleash creativity!
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Home-page: https://github.com/marick-py/e2D
|
|
6
|
+
Author: Riccardo Mariani
|
|
7
|
+
Author-email: ricomari2006@gmail.com
|
|
7
8
|
Classifier: Programming Language :: Python :: 3
|
|
8
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
9
10
|
Classifier: Operating System :: OS Independent
|
e2d-1.4.14/setup.cfg
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
name = e2D
|
|
3
|
+
version = 1.4.14
|
|
4
|
+
author = Riccardo Mariani
|
|
5
|
+
author_email = ricomari2006@gmail.com
|
|
6
|
+
description = Python library for 2D games. Streamlines dev with keyboard/mouse input, vector calculations, color manipulation, and collision detection. Simplify game creation and unleash creativity!
|
|
7
|
+
long_description = file: README.md
|
|
8
|
+
long_description_content_type = text/markdown
|
|
9
|
+
url = https://github.com/marick-py/e2D
|
|
10
|
+
classifiers =
|
|
11
|
+
Programming Language :: Python :: 3
|
|
12
|
+
License :: OSI Approved :: MIT License
|
|
13
|
+
Operating System :: OS Independent
|
|
14
|
+
|
|
15
|
+
[options]
|
|
16
|
+
packages = find:
|
|
17
|
+
python_requires = >= 3.9
|
|
18
|
+
install_requires =
|
|
19
|
+
numpy
|
|
20
|
+
pygame
|
|
21
|
+
include_package_data = True
|
|
22
|
+
|
|
23
|
+
[egg_info]
|
|
24
|
+
tag_build =
|
|
25
|
+
tag_date = 0
|
|
26
|
+
|