1 | initial version |
Sage 9.3 allows to save a collection of 3d frames as an interactive 3d animated scene.
The result is 3d, has a play/pause button, one navigate the scene both in time (frame by frame or using a play/pause button, playing it once or in a loop), and in space with ways to zoom in and out, rotate, translate the view.
The space navigation can be done while the animation is paused or while it is playing.
After you have produced the collection of 3d scenes with
num_frames_graph = 100
frames_list_graph = [0]*10
frames_list_graph.extend(list(range(num_frames_graph)))
frames_list_graph.extend([num_frames_graph for i in range(15)])
frames_list_graph.extend(frames_list_graph[::-1])
graph_frames = [graph_projection(RDF(time / num_frames_graph))
for time in frames_list_graph]
the animation can be constructed as:
animation = animate(frames).interactive()
and then rendered with
animation
or
animation.show()
or saved as html with
animation.save('graph.html')
Returning to the question as asked: to remove the excess whitespace around each frame of your animation, you would either need to adjust the xmin, xmax, ymin, ymax that are used to save each frame as png, or to trim margins after the fact on the obtained png before turning them into an animated gif.
This illustrate the latter option:
os.system('mkdir graphFrames')
for i, frame in enumerate(graph_frames):
frame.save(filename='graphFrames/graph%04d.png' % i,
figsize=[12, 8],
dpi=1000,
xmin=-2.1,
xmax=2.1,
ymin=-2.1,
ymax=2.1,
zmin=-2.1,
zmax=2.1,
transparent=True,
aspect_ratio=1,
)
os.system('cd graphFrames; '
'mogrify -trim graph*.png; '
f'convert -delay {float(100/60)} -loop {int(0)} graph*.png "graph.gif"')