Skip to content

Commit 3fea596

Browse files
Add compatibility with recent PIL and fixed openning issue
- Change Image.ANTIALIAS to Image.Resampling.LANCZOS - Now plots open correctly in a python console (plt.ion + plt.pause)
1 parent 9528035 commit 3fea596

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

black_hole.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
@author: Jonathan Peltier
66
7-
GitHub deposit:
7+
GitHub repository:
88
https://github.com/Python-simulation/Black-hole-simulation-using-python/
99
1010
BlackHole class solving photons trajectories closed to a static black hole.
@@ -41,6 +41,7 @@ class BlackHole:
4141
def __init__(self):
4242
"""Main class"""
4343
self.init_var()
44+
plt.ion()
4445

4546
try:
4647
abs_path = os.path.abspath(os.path.dirname(sys.argv[0]))
@@ -164,7 +165,7 @@ def img_resize(self, axe_X):
164165
if axe_Y % 2 != 0:
165166
axe_Y -= 1
166167

167-
self.img_debut = self.img_debut.resize((axe_X, axe_Y), Image.ANTIALIAS)
168+
self.img_debut = self.img_debut.resize((axe_X, axe_Y), Image.Resampling.LANCZOS)
168169
self.FOV_img_Y = self.FOV_img * axe_Y / axe_X
169170

170171
if self.FOV_img_Y > 180:
@@ -631,6 +632,8 @@ def draw(self):
631632
self.ax.set_ylim((down_side, up_side))
632633
# print((self.left_side, self.right_side), (self.down_side, self.up_side))
633634
self.fig.canvas.draw()
635+
plt.draw()
636+
plt.pause(0.001)
634637

635638
def onclick(self, event):
636639
"""Use to apply an offset when right clicking. Will be replace by a

0 commit comments

Comments
 (0)