e2D 1.4.17__tar.gz → 1.4.19__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.17 → e2d-1.4.19}/LICENSE +1 -1
- {e2d-1.4.17 → e2d-1.4.19}/PKG-INFO +1 -1
- {e2d-1.4.17 → e2d-1.4.19}/e2D/__init__.py +2 -23
- {e2d-1.4.17 → e2d-1.4.19}/e2D/__init__.pyi +1 -133
- {e2d-1.4.17 → e2d-1.4.19}/e2D/colors.py +103 -129
- {e2d-1.4.17 → e2d-1.4.19}/e2D/envs.py +1 -1
- {e2d-1.4.17 → e2d-1.4.19}/e2D/plots.py +25 -25
- {e2d-1.4.17 → e2d-1.4.19}/e2D.egg-info/PKG-INFO +1 -1
- {e2d-1.4.17 → e2d-1.4.19}/setup.cfg +1 -1
- {e2d-1.4.17 → e2d-1.4.19}/README.md +0 -0
- {e2d-1.4.17 → e2d-1.4.19}/e2D/def_colors.py +0 -0
- {e2d-1.4.17 → e2d-1.4.19}/e2D/utils.py +0 -0
- {e2d-1.4.17 → e2d-1.4.19}/e2D/winrec.py +0 -0
- {e2d-1.4.17 → e2d-1.4.19}/e2D.egg-info/SOURCES.txt +0 -0
- {e2d-1.4.17 → e2d-1.4.19}/e2D.egg-info/dependency_links.txt +0 -0
- {e2d-1.4.17 → e2d-1.4.19}/e2D.egg-info/requires.txt +0 -0
- {e2d-1.4.17 → e2d-1.4.19}/e2D.egg-info/top_level.txt +0 -0
- {e2d-1.4.17 → e2d-1.4.19}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: e2D
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.19
|
|
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
|
|
@@ -71,7 +71,7 @@ class Vector2D:
|
|
|
71
71
|
return self.__round__(n)
|
|
72
72
|
|
|
73
73
|
@classmethod
|
|
74
|
-
def randomize(cls, start, end) -> "Vector2D":
|
|
74
|
+
def randomize(cls, start, end, func=lambda val:val) -> "Vector2D":
|
|
75
75
|
if not isinstance(start, Vector2D):
|
|
76
76
|
if isinstance(start, (int, float)):
|
|
77
77
|
start = Vector2D(start, start)
|
|
@@ -82,7 +82,7 @@ class Vector2D:
|
|
|
82
82
|
end = Vector2D(end, end)
|
|
83
83
|
else:
|
|
84
84
|
raise Exception(f"\nArg end must be in [Vector2D, int, float, tuple, list] not a [{type(end)}]\n")
|
|
85
|
-
return start + Vector2D(_rnd.random(), _rnd.random()) * (end - start)
|
|
85
|
+
return start + Vector2D(func(_rnd.random()), func(_rnd.random())) * (end - start)
|
|
86
86
|
|
|
87
87
|
def dot_product(self, other) -> float:
|
|
88
88
|
return self.x * other.x + self.y * other.y
|
|
@@ -498,27 +498,6 @@ VECTORS_4_SEMIDIRECTIONS_NORM = (V2down_right_norm, V2down_left_norm, V2up_left_
|
|
|
498
498
|
VECTORS_8_DIRECTIONS = (V2right, V2down_right, V2down, V2down_left, V2left, V2up_left, V2up, V2up_right)
|
|
499
499
|
VECTORS_8_DIRECTIONS_NORM = (V2right, V2down_right_norm, V2down, V2down_left_norm, V2left, V2up_left_norm, V2up, V2up_right_norm)
|
|
500
500
|
|
|
501
|
-
|
|
502
|
-
def rgb(r:float, g:float, b:float) -> tuple[float, float, float]:
|
|
503
|
-
return (r,g,b)
|
|
504
|
-
|
|
505
|
-
def color_lerp(current_c:list|tuple, final_c:list|tuple, step=.1) -> tuple[float, float, float]:
|
|
506
|
-
return tuple(c + (final_c[i] - c) * step for i,c in enumerate(current_c)) #type: ignore
|
|
507
|
-
|
|
508
|
-
def color_fade(starting_c:list|tuple, final_c:list|tuple, index, max_index) -> tuple[float, float, float]:
|
|
509
|
-
return tuple((starting_c[i] - final_c[i]) / max_index * (max_index - index) + final_c[i] for i in range(3)) #type: ignore
|
|
510
|
-
|
|
511
|
-
def weighted_color_fade(colors_dict:dict) -> tuple[float, float, float]:
|
|
512
|
-
colors = colors_dict.keys()
|
|
513
|
-
weights = colors_dict.values()
|
|
514
|
-
|
|
515
|
-
if float("inf") in weights: return list(colors)[list(weights).index(float("inf"))]
|
|
516
|
-
return tuple(sum(n[i]*w for n,w in zip(colors, weights)) / sum(weights) for i in range(3)) #type: ignore
|
|
517
|
-
|
|
518
|
-
def color_distance(starting_c:list|tuple, final_c:list|tuple, rooted) -> float:
|
|
519
|
-
distance = sum([(starting_c[i]-final_c[i])**2 for i in range(3)])
|
|
520
|
-
return (distance ** .5) if rooted else distance
|
|
521
|
-
|
|
522
501
|
def lerp(starting, ending, step=.1) -> float:
|
|
523
502
|
return starting + (ending - starting) * step
|
|
524
503
|
|
|
@@ -264,7 +264,7 @@ class Vector2D:
|
|
|
264
264
|
...
|
|
265
265
|
|
|
266
266
|
@classmethod
|
|
267
|
-
def randomize(cls, start:"int|float|Vector2D", end:"int|float|Vector2D") -> "Vector2D":
|
|
267
|
+
def randomize(cls, start:"int|float|Vector2D", end:"int|float|Vector2D", func:Callable[[int|float], int|float]=lambda val:val) -> "Vector2D":
|
|
268
268
|
"""
|
|
269
269
|
# Generate a random Vector2D point within the specified range.
|
|
270
270
|
|
|
@@ -800,140 +800,8 @@ VECTORS_4_SEMIDIRECTIONS_NORM : tuple[Vector2D, Vector2D, Vector2D, Vector2D,]
|
|
|
800
800
|
VECTORS_8_DIRECTIONS : tuple[Vector2D, Vector2D, Vector2D, Vector2D, Vector2D, Vector2D, Vector2D, Vector2D]
|
|
801
801
|
VECTORS_8_DIRECTIONS_NORM : tuple[Vector2D, Vector2D, Vector2D, Vector2D, Vector2D, Vector2D, Vector2D, Vector2D]
|
|
802
802
|
|
|
803
|
-
|
|
804
|
-
def rgb(r:float, g:float, b:float) -> tuple[float, float, float]:
|
|
805
|
-
return (r,g,b)
|
|
806
|
-
|
|
807
803
|
def lerp(starting: int|float, ending: int|float, step: int|float=.1) -> float: ...
|
|
808
804
|
|
|
809
|
-
def color_lerp(current_c: list|tuple, final_c: list|tuple, step: int|float=.1) -> tuple[float, float, float]:
|
|
810
|
-
"""
|
|
811
|
-
# Linearly interpolate between two colors.
|
|
812
|
-
|
|
813
|
-
## Parameters:
|
|
814
|
-
current_c (tuple or list): The RGB values of the current color as a tuple or list.
|
|
815
|
-
final_c (tuple or list): The RGB values of the target color as a tuple or list.
|
|
816
|
-
step (int or float): The interpolation step, ranging from 0.0 (current color) to 1.0 (target color).
|
|
817
|
-
|
|
818
|
-
## Returns:
|
|
819
|
-
tuple: The RGB values of the interpolated color as a tuple.
|
|
820
|
-
|
|
821
|
-
## Example:
|
|
822
|
-
current_c = (255, 0, 0)
|
|
823
|
-
|
|
824
|
-
final_c = (0, 0, 255)
|
|
825
|
-
|
|
826
|
-
step = 0.5
|
|
827
|
-
|
|
828
|
-
interpolated_color = color_lerp(current_c, final_c, step)
|
|
829
|
-
|
|
830
|
-
print(f"At step {step}: RGB {interpolated_color}")
|
|
831
|
-
|
|
832
|
-
This will calculate the color at an interpolation step of 0.5 between (255, 0, 0) and (0, 0, 255).
|
|
833
|
-
"""
|
|
834
|
-
...
|
|
835
|
-
|
|
836
|
-
def color_fade(starting_c: list|tuple, final_c: list|tuple, index: int|float, max_index: int|float) -> tuple[float, float, float]:
|
|
837
|
-
"""
|
|
838
|
-
# Calculate the color at a specific index of a color fade between two given colors.
|
|
839
|
-
|
|
840
|
-
## Parameters:
|
|
841
|
-
starting_c (tuple or list): The RGB values of the starting color as a tuple or list.
|
|
842
|
-
final_c (tuple or list): The RGB values of the final color as a tuple or list.
|
|
843
|
-
index (int or float): The current index of the color fade, representing a position
|
|
844
|
-
between the starting and final colors.
|
|
845
|
-
max_index (int or float): The maximum index of the color fade, indicating the endpoint
|
|
846
|
-
position between the starting and final colors.
|
|
847
|
-
|
|
848
|
-
## Returns:
|
|
849
|
-
tuple: The RGB values of the color at the specified index as a tuple.
|
|
850
|
-
|
|
851
|
-
## Example:
|
|
852
|
-
starting_c = (255, 0, 0)
|
|
853
|
-
|
|
854
|
-
final_c = (0, 0, 255)
|
|
855
|
-
|
|
856
|
-
max_index = 100
|
|
857
|
-
|
|
858
|
-
for i in range(max_index + 1):
|
|
859
|
-
|
|
860
|
-
color_at_index = color_fade(starting_c, final_c, i, max_index)
|
|
861
|
-
|
|
862
|
-
print(f"At index {i}: RGB {color_at_index}")
|
|
863
|
-
|
|
864
|
-
This will print the colors transitioning from (255, 0, 0) to (0, 0, 255).
|
|
865
|
-
"""
|
|
866
|
-
...
|
|
867
|
-
|
|
868
|
-
def weighted_color_fade(colors_dict:dict) -> tuple[float, float, float]:
|
|
869
|
-
"""
|
|
870
|
-
# Calculate the weighted color based on a dictionary of colors and their corresponding weights.
|
|
871
|
-
|
|
872
|
-
## Parameters:
|
|
873
|
-
colors_dict (dict): A dictionary where keys represent RGB color values as tuples,
|
|
874
|
-
and values represent the weights (floats) for each color.
|
|
875
|
-
|
|
876
|
-
## Returns:
|
|
877
|
-
tuple: The RGB values of the calculated weighted color as a tuple.
|
|
878
|
-
|
|
879
|
-
## Example:
|
|
880
|
-
colors_dict = {
|
|
881
|
-
|
|
882
|
-
(255, 255, 255): 0.1,
|
|
883
|
-
|
|
884
|
-
(0, 0, 0): 0.9,
|
|
885
|
-
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
weighted_color = weighted_color_fade(colors_dict)
|
|
889
|
-
|
|
890
|
-
print(f"Weighted color: RGB {weighted_color}")
|
|
891
|
-
|
|
892
|
-
This will print the weighted color based on the provided dictionary.
|
|
893
|
-
"""
|
|
894
|
-
...
|
|
895
|
-
|
|
896
|
-
def color_distance(starting_c: list|tuple, final_c: list|tuple, rooted:bool=True) -> float:
|
|
897
|
-
"""
|
|
898
|
-
# Calculate the distance between two colors in RGB space.
|
|
899
|
-
|
|
900
|
-
## Parameters:
|
|
901
|
-
starting_c (list or tuple): The RGB values of the starting color.
|
|
902
|
-
final_c (list or tuple): The RGB values of the final color.
|
|
903
|
-
rooted (bool, optional): If True, return the rooted distance. If False, return
|
|
904
|
-
the actual distance. Default is True.
|
|
905
|
-
|
|
906
|
-
## Returns:
|
|
907
|
-
float: The squared distance between the two colors if `rooted` is False, otherwise
|
|
908
|
-
the actual distance.
|
|
909
|
-
|
|
910
|
-
## Example:
|
|
911
|
-
starting_c = [255, 0, 0]
|
|
912
|
-
|
|
913
|
-
final_c = [0, 255, 0]
|
|
914
|
-
|
|
915
|
-
squared_distance = color_distance(starting_c, final_c)
|
|
916
|
-
|
|
917
|
-
print(f"Squared Distance: {squared_distance}")
|
|
918
|
-
|
|
919
|
-
distance = color_distance(starting_c, final_c, rooted=True)
|
|
920
|
-
|
|
921
|
-
print(f"Actual Distance: {distance}")
|
|
922
|
-
|
|
923
|
-
This will calculate the squared and actual distances between the colors.
|
|
924
|
-
|
|
925
|
-
## Explanation:
|
|
926
|
-
The function first calculates the squared distance between the two colors in RGB
|
|
927
|
-
space. It does this by computing the sum of the squared differences of the RGB
|
|
928
|
-
components for each color. The squared distance is obtained by taking the square
|
|
929
|
-
root of this sum.
|
|
930
|
-
|
|
931
|
-
The `rooted` parameter allows the user to choose between returning the squared
|
|
932
|
-
distance or the actual distance. If `rooted` is True, the function returns the
|
|
933
|
-
actual distance, and if `rooted` is False, it returns the squared distance.
|
|
934
|
-
"""
|
|
935
|
-
...
|
|
936
|
-
|
|
937
805
|
def angular_interpolation(starting_angle: int|float, final_angle: int|float, step: int|float=.1) -> float:
|
|
938
806
|
"""
|
|
939
807
|
# Perform angular interpolation between two angles using the shortest distance.
|
|
@@ -86,6 +86,22 @@ class Color:
|
|
|
86
86
|
def __init__(self, *values, mode:__LITERAL_COLOR_MODES__=RGB_COLOR_MODE) -> None:
|
|
87
87
|
self.__dict__ = dict(zip(mode, values))
|
|
88
88
|
self.mode :__LITERAL_COLOR_MODES__= mode
|
|
89
|
+
|
|
90
|
+
def lerp(self, other:"Color", step=.1) -> "Color":
|
|
91
|
+
return (self + (other - self).mult(step))
|
|
92
|
+
|
|
93
|
+
@staticmethod
|
|
94
|
+
def weighted_lerp(colors_dict:dict["Color", float]) -> "Color":
|
|
95
|
+
"""Colors HAVE to be in the rgb format."""
|
|
96
|
+
|
|
97
|
+
colors = colors_dict.keys()
|
|
98
|
+
weights = colors_dict.values()
|
|
99
|
+
if float("inf") in weights: return list(colors)[list(weights).index(float("inf"))]
|
|
100
|
+
return sum(n.mult(w) for n,w in zip(colors, weights)).div(sum(weights))
|
|
101
|
+
|
|
102
|
+
def distance_to(self, other:"Color", rooted=True) -> float:
|
|
103
|
+
d = sum((self.to_rgb() - other.to_rgb()).pow(2))
|
|
104
|
+
return (d ** .5) if rooted else d
|
|
89
105
|
|
|
90
106
|
@classmethod
|
|
91
107
|
def new_rgb(cls, r:int|float, g:int|float, b:int|float) -> "Color":
|
|
@@ -163,134 +179,107 @@ class Color:
|
|
|
163
179
|
return "Color(" + ", ".join(f"{k}:{v}" for k, v in self.items) + ")"
|
|
164
180
|
|
|
165
181
|
def __call__(self) -> __color_pygame__:
|
|
166
|
-
return __color_pygame__(
|
|
182
|
+
return __color_pygame__(int(self.r), int(self.g), int(self.b))
|
|
167
183
|
|
|
168
184
|
# fast operations Vector2D.operation(both,x,y)
|
|
169
185
|
def add(self, all3=.0, r=.0, g=.0, b=.0) -> "Color":
|
|
170
|
-
|
|
171
|
-
return Color(c_color.r + (r + all3), c_color.g + (g + all3), c_color.b + (b + all3)).to_mode(self.mode) # type: ignore
|
|
186
|
+
return Color(self.r + (r + all3), self.g + (g + all3), self.b + (b + all3))
|
|
172
187
|
|
|
173
188
|
def sub(self, all3=.0, r=.0, g=.0, b=.0) -> "Color":
|
|
174
|
-
|
|
175
|
-
return Color(c_color.r - (r + all3), c_color.g - (g + all3), c_color.b - (b + all3)).to_mode(self.mode) # type: ignore
|
|
189
|
+
return Color(self.r - (r + all3), self.g - (g + all3), self.b - (b + all3))
|
|
176
190
|
|
|
177
191
|
def mult(self, all3=1.0, r=1.0, g=1.0, b=1.0) -> "Color":
|
|
178
|
-
|
|
179
|
-
return Color(c_color.r * r * all3, c_color.g * g * all3, c_color.b * b * all3).to_mode(self.mode) # type: ignore
|
|
192
|
+
return Color(self.r * r * all3, self.g * g * all3, self.b * b * all3)
|
|
180
193
|
|
|
181
194
|
def pow(self, all3=1.0, r=1.0, g=1.0, b=1.0) -> "Color":
|
|
182
|
-
|
|
183
|
-
return Color(c_color.r ** (r + all3), c_color.g ** (g + all3), c_color.b ** (b + all3)).to_mode(self.mode) # type: ignore
|
|
195
|
+
return Color(self.r ** (r + all3), self.g ** (g + all3), self.b ** (b + all3))
|
|
184
196
|
|
|
185
197
|
def mod(self, all3=1.0, r=1.0, g=1.0, b=1.0) -> "Color":
|
|
186
|
-
|
|
187
|
-
return Color(c_color.r % (r + all3), c_color.g % (g + all3), c_color.b % (b + all3)).to_mode(self.mode) # type: ignore
|
|
198
|
+
return Color(self.r % (r + all3), self.g % (g + all3), self.b % (b + all3))
|
|
188
199
|
|
|
189
200
|
def div(self, all3=1.0, r=1.0, g=1.0, b=1.0) -> "Color":
|
|
190
|
-
|
|
191
|
-
return Color(c_color.r / r / all3, c_color.g / g / all3, c_color.b / b / all3).to_mode(self.mode) # type: ignore
|
|
201
|
+
return Color(self.r / r / all3, self.g / g / all3, self.b / b / all3)
|
|
192
202
|
|
|
193
203
|
def fdiv(self, all3=1.0, r=1.0, g=1.0, b=1.0) -> "Color":
|
|
194
|
-
|
|
195
|
-
return Color(c_color.r // r // all3, c_color.g // g // all3, c_color.b // b // all3).to_mode(self.mode) # type: ignore
|
|
204
|
+
return Color(self.r // r // all3, self.g // g // all3, self.b // b // all3)
|
|
196
205
|
|
|
197
206
|
# fast inplace operations Vector2D.ioperation(both,x,y)
|
|
198
|
-
def set(self,
|
|
199
|
-
self.
|
|
200
|
-
self.
|
|
207
|
+
def set(self, all3=.0, r=.0, g=.0, b=.0) -> "Color":
|
|
208
|
+
self.r = r + all3
|
|
209
|
+
self.g = g + all3
|
|
210
|
+
self.b = b + all3
|
|
201
211
|
return self
|
|
202
212
|
|
|
203
213
|
def iadd(self, all3=.0, r=.0, g=.0, b=.0) -> "Color":
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
c_color.b += b + all3 # type: ignore
|
|
208
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
214
|
+
self.r += r + all3
|
|
215
|
+
self.g += g + all3
|
|
216
|
+
self.b += b + all3
|
|
209
217
|
return self
|
|
210
218
|
|
|
211
219
|
def isub(self, all3=.0, r=.0, g=.0, b=.0) -> "Color":
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
c_color.b -= b + all3 # type: ignore
|
|
216
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
220
|
+
self.r -= r + all3
|
|
221
|
+
self.g -= g + all3
|
|
222
|
+
self.b -= b + all3
|
|
217
223
|
return self
|
|
218
224
|
|
|
219
225
|
def imult(self, all3=1.0, r=1.0, g=1.0, b=1.0) -> "Color":
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
c_color.b *= b * all3 # type: ignore
|
|
224
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
226
|
+
self.r *= r * all3
|
|
227
|
+
self.g *= g * all3
|
|
228
|
+
self.b *= b * all3
|
|
225
229
|
return self
|
|
226
230
|
|
|
227
231
|
def ipow(self, all3=1.0, r=1.0, g=1.0, b=1.0) -> "Color":
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
c_color.b **= b + all3 # type: ignore
|
|
232
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
232
|
+
self.r **= r + all3
|
|
233
|
+
self.g **= g + all3
|
|
234
|
+
self.b **= b + all3
|
|
233
235
|
return self
|
|
234
236
|
|
|
235
237
|
def imod(self, all3=1.0, r=1.0, g=1.0, b=1.0) -> "Color":
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
c_color.b %= b + all3 # type: ignore
|
|
240
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
238
|
+
self.r %= r + all3
|
|
239
|
+
self.g %= g + all3
|
|
240
|
+
self.b %= b + all3
|
|
241
241
|
return self
|
|
242
242
|
|
|
243
243
|
def idiv(self, all3=1.0, r=1.0, g=1.0, b=1.0) -> "Color":
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
c_color.b /= b * all3 # type: ignore
|
|
248
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
244
|
+
self.r /= r * all3
|
|
245
|
+
self.g /= g * all3
|
|
246
|
+
self.b /= b * all3
|
|
249
247
|
return self
|
|
250
248
|
|
|
251
249
|
def ifdiv(self, all3=1.0, r=1.0, g=1.0, b=1.0) -> "Color":
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
c_color.b //= b * all3 # type: ignore
|
|
256
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
250
|
+
self.r //= r * all3
|
|
251
|
+
self.g //= g * all3
|
|
252
|
+
self.b //= b * all3
|
|
257
253
|
return self
|
|
258
254
|
|
|
259
255
|
# normal operations Vector2D + a
|
|
260
256
|
def __add__(self, other) -> "Color":
|
|
261
257
|
other = Color.__normalize__(other)
|
|
262
|
-
|
|
263
|
-
return Color(c_color.r + other.r, c_color.g + other.g, c_color.b + other.b).to_mode(self.mode) # type: ignore
|
|
258
|
+
return Color(self.r + other.r, self.g + other.g, self.b + other.b)
|
|
264
259
|
|
|
265
260
|
def __sub__(self, other) -> "Color":
|
|
266
261
|
other = Color.__normalize__(other)
|
|
267
|
-
|
|
268
|
-
return Color(c_color.r - other.r, c_color.g - other.g, c_color.b - other.b).to_mode(self.mode) # type: ignore
|
|
262
|
+
return Color(self.r - other.r, self.g - other.g, self.b - other.b)
|
|
269
263
|
|
|
270
264
|
def __mul__(self, other) -> "Color":
|
|
271
265
|
other = Color.__normalize__(other)
|
|
272
|
-
|
|
273
|
-
return Color(c_color.r * other.r, c_color.g * other.g, c_color.b * other.b).to_mode(self.mode) # type: ignore
|
|
266
|
+
return Color(self.r * other.r, self.g * other.g, self.b * other.b)
|
|
274
267
|
|
|
275
268
|
def __mod__(self, other) -> "Color":
|
|
276
269
|
other = Color.__normalize__(other)
|
|
277
|
-
|
|
278
|
-
return Color(c_color.r % other.r, c_color.g % other.g, c_color.b % other.b).to_mode(self.mode) # type: ignore
|
|
270
|
+
return Color(self.r % other.r, self.g % other.g, self.b % other.b)
|
|
279
271
|
|
|
280
272
|
def __pow__(self, other) -> "Color":
|
|
281
273
|
other = Color.__normalize__(other)
|
|
282
|
-
|
|
283
|
-
return Color(c_color.r ** other.r, c_color.g ** other.g, c_color.b ** other.b).to_mode(self.mode) # type: ignore
|
|
274
|
+
return Color(self.r ** other.r, self.g ** other.g, self.b ** other.b)
|
|
284
275
|
|
|
285
276
|
def __truediv__(self, other) -> "Color":
|
|
286
277
|
other = Color.__normalize__(other)
|
|
287
|
-
|
|
288
|
-
return Color(c_color.r / other.r, c_color.g / other.g, c_color.b / other.b).to_mode(self.mode) # type: ignore
|
|
278
|
+
return Color(self.r / other.r, self.g / other.g, self.b / other.b)
|
|
289
279
|
|
|
290
280
|
def __floordiv__(self, other) -> "Color":
|
|
291
281
|
other = Color.__normalize__(other)
|
|
292
|
-
|
|
293
|
-
return Color(c_color.r // other.r, c_color.g // other.g, c_color.b // other.b).to_mode(self.mode) # type: ignore
|
|
282
|
+
return Color(self.r // other.r, self.g // other.g, self.b // other.b)
|
|
294
283
|
|
|
295
284
|
# right operations a + Vector2D
|
|
296
285
|
def __radd__(self, other) -> "Color":
|
|
@@ -298,128 +287,104 @@ class Color:
|
|
|
298
287
|
|
|
299
288
|
def __rsub__(self, other) -> "Color":
|
|
300
289
|
other = Color.__normalize__(other)
|
|
301
|
-
|
|
302
|
-
return Color(other.r - c_color.r, other.g - c_color.g, other.b - c_color.b).to_mode(self.mode) # type: ignore
|
|
290
|
+
return Color(other.r - self.r, other.g - self.g, other.b - self.b)
|
|
303
291
|
|
|
304
292
|
def __rmul__(self, other) -> "Color":
|
|
305
293
|
return self.__mul__(other)
|
|
306
294
|
|
|
307
295
|
def __rmod__(self, other) -> "Color":
|
|
308
296
|
other = Color.__normalize__(other)
|
|
309
|
-
|
|
310
|
-
return Color(other.r % c_color.r, other.g % c_color.g, other.b % c_color.b).to_mode(self.mode) # type: ignore
|
|
297
|
+
return Color(other.r % self.r, other.g % self.g, other.b % self.b)
|
|
311
298
|
|
|
312
299
|
def __rpow__(self, other) -> "Color":
|
|
313
300
|
other = Color.__normalize__(other)
|
|
314
|
-
|
|
315
|
-
return Color(other.r ** c_color.r, other.g ** c_color.g, other.b ** c_color.b).to_mode(self.mode) # type: ignore
|
|
301
|
+
return Color(other.r ** self.r, other.g ** self.g, other.b ** self.b)
|
|
316
302
|
|
|
317
303
|
def __rtruediv__(self, other) -> "Color":
|
|
318
304
|
other = Color.__normalize__(other)
|
|
319
|
-
|
|
320
|
-
return Color(other.r / c_color.r, other.g / c_color.g, other.b / c_color.b).to_mode(self.mode) # type: ignore
|
|
305
|
+
return Color(other.r / self.r, other.g / self.g, other.b / self.b)
|
|
321
306
|
|
|
322
307
|
def __rfloordiv__(self, other) -> "Color":
|
|
323
308
|
other = Color.__normalize__(other)
|
|
324
|
-
|
|
325
|
-
return Color(other.r // c_color.r, other.g // c_color.g, other.b // c_color.b).to_mode(self.mode) # type: ignore
|
|
309
|
+
return Color(other.r // self.r, other.g // self.g, other.b // self.b)
|
|
326
310
|
|
|
327
311
|
# in-place operations Vector2D += a
|
|
328
312
|
def __iadd__(self, other) -> "Color":
|
|
329
313
|
other = Color.__normalize__(other)
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
c_color.b += other.b # type: ignore
|
|
334
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
314
|
+
self.r += other.r
|
|
315
|
+
self.g += other.g
|
|
316
|
+
self.b += other.b
|
|
335
317
|
return self
|
|
336
318
|
|
|
337
319
|
def __isub__(self, other) -> "Color":
|
|
338
320
|
other = Color.__normalize__(other)
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
c_color.b -= other.b # type: ignore
|
|
343
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
321
|
+
self.r -= other.r
|
|
322
|
+
self.g -= other.g
|
|
323
|
+
self.b -= other.b
|
|
344
324
|
return self
|
|
345
325
|
|
|
346
326
|
def __imul__(self, other) -> "Color":
|
|
347
327
|
other = Color.__normalize__(other)
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
c_color.b *= other.b # type: ignore
|
|
352
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
328
|
+
self.r *= other.r
|
|
329
|
+
self.g *= other.g
|
|
330
|
+
self.b *= other.b
|
|
353
331
|
return self
|
|
354
332
|
|
|
355
333
|
def __itruediv__(self, other) -> "Color":
|
|
356
334
|
other = Color.__normalize__(other)
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
c_color.b **= other.b # type: ignore
|
|
361
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
335
|
+
self.r **= other.r
|
|
336
|
+
self.g **= other.g
|
|
337
|
+
self.b **= other.b
|
|
362
338
|
return self
|
|
363
339
|
|
|
364
340
|
def __imod__(self, other) -> "Color":
|
|
365
341
|
other = Color.__normalize__(other)
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
c_color.b %= other.b # type: ignore
|
|
370
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
342
|
+
self.r %= other.r
|
|
343
|
+
self.g %= other.g
|
|
344
|
+
self.b %= other.b
|
|
371
345
|
return self
|
|
372
346
|
|
|
373
347
|
def __ipow__(self, other) -> "Color":
|
|
374
348
|
other = Color.__normalize__(other)
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
c_color.b /= other.b # type: ignore
|
|
379
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
349
|
+
self.r /= other.r
|
|
350
|
+
self.g /= other.g
|
|
351
|
+
self.b /= other.b
|
|
380
352
|
return self
|
|
381
353
|
|
|
382
354
|
def __ifloordiv__(self, other) -> "Color":
|
|
383
355
|
other = Color.__normalize__(other)
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
c_color.b //= other.b # type: ignore
|
|
388
|
-
self.__dict__ = c_color.to_mode(self.mode).__dict__
|
|
356
|
+
self.r //= other.r
|
|
357
|
+
self.g //= other.g
|
|
358
|
+
self.b //= other.b
|
|
389
359
|
return self
|
|
390
360
|
|
|
391
361
|
# comparasion
|
|
392
362
|
def __eq__(self, other) -> bool:
|
|
393
363
|
try: other = Color.__normalize__(other)
|
|
394
364
|
except: return False
|
|
395
|
-
|
|
396
|
-
return c_color.r == other.r and c_color.g == other.g and c_color.b == other.b # type: ignore
|
|
365
|
+
return self.r == other.r and self.g == other.g and self.b == other.b
|
|
397
366
|
|
|
398
367
|
def __ne__(self, other) -> bool:
|
|
399
368
|
return not self.__eq__(other)
|
|
400
369
|
|
|
401
370
|
def __abs__(self) -> "Color":
|
|
402
|
-
|
|
403
|
-
return Color(abs(
|
|
371
|
+
self = self.to_rgb()
|
|
372
|
+
return Color(abs(self.r), abs(self.g), abs(self.b))
|
|
404
373
|
|
|
405
374
|
def __round__(self, n=1) -> "Color":
|
|
406
375
|
n = Color.__normalize__(n)
|
|
407
|
-
|
|
408
|
-
return Color(round(c_color.r / n.r) * n.r, round(c_color.g / n.g) * n.g, round(c_color.b / n.b) * n.b).to_mode(self.mode) # type: ignore
|
|
376
|
+
return Color(round(self.r / n.r) * n.r, round(self.g / n.g) * n.g, round(self.b / n.b) * n.b)
|
|
409
377
|
|
|
410
378
|
def __floor__(self, n=1) -> "Color":
|
|
411
379
|
n = Color.__normalize__(n)
|
|
412
|
-
|
|
413
|
-
return Color((c_color.r / n.r).__floor__() * n.r, (c_color.g / n.g).__floor__() * n.g, (c_color.b / n.b).__floor__() * n.b).to_mode(self.mode) # type: ignore
|
|
380
|
+
return Color((self.r / n.r).__floor__() * n.r, (self.g / n.g).__floor__() * n.g, (self.b / n.b).__floor__() * n.b)
|
|
414
381
|
|
|
415
382
|
def __ceil__(self, n=1) -> "Color":
|
|
416
383
|
n = Color.__normalize__(n)
|
|
417
|
-
|
|
418
|
-
return Color((c_color.r / n.r).__ceil__() * n.r, (c_color.g / n.g).__ceil__() * n.g, (c_color.b / n.b).__ceil__() * n.b).to_mode(self.mode) # type: ignore
|
|
384
|
+
return Color((self.r / n.r).__ceil__() * n.r, (self.g / n.g).__ceil__() * n.g, (self.b / n.b).__ceil__() * n.b)
|
|
419
385
|
|
|
420
386
|
def __float__(self) -> "Color":
|
|
421
|
-
|
|
422
|
-
return Color(float(c_color.r), float(c_color.g), float(c_color.b)).to_mode(self.mode) # type: ignore
|
|
387
|
+
return Color(float(self.r), float(self.g), float(self.b))
|
|
423
388
|
|
|
424
389
|
def __getitem__(self, n) -> int|float:
|
|
425
390
|
return self.values[n] if isinstance(n, int) else self.values[self.keys.index(n)]
|
|
@@ -432,6 +397,8 @@ class Color:
|
|
|
432
397
|
def __normalize__(cls, other) -> "Color":
|
|
433
398
|
if isinstance(other, Color):
|
|
434
399
|
return other
|
|
400
|
+
if isinstance(other, __color_pygame__):
|
|
401
|
+
return cls(*other[:], mode="rgba")
|
|
435
402
|
if isinstance(other, (int, float)):
|
|
436
403
|
return cls(other, other, other)
|
|
437
404
|
if isinstance(other, (list, tuple)):
|
|
@@ -459,8 +426,15 @@ class Color:
|
|
|
459
426
|
def randomize(cls) -> "Color":
|
|
460
427
|
return Color(__randint__(0,255), __randint__(0,255), __randint__(0,255))
|
|
461
428
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
429
|
+
|
|
430
|
+
WHITE_COLOR = Color.white()
|
|
431
|
+
BLACK_COLOR = Color.black()
|
|
432
|
+
RED_COLOR = Color.red()
|
|
433
|
+
GREEN_COLOR = Color.green()
|
|
434
|
+
BLUE_COLOR = Color.blue()
|
|
435
|
+
|
|
436
|
+
WHITE_COLOR_PYG = WHITE_COLOR()
|
|
437
|
+
BLACK_COLOR_PYG = BLACK_COLOR()
|
|
438
|
+
RED_COLOR_PYG = RED_COLOR()
|
|
439
|
+
GREEN_COLOR_PYG = GREEN_COLOR()
|
|
440
|
+
BLUE_COLOR_PYG = BLUE_COLOR()
|
|
@@ -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.19
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[metadata]
|
|
2
2
|
name = e2D
|
|
3
|
-
version = 1.4.
|
|
3
|
+
version = 1.4.19
|
|
4
4
|
author = Riccardo Mariani
|
|
5
5
|
author_email = ricomari2006@gmail.com
|
|
6
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!
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|