Added Displayer::save_frames()
This commit is contained in:
parent
18aa441f82
commit
2ed95e235b
@ -44,7 +44,7 @@ class Displayer:
|
||||
self._objects.append(self._circle_map[obj_name])
|
||||
|
||||
|
||||
# Functions to be used in the animation callback
|
||||
# Functions to be used in the callback
|
||||
|
||||
|
||||
def move_object(self, obj_name, position):
|
||||
@ -63,7 +63,7 @@ class Displayer:
|
||||
self._circle_map[obj_name].set_alpha(1)
|
||||
|
||||
|
||||
# Start the animation
|
||||
# Display functions
|
||||
|
||||
|
||||
def animate(self, n_steps, anim_callback):
|
||||
@ -78,4 +78,16 @@ class Displayer:
|
||||
interval=self._frame_interval,
|
||||
init_func=self.__init_animation,
|
||||
blit=False)
|
||||
plt.show()
|
||||
plt.show()
|
||||
|
||||
|
||||
def save_frames(self, frames, callback, prefix="fig-", ext="png"):
|
||||
n_steps = max(frames) + 1
|
||||
|
||||
self.__init_animation()
|
||||
|
||||
for t in range(1, n_steps):
|
||||
callback(self, t)
|
||||
|
||||
if t in frames:
|
||||
self._fig.savefig(prefix + str(t) + "." + ext)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user