e2D 1.4.12__py3-none-any.whl → 1.4.14__py3-none-any.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/__init__.py +58 -55
- e2D/__init__.pyi +124 -123
- e2D/envs.py +7 -6
- e2D/plots.py +3 -3
- e2D/utils.py +7 -3
- e2D/winrec.py +1 -1
- {e2D-1.4.12.dist-info → e2D-1.4.14.dist-info}/METADATA +1 -1
- e2D-1.4.14.dist-info/RECORD +11 -0
- {e2D-1.4.12.dist-info → e2D-1.4.14.dist-info}/WHEEL +1 -1
- e2D/cvb.py +0 -831
- e2D-1.4.12.dist-info/RECORD +0 -12
- {e2D-1.4.12.dist-info → e2D-1.4.14.dist-info}/LICENSE +0 -0
- {e2D-1.4.12.dist-info → e2D-1.4.14.dist-info}/top_level.txt +0 -0
e2D/envs.py
CHANGED
|
@@ -5,7 +5,7 @@ from .utils import *
|
|
|
5
5
|
import pygame as pg
|
|
6
6
|
|
|
7
7
|
""" CODE EXAMPLE FOR RootEnv
|
|
8
|
-
from e2D.envs import *
|
|
8
|
+
from e2D.envs import * #type: ignore
|
|
9
9
|
|
|
10
10
|
class Env(DefEnv):
|
|
11
11
|
def __init__(self) -> None:
|
|
@@ -41,13 +41,13 @@ class RootEnv:
|
|
|
41
41
|
show_fps = True,
|
|
42
42
|
quit_on_key_pressed : None|int = pg.K_x,
|
|
43
43
|
vsync : bool = True,
|
|
44
|
-
|
|
44
|
+
window_flags : int = pg.DOUBLEBUF,
|
|
45
45
|
clear_screen_each_frame : bool = True) -> None:
|
|
46
46
|
self.quit = False
|
|
47
47
|
self.__screen_size__ :Vector2D= screen_size
|
|
48
48
|
|
|
49
49
|
self.__vsync__ = vsync
|
|
50
|
-
self.__flags__ =
|
|
50
|
+
self.__flags__ = window_flags
|
|
51
51
|
self.screen = pg.display.set_mode(self.__screen_size__(), vsync=self.__vsync__, flags=self.__flags__)
|
|
52
52
|
|
|
53
53
|
self.clock = pg.time.Clock()
|
|
@@ -108,7 +108,7 @@ class RootEnv:
|
|
|
108
108
|
|
|
109
109
|
@property
|
|
110
110
|
def runtime_seconds(self) -> float:
|
|
111
|
-
return pg.time.get_ticks()
|
|
111
|
+
return pg.time.get_ticks() / 1e3
|
|
112
112
|
|
|
113
113
|
def init(self, sub_env:DefEnv) -> None:
|
|
114
114
|
self.env = sub_env
|
|
@@ -147,11 +147,12 @@ class RootEnv:
|
|
|
147
147
|
self.clock.tick(self.target_fps)
|
|
148
148
|
self.current_fps = self.clock.get_fps()
|
|
149
149
|
if self.clear_screen_each_frame: self.clear()
|
|
150
|
-
if self.show_fps: self.print(str(round(self.current_fps,2)), self.screen_size * .01, bg_color=(0,0,0))
|
|
151
150
|
|
|
152
151
|
self.env.draw()
|
|
153
152
|
for util in self.utils.values(): util.draw()
|
|
154
|
-
|
|
153
|
+
|
|
154
|
+
if self.show_fps: self.print(str(round(self.current_fps,2)), self.screen_size * .01, bg_color=(0,0,0))
|
|
155
|
+
pg.display.flip()
|
|
155
156
|
|
|
156
157
|
def __update__(self) -> None:
|
|
157
158
|
self.mouse.update()
|
e2D/plots.py
CHANGED
|
@@ -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
|
e2D/utils.py
CHANGED
|
@@ -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:
|
e2D/winrec.py
CHANGED
|
@@ -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,6 +1,6 @@
|
|
|
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
5
|
Home-page: https://github.com/marick-py/e2D
|
|
6
6
|
Author: Riccardo Mariani
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
e2D/__init__.py,sha256=klic-pOCE3h0JqwhpkKz6euZLS7wrvKQEUPTKTR9YRI,23066
|
|
2
|
+
e2D/__init__.pyi,sha256=rMceBt26-bozw_Xt3JQWfQ_20G8RAkE2j4CqIf7PIuQ,48013
|
|
3
|
+
e2D/envs.py,sha256=Kf6f9szesdI9xado9u1FiDOBEVusbJDAvU-i9rMESws,6306
|
|
4
|
+
e2D/plots.py,sha256=S4YWKJVrb1bfJGxUebFy4167coCb4oTdcNl_DKcJtlA,36075
|
|
5
|
+
e2D/utils.py,sha256=tDs_Fl_8YBQoJaATQmgmFD50oNu39i4bCmvxxU16cS0,14152
|
|
6
|
+
e2D/winrec.py,sha256=EFFfWYbk27NhS-rWD-BLChXvLjFW1uYZ5LkRGMj_Xo0,1116
|
|
7
|
+
e2D-1.4.14.dist-info/LICENSE,sha256=wymkNVDvj3qmjdO_rAhkRPM4t5y3_SqffGsFdgfvznU,1066
|
|
8
|
+
e2D-1.4.14.dist-info/METADATA,sha256=LxDaWfll8xiSRggk4Wv6r8Nv6BdDgu7SgajDuxcXwaU,9611
|
|
9
|
+
e2D-1.4.14.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
10
|
+
e2D-1.4.14.dist-info/top_level.txt,sha256=3vKZ-CGzNlTCpzVMmM0Ht76krCofKw7hZ0wBf-dnKdM,4
|
|
11
|
+
e2D-1.4.14.dist-info/RECORD,,
|