e2D 1.4.16__py3-none-any.whl → 1.4.18__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 +5 -22
- e2D/__init__.pyi +5 -133
- e2D/colors.py +106 -129
- e2D/def_colors.py +1732 -0
- e2D/envs.py +9 -9
- e2D/plots.py +25 -25
- {e2D-1.4.16.dist-info → e2D-1.4.18.dist-info}/METADATA +1 -1
- e2D-1.4.18.dist-info/RECORD +13 -0
- e2D-1.4.16.dist-info/RECORD +0 -12
- {e2D-1.4.16.dist-info → e2D-1.4.18.dist-info}/LICENSE +0 -0
- {e2D-1.4.16.dist-info → e2D-1.4.18.dist-info}/WHEEL +0 -0
- {e2D-1.4.16.dist-info → e2D-1.4.18.dist-info}/top_level.txt +0 -0
e2D/envs.py
CHANGED
|
@@ -59,7 +59,7 @@ class RootEnv:
|
|
|
59
59
|
self.current_frame = 0
|
|
60
60
|
self.show_fps = show_fps
|
|
61
61
|
self.events :list[pg.event.Event]= []
|
|
62
|
-
self.background_color =
|
|
62
|
+
self.background_color = BLACK_COLOR_PYG
|
|
63
63
|
self.clear_screen_each_frame = clear_screen_each_frame
|
|
64
64
|
self.utils :dict[int|str, Util]= {}
|
|
65
65
|
self.selected_util :Util|None = None
|
|
@@ -115,7 +115,7 @@ class RootEnv:
|
|
|
115
115
|
self.env = sub_env
|
|
116
116
|
|
|
117
117
|
def clear(self) -> None:
|
|
118
|
-
self.screen.fill(self.background_color
|
|
118
|
+
self.screen.fill(self.background_color)
|
|
119
119
|
|
|
120
120
|
def clear_rect(self, position:Vector2D, size:Vector2D) -> None:
|
|
121
121
|
self.screen.fill(self.background_color, position() + size())
|
|
@@ -123,25 +123,25 @@ class RootEnv:
|
|
|
123
123
|
def print(self,
|
|
124
124
|
text : str,
|
|
125
125
|
position : Vector2D,
|
|
126
|
-
color : Color =
|
|
126
|
+
color : pg.Color = WHITE_COLOR_PYG,
|
|
127
127
|
pivot_position : __LITERAL_PIVOT_POSITIONS__ = "top_left",
|
|
128
128
|
font : pg.font.Font = FONT_ARIAL_32,
|
|
129
|
-
bg_color : None|Color = None,
|
|
130
|
-
border_color : Color =
|
|
129
|
+
bg_color : None|pg.Color = None,
|
|
130
|
+
border_color : pg.Color = WHITE_COLOR_PYG,
|
|
131
131
|
border_width : float = 0.0,
|
|
132
132
|
border_radius : int|list[int]|tuple[int,int,int,int] = -1,
|
|
133
133
|
margin : Vector2D = Vector2D.zero(),
|
|
134
134
|
personalized_surface : pg.Surface|None = None
|
|
135
135
|
) -> None:
|
|
136
|
-
text_box = font.render(text, True, color
|
|
136
|
+
text_box = font.render(text, True, color)
|
|
137
137
|
size = Vector2D(*text_box.get_size()) + margin * 2
|
|
138
138
|
pivotted_position = position - size * __PIVOT_POSITIONS_MULTIPLIER__[pivot_position] + margin
|
|
139
139
|
if not any(isinstance(border_radius, cls) for cls in {tuple, list}): border_radius = [border_radius]*4
|
|
140
140
|
surface = (self.screen if personalized_surface == None else personalized_surface)
|
|
141
141
|
if bg_color != None:
|
|
142
|
-
pg.draw.rect(surface, bg_color
|
|
142
|
+
pg.draw.rect(surface, bg_color, (pivotted_position - margin)() + size(), 0, -1, *border_radius)
|
|
143
143
|
if border_width:
|
|
144
|
-
pg.draw.rect(surface, border_color
|
|
144
|
+
pg.draw.rect(surface, border_color, (pivotted_position - margin)() + size(), border_width, -1, *border_radius)
|
|
145
145
|
surface.blit(text_box, pivotted_position())
|
|
146
146
|
|
|
147
147
|
def __draw__(self) -> None:
|
|
@@ -152,7 +152,7 @@ class RootEnv:
|
|
|
152
152
|
self.env.draw()
|
|
153
153
|
for util in self.utils.values(): util.draw()
|
|
154
154
|
|
|
155
|
-
if self.show_fps: self.print(str(round(self.current_fps,2)), self.screen_size * .01, bg_color=
|
|
155
|
+
if self.show_fps: self.print(str(round(self.current_fps,2)), self.screen_size * .01, bg_color=BLACK_COLOR_PYG)
|
|
156
156
|
pg.display.flip()
|
|
157
157
|
|
|
158
158
|
def __update__(self) -> None:
|
e2D/plots.py
CHANGED
|
@@ -50,7 +50,7 @@ class Object:
|
|
|
50
50
|
self.plot.canvas.blit(self.__layer_surface__, (0,0))
|
|
51
51
|
|
|
52
52
|
class Line(Object):
|
|
53
|
-
def __init__(self, id:int|str, point_a:Vector2D|Point, point_b:Vector2D|Point, color:
|
|
53
|
+
def __init__(self, id:int|str, point_a:Vector2D|Point, point_b:Vector2D|Point, color:pg.Color=WHITE_COLOR_PYG, width:float=1) -> None:
|
|
54
54
|
super().__init__()
|
|
55
55
|
self.id = id
|
|
56
56
|
if isinstance(point_a, Point):
|
|
@@ -79,13 +79,13 @@ class Point(Object):
|
|
|
79
79
|
position : Vector2D,
|
|
80
80
|
label : str = "",
|
|
81
81
|
radius : float = 1,
|
|
82
|
-
color :
|
|
83
|
-
label_color :
|
|
82
|
+
color : pg.Color = WHITE_COLOR_PYG,
|
|
83
|
+
label_color : pg.Color = WHITE_COLOR_PYG,
|
|
84
84
|
label_position_offset : Vector2D = Vector2D.zero(),
|
|
85
85
|
label_pivot_position : __LITERAL_PIVOT_POSITIONS__ = "top_left",
|
|
86
86
|
label_font : pg.font.Font = FONT_ARIAL_32,
|
|
87
|
-
label_bg_color :
|
|
88
|
-
label_border_color :
|
|
87
|
+
label_bg_color : pg.Color|None = None,
|
|
88
|
+
label_border_color : pg.Color|None = None,
|
|
89
89
|
label_border_width : float = 0,
|
|
90
90
|
label_border_radius : int|list[int]|tuple[int,int,int,int] = -1,
|
|
91
91
|
label_margin : Vector2D = Vector2D.zero()
|
|
@@ -128,7 +128,7 @@ class MathFunction(Function):
|
|
|
128
128
|
function:Callable[[np.ndarray, np.ndarray], np.ndarray],
|
|
129
129
|
domain:list[float]=[-np.inf, np.inf],
|
|
130
130
|
codomain:list[float]=[-np.inf, np.inf],
|
|
131
|
-
color:
|
|
131
|
+
color:pg.Color=WHITE_COLOR_PYG) -> None:
|
|
132
132
|
super().__init__()
|
|
133
133
|
self.id = id
|
|
134
134
|
self.color = color
|
|
@@ -162,7 +162,7 @@ class MathFunction(Function):
|
|
|
162
162
|
self.points = self.get_points()
|
|
163
163
|
self.__render__()
|
|
164
164
|
|
|
165
|
-
def get_derivative(self, delta:float=.01, color:None|
|
|
165
|
+
def get_derivative(self, delta:float=.01, color:None|pg.Color=None) -> MathFunction:
|
|
166
166
|
return MathFunction(lambda x,y: (self.function(x + delta, y) - self.function(x,y))/delta - y, color if color != None else self.color) #type: ignore
|
|
167
167
|
|
|
168
168
|
def __render__(self) -> None:
|
|
@@ -181,7 +181,7 @@ class MathFunction(Function):
|
|
|
181
181
|
self.__layer_surface__.set_at(point, self.color) #type: ignore
|
|
182
182
|
|
|
183
183
|
class TimeFunction(Function):
|
|
184
|
-
def __init__(self, id:int|str, function, t_range:list[float]=[0,0, 1.0], t_step:float=.01, color:
|
|
184
|
+
def __init__(self, id:int|str, function, t_range:list[float]=[0,0, 1.0], t_step:float=.01, color:pg.Color=WHITE_COLOR_PYG) -> None:
|
|
185
185
|
super().__init__()
|
|
186
186
|
self.id = id
|
|
187
187
|
self.color = color
|
|
@@ -222,7 +222,7 @@ class TimeFunction(Function):
|
|
|
222
222
|
self.__layer_surface__.set_at(point, self.color) #type: ignore
|
|
223
223
|
|
|
224
224
|
class PointsFunction(Function):
|
|
225
|
-
def __init__(self, id:int|str, points:list[Vector2D]=[], points_color:
|
|
225
|
+
def __init__(self, id:int|str, points:list[Vector2D]=[], points_color:pg.Color=RED_COLOR_PYG, color:pg.Color=WHITE_COLOR_PYG) -> None:
|
|
226
226
|
super().__init__()
|
|
227
227
|
self.id = id
|
|
228
228
|
self.color = color
|
|
@@ -251,7 +251,7 @@ def no_error_complex_function(function, args) -> Vector2D:
|
|
|
251
251
|
return Vector2D(res.real, res.imag)
|
|
252
252
|
sign = lambda value: -1 if value < 0 else (1 if value > 0 else 0)
|
|
253
253
|
class ComplexFunction:
|
|
254
|
-
def __init__(self, function, plot:"Plot", starting_t:float=-10, ending_t:float=10, step=.01, color=
|
|
254
|
+
def __init__(self, function, plot:"Plot", starting_t:float=-10, ending_t:float=10, step=.01, color=WHITE_COLOR_PYG, auto_connect_treshold=float("inf"), points_radius=2, points_color=None) -> None:
|
|
255
255
|
self.auto_connect_treshold = auto_connect_treshold
|
|
256
256
|
self.plot = plot
|
|
257
257
|
self.starting_t = starting_t
|
|
@@ -288,7 +288,7 @@ class ComplexFunction:
|
|
|
288
288
|
class __PlotSettings__:
|
|
289
289
|
def __init__(self, plot:Plot) -> None:
|
|
290
290
|
self.plot = plot
|
|
291
|
-
self.settings :dict[__LITERAL_SETTINGS_KEYS__, int|float|bool|Vector2D|
|
|
291
|
+
self.settings :dict[__LITERAL_SETTINGS_KEYS__, int|float|bool|Vector2D|pg.Color|pg.font.Font]= {
|
|
292
292
|
# axes
|
|
293
293
|
"distance_to_axis_for_scalar_zoom" : 10,
|
|
294
294
|
|
|
@@ -305,11 +305,11 @@ class __PlotSettings__:
|
|
|
305
305
|
|
|
306
306
|
# axes
|
|
307
307
|
"change_axes_colors_on_mouse_hover" : True,
|
|
308
|
-
"mouse_hover_axes_color" :
|
|
308
|
+
"mouse_hover_axes_color" : Color(200, 200, 200)(),
|
|
309
309
|
"show_axes" : True,
|
|
310
310
|
"show_x_axis" : True,
|
|
311
311
|
"show_y_axis" : True,
|
|
312
|
-
"axes_default_color" :
|
|
312
|
+
"axes_default_color" : Color(100, 100, 100)(),
|
|
313
313
|
"x_axis_color" : None,
|
|
314
314
|
"y_axis_color" : None,
|
|
315
315
|
"axes_default_width" : 5,
|
|
@@ -320,22 +320,22 @@ class __PlotSettings__:
|
|
|
320
320
|
# grid
|
|
321
321
|
"show_grid" : True,
|
|
322
322
|
"grid_step" : Vector2D(PI, 1),
|
|
323
|
-
"grid_color" :
|
|
323
|
+
"grid_color" : Color(17, 65, 68)(),
|
|
324
324
|
"grid_width" : 1,
|
|
325
325
|
|
|
326
326
|
# pointer
|
|
327
327
|
"show_pointer" : True,
|
|
328
328
|
"pointer_radius" : 15,
|
|
329
|
-
"pointer_color" :
|
|
329
|
+
"pointer_color" : WHITE_COLOR_PYG,
|
|
330
330
|
|
|
331
331
|
# cursor
|
|
332
332
|
"show_cursor_coords" : False,
|
|
333
333
|
|
|
334
334
|
# rect
|
|
335
335
|
"render_bg" : True,
|
|
336
|
-
"bg_color" :
|
|
336
|
+
"bg_color" : Color(28, 29, 34)(),
|
|
337
337
|
"draw_rect" : True,
|
|
338
|
-
"rect_color" :
|
|
338
|
+
"rect_color" : WHITE_COLOR_PYG,
|
|
339
339
|
"rect_width" : 5,
|
|
340
340
|
"show_corners_coords" : True,
|
|
341
341
|
|
|
@@ -364,17 +364,17 @@ class __PlotSettings__:
|
|
|
364
364
|
def toggle(self, key:__LITERAL_SETTINGS_KEYS__) -> None:
|
|
365
365
|
self.set(key, not self.get(key))
|
|
366
366
|
|
|
367
|
-
def set(self, key:__LITERAL_SETTINGS_KEYS__, new_value:int|float|bool|Vector2D|
|
|
367
|
+
def set(self, key:__LITERAL_SETTINGS_KEYS__, new_value:int|float|bool|Vector2D|pg.Color|pg.font.Font) -> None:
|
|
368
368
|
if not (key in self.settings): raise ValueError(f"The key [{key}] does not exist...")
|
|
369
369
|
self.settings[key] = new_value
|
|
370
370
|
|
|
371
|
-
def multiple_set(self, new_key_and_values_dict:dict[__LITERAL_SETTINGS_KEYS__, int|float|bool|Vector2D|
|
|
371
|
+
def multiple_set(self, new_key_and_values_dict:dict[__LITERAL_SETTINGS_KEYS__, int|float|bool|Vector2D|pg.Color|pg.font.Font]) -> None:
|
|
372
372
|
self.settings.update(new_key_and_values_dict)
|
|
373
373
|
|
|
374
|
-
def get(self, key:__LITERAL_SETTINGS_KEYS__) -> int|float|bool|Vector2D|
|
|
374
|
+
def get(self, key:__LITERAL_SETTINGS_KEYS__) -> int|float|bool|Vector2D|pg.Color|pg.font.Font:
|
|
375
375
|
return self.settings[key]
|
|
376
376
|
|
|
377
|
-
def multiple_get(self, keys:list[__LITERAL_SETTINGS_KEYS__]) -> list[int|float|bool|Vector2D|
|
|
377
|
+
def multiple_get(self, keys:list[__LITERAL_SETTINGS_KEYS__]) -> list[int|float|bool|Vector2D|pg.Color|pg.font.Font]:
|
|
378
378
|
return [self.get(key) for key in keys]
|
|
379
379
|
|
|
380
380
|
class Plot:
|
|
@@ -483,10 +483,10 @@ class Plot:
|
|
|
483
483
|
pg.draw.circle(self.canvas, pointer_color, (self.size * .5)(), 15, 1) #type: ignore
|
|
484
484
|
|
|
485
485
|
if self.settings.get("show_corners_coords"):
|
|
486
|
-
self.rootEnv.print(self.top_left_plot_coord.advanced_stringify(4, True), Vector2D.zero(), bg_color=
|
|
487
|
-
self.rootEnv.print(Vector2D(self.top_left_plot_coord.x, self.bottom_right_plot_coord.y).advanced_stringify(4, True), self.size * Vector2D(0, 1), pivot_position="bottom_left", bg_color=
|
|
488
|
-
self.rootEnv.print(self.bottom_right_plot_coord.advanced_stringify(4, True), self.size.copy, pivot_position="bottom_right", bg_color=
|
|
489
|
-
self.rootEnv.print(Vector2D(self.bottom_right_plot_coord.x, self.top_left_plot_coord.y).advanced_stringify(4, True), self.size * Vector2D(1, 0), pivot_position="top_right", bg_color=
|
|
486
|
+
self.rootEnv.print(self.top_left_plot_coord.advanced_stringify(4, True), Vector2D.zero(), bg_color=BLACK_COLOR_PYG, border_color=WHITE_COLOR_PYG, border_width=2, border_radius=15, margin=Vector2D(10,10), personalized_surface=self.canvas)
|
|
487
|
+
self.rootEnv.print(Vector2D(self.top_left_plot_coord.x, self.bottom_right_plot_coord.y).advanced_stringify(4, True), self.size * Vector2D(0, 1), pivot_position="bottom_left", bg_color=BLACK_COLOR_PYG, border_color=WHITE_COLOR_PYG, border_width=2, border_radius=15, margin=Vector2D(10,10), personalized_surface=self.canvas)
|
|
488
|
+
self.rootEnv.print(self.bottom_right_plot_coord.advanced_stringify(4, True), self.size.copy, pivot_position="bottom_right", bg_color=BLACK_COLOR_PYG, border_color=WHITE_COLOR_PYG, border_width=2, border_radius=15, margin=Vector2D(10,10), personalized_surface=self.canvas)
|
|
489
|
+
self.rootEnv.print(Vector2D(self.bottom_right_plot_coord.x, self.top_left_plot_coord.y).advanced_stringify(4, True), self.size * Vector2D(1, 0), pivot_position="top_right", bg_color=BLACK_COLOR_PYG, border_color=WHITE_COLOR_PYG, border_width=2, border_radius=15, margin=Vector2D(10,10), personalized_surface=self.canvas)
|
|
490
490
|
|
|
491
491
|
def update(self) -> None:
|
|
492
492
|
# update mouse and center positions
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: e2D
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.18
|
|
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,13 @@
|
|
|
1
|
+
e2D/__init__.py,sha256=yWKj--yODW8diDHRrIDKA-lfc9e-I4NQXVaK-eJOhxw,22043
|
|
2
|
+
e2D/__init__.pyi,sha256=1qEXUQC2o58Zsd8fF-UrOE0tRBbIbRG1U4vqn8iYWkI,43414
|
|
3
|
+
e2D/colors.py,sha256=DgkgUdaQY41nA0VlJaMaT6VZwypG--Cw3Pwakf4OVHM,17412
|
|
4
|
+
e2D/def_colors.py,sha256=3sJq2L6qFZ3svn2qEWIx0SinNXjb9huNaFigDeJipm8,43805
|
|
5
|
+
e2D/envs.py,sha256=1IMQxQVYI3nx4aq1HhxeIhEyq9BKa7Vt0V4lUKL-oNA,6324
|
|
6
|
+
e2D/plots.py,sha256=_d72ZJo-GIhcJ44XCphFH288cf_ZSwWcbLh_olgGjBc,35880
|
|
7
|
+
e2D/utils.py,sha256=cJarYc6OTIdud7AJZHxwOhxMcEJLlgfKu60kkBu4hB8,14116
|
|
8
|
+
e2D/winrec.py,sha256=EFFfWYbk27NhS-rWD-BLChXvLjFW1uYZ5LkRGMj_Xo0,1116
|
|
9
|
+
e2D-1.4.18.dist-info/LICENSE,sha256=wymkNVDvj3qmjdO_rAhkRPM4t5y3_SqffGsFdgfvznU,1066
|
|
10
|
+
e2D-1.4.18.dist-info/METADATA,sha256=ik2MYSLN2AWYo0yr8CTOZst4k6N1tGy06yipbqrOOSg,9611
|
|
11
|
+
e2D-1.4.18.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
12
|
+
e2D-1.4.18.dist-info/top_level.txt,sha256=3vKZ-CGzNlTCpzVMmM0Ht76krCofKw7hZ0wBf-dnKdM,4
|
|
13
|
+
e2D-1.4.18.dist-info/RECORD,,
|
e2D-1.4.16.dist-info/RECORD
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
e2D/__init__.py,sha256=CtupqrGE_LUp310YGk4EqHuOlWe-nSAikc4uhzKiCME,23014
|
|
2
|
-
e2D/__init__.pyi,sha256=rMceBt26-bozw_Xt3JQWfQ_20G8RAkE2j4CqIf7PIuQ,48013
|
|
3
|
-
e2D/colors.py,sha256=2pMvI6n6l1fsxmXywlhO3gZSkpegmMT4lQL51Nu_hNI,20319
|
|
4
|
-
e2D/envs.py,sha256=W8SC30_U5SaYFld9DcdG-_jgzbqX366S4OoMSgU_Pbc,6316
|
|
5
|
-
e2D/plots.py,sha256=MTvIeQl_9ASDW7QUd6fgrL2IDK-5NFtiXsm7rhFKdNs,36078
|
|
6
|
-
e2D/utils.py,sha256=cJarYc6OTIdud7AJZHxwOhxMcEJLlgfKu60kkBu4hB8,14116
|
|
7
|
-
e2D/winrec.py,sha256=EFFfWYbk27NhS-rWD-BLChXvLjFW1uYZ5LkRGMj_Xo0,1116
|
|
8
|
-
e2D-1.4.16.dist-info/LICENSE,sha256=wymkNVDvj3qmjdO_rAhkRPM4t5y3_SqffGsFdgfvznU,1066
|
|
9
|
-
e2D-1.4.16.dist-info/METADATA,sha256=wKb-TFAUr-oT2WEY1kgJIWojQQCFs1fQwyahjQDyng4,9611
|
|
10
|
-
e2D-1.4.16.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
11
|
-
e2D-1.4.16.dist-info/top_level.txt,sha256=3vKZ-CGzNlTCpzVMmM0Ht76krCofKw7hZ0wBf-dnKdM,4
|
|
12
|
-
e2D-1.4.16.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|