e2D 1.4.15__py3-none-any.whl → 1.4.17__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/envs.py CHANGED
@@ -38,7 +38,7 @@ class RootEnv:
38
38
  def __init__(self,
39
39
  screen_size : Vector2D = Vector2D(1920, 1080),
40
40
  target_fps : int = 60,
41
- show_fps = True,
41
+ show_fps : bool = True,
42
42
  quit_on_key_pressed : None|int = pg.K_x,
43
43
  vsync : bool = True,
44
44
  window_flags : int = pg.DOUBLEBUF,
@@ -59,12 +59,11 @@ 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 = rgb(0,0,0)
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
66
66
  self.__quit_on_key_pressed__ = quit_on_key_pressed
67
-
68
67
 
69
68
  @property
70
69
  def screen_size(self) -> Vector2D:
@@ -72,6 +71,7 @@ class RootEnv:
72
71
 
73
72
  @screen_size.setter
74
73
  def screen_size(self, new_size:Vector2D) -> None:
74
+ self.__screen_size__ = new_size
75
75
  self.screen = pg.display.set_mode(self.__screen_size__(), vsync=self.__vsync__, flags=self.__flags__)
76
76
 
77
77
  @property
@@ -81,22 +81,23 @@ class RootEnv:
81
81
  def get_teoric_max_fps(self) -> float:
82
82
  rawdelta = self.clock.get_rawtime()
83
83
  return (1000 / rawdelta) if rawdelta != 0 else 1
84
-
84
+
85
85
  def update_screen_mode(self, vsync:None|bool=None, flags=None) -> None:
86
- pass
87
-
86
+ self.__vsync__ = vsync
87
+ self.__flags__ = flags
88
+
88
89
  def sleep(self, seconds:int|float, precise_delay=False) -> None:
89
90
  if precise_delay:
90
91
  pg.time.delay(seconds * 1000)
91
92
  else:
92
93
  pg.time.wait(seconds * 1000)
93
-
94
+
94
95
  def add_utils(self, *utils:Util) -> None:
95
96
  for util in utils:
96
97
  if util.surface == None: util.surface = self.screen
97
98
  util.rootEnv = self
98
99
  self.utils[util.id] = util
99
-
100
+
100
101
  def remove_utils(self, *utils:int|str|Util) -> None:
101
102
  for uid in utils:
102
103
  if uid in self.utils:
@@ -105,29 +106,29 @@ class RootEnv:
105
106
  del self.utils[uid.id]
106
107
  else:
107
108
  raise Exception(f"Unknown util type: {uid}")
108
-
109
+
109
110
  @property
110
111
  def runtime_seconds(self) -> float:
111
112
  return pg.time.get_ticks() / 1e3
112
-
113
+
113
114
  def init(self, sub_env:DefEnv) -> None:
114
115
  self.env = sub_env
115
-
116
+
116
117
  def clear(self) -> None:
117
118
  self.screen.fill(self.background_color)
118
-
119
+
119
120
  def clear_rect(self, position:Vector2D, size:Vector2D) -> None:
120
121
  self.screen.fill(self.background_color, position() + size())
121
-
122
+
122
123
  def print(self,
123
124
  text : str,
124
125
  position : Vector2D,
125
- color : tuple[float,float,float] = (255,255,255),
126
+ color : pg.color.Color = WHITE_COLOR_PYG,
126
127
  pivot_position : __LITERAL_PIVOT_POSITIONS__ = "top_left",
127
128
  font : pg.font.Font = FONT_ARIAL_32,
128
- bg_color : None|tuple[int,int,int]|list[int] = None,
129
- border_color : None|tuple[int,int,int]|list[int] = (255,255,255),
130
- border_width : float = 0,
129
+ bg_color : None|pg.color.Color = None,
130
+ border_color : pg.color.Color = WHITE_COLOR_PYG,
131
+ border_width : float = 0.0,
131
132
  border_radius : int|list[int]|tuple[int,int,int,int] = -1,
132
133
  margin : Vector2D = Vector2D.zero(),
133
134
  personalized_surface : pg.Surface|None = None
@@ -147,13 +148,13 @@ class RootEnv:
147
148
  self.clock.tick(self.target_fps)
148
149
  self.current_fps = self.clock.get_fps()
149
150
  if self.clear_screen_each_frame: self.clear()
150
-
151
+
151
152
  self.env.draw()
152
153
  for util in self.utils.values(): util.draw()
153
-
154
- if self.show_fps: self.print(str(round(self.current_fps,2)), self.screen_size * .01, bg_color=(0,0,0))
154
+
155
+ if self.show_fps: self.print(str(round(self.current_fps,2)), self.screen_size * .01, bg_color=BLACK_COLOR_PYG)
155
156
  pg.display.flip()
156
-
157
+
157
158
  def __update__(self) -> None:
158
159
  self.mouse.update()
159
160
  self.keyboard.update()
@@ -168,4 +169,5 @@ class RootEnv:
168
169
 
169
170
  for event in self.events:
170
171
  if event.type == pg.QUIT or ((event.type == pg.KEYDOWN and event.key == self.__quit_on_key_pressed__ and self.selected_util == None) if self.__quit_on_key_pressed__ != None else False):
172
+ pg.quit()
171
173
  self.quit = True
e2D/plots.py CHANGED
@@ -125,7 +125,7 @@ class Point(Object):
125
125
  class MathFunction(Function):
126
126
  def __init__(self,
127
127
  id:int|str,
128
- function:Callable[[int|float, int|float], int|float],
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
131
  color:list[float]|tuple[float,float,float]=(255,255,255)) -> None:
e2D/utils.py CHANGED
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
  from typing import Any, Callable, Literal
3
3
  import pygame as pg
4
4
  from e2D import *
5
+ from e2D.colors import *
5
6
 
6
7
  import math as _mt
7
8
 
@@ -12,7 +13,8 @@ __LITERAL_KEY_MODE_TYPES__ = Literal["pressed", "just_pressed", "just_released"]
12
13
 
13
14
  __LITERAL_FONTS__ = Literal['arial', 'arialblack', 'bahnschrift', 'calibri', 'cambria', 'cambriamath', 'candara', 'comicsansms', 'consolas', 'constantia', 'corbel', 'couriernew', 'ebrima', 'franklingothicmedium', 'gabriola', 'gadugi', 'georgia', 'impact', 'inkfree', 'javanesetext', 'leelawadeeui', 'leelawadeeuisemilight', 'lucidaconsole', 'lucidasans', 'malgungothic', 'malgungothicsemilight', 'microsofthimalaya', 'microsoftjhenghei', 'microsoftjhengheiui', 'microsoftnewtailue', 'microsoftphagspa', 'microsoftsansserif', 'microsofttaile', 'microsoftyahei', 'microsoftyaheiui', 'microsoftyibaiti', 'mingliuextb', 'pmingliuextb', 'mingliuhkscsextb', 'mongolianbaiti', 'msgothic', 'msuigothic', 'mspgothic', 'mvboli', 'myanmartext', 'nirmalaui', 'nirmalauisemilight', 'palatinolinotype', 'segoemdl2assets', 'segoeprint', 'segoescript', 'segoeui', 'segoeuiblack', 'segoeuiemoji', 'segoeuihistoric', 'segoeuisemibold', 'segoeuisemilight', 'segoeuisymbol', 'simsun', 'nsimsun', 'simsunextb', 'sitkasmall', 'sitkatext', 'sitkasubheading', 'sitkaheading', 'sitkadisplay', 'sitkabanner', 'sylfaen', 'symbol', 'tahoma', 'timesnewroman', 'trebuchetms', 'verdana', 'webdings', 'wingdings', 'yugothic', 'yugothicuisemibold', 'yugothicui', 'yugothicmedium', 'yugothicuiregular', 'yugothicregular', 'yugothicuisemilight', 'holomdl2assets', 'bizudgothic', 'bizudpgothictruetype', 'bizudminchomedium', 'bizudpminchomediumtruetype', 'meiryo', 'meiryoui', 'msmincho', 'mspmincho', 'uddigikyokashonb', 'uddigikyokashonpb', 'uddigikyokashonkb', 'uddigikyokashonr', 'uddigikyokashonpr', 'uddigikyokashonkr', 'yumincho', 'lcd', 'glassgauge', 'maiandragd', 'maiandragddemi', 'newsgothic', 'quartz', 'kievitoffcpro', 'agencyfbgrassetto', 'agencyfb', 'algerian', 'bookantiquagrassetto', 'bookantiquagrassettocorsivo', 'bookantiquacorsivo', 'arialcorsivo', 'arialrounded', 'baskervilleoldface', 'bauhaus93', 'bell', 'bellgrassetto', 'bellcorsivo', 'bernardcondensed', 'bookantiqua', 'bodonigrassetto', 'bodonigrassettocorsivo', 'bodoniblackcorsivo', 'bodoniblack', 'bodonicondensedgrassetto', 'bodonicondensedgrassettocorsivo', 'bodonicondensedcorsivo', 'bodonicondensed', 'bodonicorsivo', 'bodonipostercompressed', 'bodoni', 'bookmanoldstyle', 'bookmanoldstylegrassetto', 'bookmanoldstylegrassettocorsivo', 'bookmanoldstylecorsivo', 'bradleyhanditc', 'britannic', 'berlinsansfbgrassetto', 'berlinsansfbdemigrassetto', 'berlinsansfb', 'broadway', 'brushscriptcorsivo', 'bookshelfsymbol7', 'californianfbgrassetto', 'californianfbcorsivo', 'californianfb', 'calisto', 'calistograssetto', 'calistograssettocorsivo', 'calistocorsivo', 'castellar', 'centuryschoolbook', 'centaur', 'century', 'chiller', 'colonna', 'cooperblack', 'copperplategothic', 'curlz', 'dubai', 'dubaimedium', 'dubairegular', 'elephant', 'elephantcorsivo', 'engravers', 'erasitc', 'erasdemiitc', 'erasmediumitc', 'felixtitling', 'forte', 'franklingothicbook', 'franklingothicbookcorsivo', 'franklingothicdemi', 'franklingothicdemicond', 'franklingothicdemicorsivo', 'franklingothicheavy', 'franklingothicheavycorsivo', 'franklingothicmediumcond', 'freestylescript', 'frenchscript', 'footlight', 'garamond', 'garamondgrassetto', 'garamondcorsivo', 'gigi', 'gillsansgrassettocorsivo', 'gillsansgrassetto', 'gillsanscondensed', 'gillsanscorsivo', 'gillsansultracondensed', 'gillsansultra', 'gillsans', 'gloucesterextracondensed', 'gillsansextcondensed', 'centurygothic', 'centurygothicgrassetto', 'centurygothicgrassettocorsivo', 'centurygothiccorsivo', 'goudyoldstyle', 'goudyoldstylegrassetto', 'goudyoldstylecorsivo', 'goudystout', 'harlowsolid', 'harrington', 'haettenschweiler', 'hightowertext', 'hightowertextcorsivo', 'imprintshadow', 'informalroman', 'blackadderitc', 'kristenitc', 'jokerman', 'juiceitc', 'kunstlerscript', 'widelatin', 'lucidabright', 'lucidacalligraphy', 'leelawadee', 'leelawadeegrassetto', 'lucidafax', 'lucidafaxdemigrassetto', 'lucidafaxdemigrassettocorsivo', 'lucidafaxcorsivo', 'lucidahandwritingcorsivo', 'lucidasansdemigrassetto', 'lucidasansdemigrassettocorsivo', 'lucidasanscorsivo', 'lucidasanstypewriter', 'lucidasanstypewritergrassetto', 'lucidasanstypewritergrassettooblique', 'lucidasanstypewriteroblique', 'magnetograssetto', 'maturascriptcapitals', 'mistral', 'modernno20', 'microsoftuighurgrassetto', 'microsoftuighur', 'monotypecorsiva', 'extra', 'niagaraengraved', 'niagarasolid', 'ocraextended', 'oldenglishtext', 'onyx', 'msoutlook', 'palacescript', 'papyrus', 'parchment', 'perpetuagrassettocorsivo', 'perpetuagrassetto', 'perpetuacorsivo', 'perpetuatitlinggrassetto', 'perpetuatitlingchiarissimo', 'perpetua', 'playbill', 'poorrichard', 'pristina', 'rage', 'ravie', 'msreferencesansserif', 'msreferencespecialty', 'rockwellcondensedgrassetto', 'rockwellcondensed', 'rockwell', 'rockwellgrassetto', 'rockwellgrassettocorsivo', 'rockwellextra', 'rockwellcorsivo', 'centuryschoolbookgrassetto', 'centuryschoolbookgrassettocorsivo', 'centuryschoolbookcorsivo', 'script', 'showcardgothic', 'snapitc', 'stencil', 'twcengrassettocorsivo', 'twcengrassetto', 'twcencondensedgrassetto', 'twcencondensedextra', 'twcencondensed', 'twcencorsivo', 'twcen', 'tempussansitc', 'vinerhanditc', 'vivaldicorsivo', 'vladimirscript', 'wingdings2', 'wingdings3', 'cascadiacoderegular', 'cascadiamonoregular', 'edwardianscriptitcnormale', 'stoneharbourregular', 'mregular', 'xirodregular', 'minecraft']
14
15
 
15
- NEW_FONT :Callable[[int, __LITERAL_FONTS__, bool, bool], pg.font.Font]= lambda size, name="arial", bold=False, italic=False: pg.font.SysFont(name, size, bold, italic)
16
+ def NEW_FONT(size, name:__LITERAL_FONTS__="arial", bold:bool=False, italic:bool=False) -> pg.font.Font:
17
+ return pg.font.SysFont(name, size, bold, italic)
16
18
  FONT_ARIAL_16 = NEW_FONT(16)
17
19
  FONT_ARIAL_32 = NEW_FONT(32)
18
20
  FONT_ARIAL_64 = NEW_FONT(64)
@@ -74,7 +76,7 @@ class Mouse:
74
76
 
75
77
  class Keyboard:
76
78
  def __init__(self) -> None:
77
- self.__pressed__ :list= pg.key.get_pressed()
79
+ self.__pressed__ :pg.key.ScancodeWrapper= pg.key.get_pressed()
78
80
  self.update()
79
81
 
80
82
  def update(self) -> None:
@@ -91,7 +93,6 @@ class Keyboard:
91
93
  else:
92
94
  raise Exception(f"Unknown mode type: {mode}")
93
95
 
94
-
95
96
  class Util:
96
97
  def __init__(self) -> None:
97
98
  self.rootEnv = None
@@ -108,9 +109,9 @@ class InputCell(Util):
108
109
  position : Vector2D,
109
110
  size : Vector2D,
110
111
  prefix : str|None = None,
111
- text_color : tuple[int,int,int]|list[int] = (255,255,255),
112
- bg_color : None|tuple[int,int,int]|list[int] = None,
113
- border_color : None|tuple[int,int,int]|list[int] = (255,255,255),
112
+ text_color : Color = Color.white(),
113
+ bg_color : None|Color = None,
114
+ border_color : Color = Color.white(),
114
115
  border_width : float = 0,
115
116
  border_radius : int|list[int]|tuple[int,int,int,int] = -1,
116
117
  margin : Vector2D = Vector2D.zero(),
@@ -148,13 +149,13 @@ class InputCell(Util):
148
149
  def draw(self) -> None:
149
150
  self.text_surface.fill((0,0,0,0))
150
151
  if self.bg_color != None:
151
- pg.draw.rect(self.text_surface, self.bg_color, self.bg_rect, 0, -1, *self.border_radius)
152
+ pg.draw.rect(self.text_surface, self.bg_color(), self.bg_rect, 0, -1, *self.border_radius)
152
153
 
153
154
  self.text_surface.blit(self.text_box, self.text_position())
154
155
 
155
156
  if self.rootEnv.selected_util != self:
156
157
  if self.border_width:
157
- pg.draw.rect(self.text_surface, self.border_color, self.margin_rect, self.border_width, -1, *self.border_radius)
158
+ pg.draw.rect(self.text_surface, self.border_color(), self.margin_rect, self.border_width, -1, *self.border_radius)
158
159
  else:
159
160
  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)
160
161
 
@@ -182,7 +183,7 @@ class InputCell(Util):
182
183
  self.update_text()
183
184
 
184
185
  def update_text(self) -> None:
185
- self.text_box = self.font.render(self.prefix + self.value, True, self.text_color)
186
+ self.text_box = self.font.render(self.prefix + self.value, True, self.text_color())
186
187
  if self.rootEnv != None and self.rootEnv.selected_util == self:
187
188
  # self.text_position = self.position + self.size * Vector2D(.85, .5) - Vector2D(*self.text_box.get_size()) * Vector2D(1, .5) - self.position
188
189
  self.text_position = self.position + self.size * .5 - Vector2D(*self.text_box.get_size()) * Vector2D(.5, .5) - self.position
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: e2D
3
- Version: 1.4.15
3
+ Version: 1.4.17
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=kY54r5Hv_5wFZ2xu_Fn1iIzew4hDm8Xnm7Sx7KZh4zw,23099
2
+ e2D/__init__.pyi,sha256=YgNYO9ungr1qqVnzQZe14v7_zt7jZ4lWtc5rBsA8TYY,48092
3
+ e2D/colors.py,sha256=7EXlRWmK-ie5XrEtpRAj3_TZ61AVGope2RTFRkEhyZ4,20396
4
+ e2D/def_colors.py,sha256=3sJq2L6qFZ3svn2qEWIx0SinNXjb9huNaFigDeJipm8,43805
5
+ e2D/envs.py,sha256=W2Yj-vPit_l8wKq6yPAT_gOrx9NBC-qy9cc0bCaN9C4,6342
6
+ e2D/plots.py,sha256=MTvIeQl_9ASDW7QUd6fgrL2IDK-5NFtiXsm7rhFKdNs,36078
7
+ e2D/utils.py,sha256=cJarYc6OTIdud7AJZHxwOhxMcEJLlgfKu60kkBu4hB8,14116
8
+ e2D/winrec.py,sha256=EFFfWYbk27NhS-rWD-BLChXvLjFW1uYZ5LkRGMj_Xo0,1116
9
+ e2D-1.4.17.dist-info/LICENSE,sha256=wymkNVDvj3qmjdO_rAhkRPM4t5y3_SqffGsFdgfvznU,1066
10
+ e2D-1.4.17.dist-info/METADATA,sha256=tCqqaOzNTZgLg95iJf9ejt510YB0XMCmiycwYVdRejc,9611
11
+ e2D-1.4.17.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
12
+ e2D-1.4.17.dist-info/top_level.txt,sha256=3vKZ-CGzNlTCpzVMmM0Ht76krCofKw7hZ0wBf-dnKdM,4
13
+ e2D-1.4.17.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,11 +0,0 @@
1
- e2D/__init__.py,sha256=_c-g4Fcqq3SuEHAzuWgRiJz_WtrHkhCa4sUV1ECxriE,23047
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.15.dist-info/LICENSE,sha256=wymkNVDvj3qmjdO_rAhkRPM4t5y3_SqffGsFdgfvznU,1066
8
- e2D-1.4.15.dist-info/METADATA,sha256=oFrU4Cpad58Ipuxxacs2Cj9b-qtl9_4FeDGnJ2Guvfs,9611
9
- e2D-1.4.15.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
10
- e2D-1.4.15.dist-info/top_level.txt,sha256=3vKZ-CGzNlTCpzVMmM0Ht76krCofKw7hZ0wBf-dnKdM,4
11
- e2D-1.4.15.dist-info/RECORD,,
File without changes