Skip to content

Commit 233b5ac

Browse files
committed
back_and_forth
1 parent a1a650a commit 233b5ac

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

WrightTools/artists/_animate.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ def updater(frame):
111111
fig.canvas.draw_idle()
112112
return art
113113

114+
# generate frame sequence
114115
frames = list(np.ndindex(data.shape[:-2]))
116+
if back_and_forth:
117+
frames += reversed(frames)
118+
115119
return FuncAnimation(
116120
fig=fig,
117121
func=updater,
@@ -139,6 +143,9 @@ def update(frame):
139143
slider.set_val(ind)
140144

141145
frames = list(np.ndindex(tuple([s.valmax + 1 for s in interact2D.sliders.values()])))
146+
if back_and_forth:
147+
frames += reversed(frames)
148+
142149
return FuncAnimation(
143150
fig=interact2D.fig,
144151
func=update,

tests/artists/test_animate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_animate2D():
1515
from matplotlib.colors import CenteredNorm
1616
from functools import partial
1717

18-
ani = wt.artists.animate2D(d, interval=100, norm=partial(CenteredNorm, vcenter=0))
18+
ani = wt.artists.animate2D(d, interval=50, back_and_forth=True, norm=partial(CenteredNorm, vcenter=0))
1919
return ani
2020

2121

0 commit comments

Comments
 (0)