Question: Attempt to create an animation zooming in on axis

I want to apologize if this being neither necessarily a minimal working example for one question nor just one question is uncomfortable. The "MWE" was created on and is designed for Linux machines including ImageMagick. The problem itself should be obvious to all users though, as the subfolder and creation of the gif are just conveniences. I have three sections concerning the different problems occuring in my attempts.

(which I was told is not doable in maple ... hence the gif)

link

The goal was to create an animation that zooms in on a function. As maple just wouldn't allow scaling of axis in animations I decided to export single frames and then convert those with ImageMagick. Maple offers ssystem(„...“) which allows for command line usage.

The problem (may as well be a bug) occurs when I try to export images in a for loop with exportplot(...). If the path as well as previously exported images exist, it won't output an error but still not export the desired images. Exporting frames separately works just fine, as well as doing the very same operation in a separate for loop.

(see the first red comment and export section)

After using the workaround in a second for loop. I couldn't figure out how to import the images and then create an animation from them. The main obstacle is the fact that the imported pictures are put into plot-functions.

(see the second red comment)

 

restart;

with(plottools):

f1 := s -> sin(2*s):

max_frame := 10: # = number of steps

for k from 0 to max_frame do
    pic[k] := plot(f1(x), x=-Pi*(1-k/max_frame)..Pi*(1-k/max_frame),
                    filled=true, #color = ["Orange"],
                    color = ColorTools:-Color([0,
                                              floor(128*k/max_frame),
                                              floor(255*k/max_frame)
                                              ]),
                    view=[-Pi*(1-k/max_frame)..Pi*(1-k/max_frame), -1..1]
                    ):
end do:

path := FileTools:-TemporaryDirectory();
path_list := ssystem("pwd");
path := path_list[2];
ssystem("mkdir ./pics"); # creates a subfolder
path := FileTools:-JoinPath([path, "pics"]); # need to change path to subfolder

plotsetup(window, plotoptions="width=480, height=600");
for k from 0 to max_frame do
    file[k] := FileTools:-JoinPath([path,
                                     MapleTA:-Builtin:-strcat("frame_",
                                                              convert(k, string),
                                                              ".jpg")
                                    ]);
    # exportplot(file[k], pic[k]); # does not work
end do:

exportplot(file[0], pic[0]); # works

# =====================================================================================
# export
# =====================================================================================
for k from 0 to max_frame do
  exportplot(file[k], pic[k]);
od; # also works

# =====================================================================================
# import
# =====================================================================================
for k from 0 to max_frame do
    reimported_pic[k] := importplot(file[k]); # this might take a while (depending on the amount of frames)
end do: # import works but [Length of output exceeds limit of 1000000]

whattype(reimported_pic[0]); #seems to create a plot function
show := convert(reimported_pic,list):
#Error, while processing result #There is no help page available for this error

show[1]; # works

# =====================================================================================
# create an animated gif at least
# =====================================================================================
delay_time := ceil(evalf(100/max_frame));
command_for_gif := MapleTA:-Builtin:-strcat("convert -delay ",
                                            convert(delay_time, string),
                                            " -loop 0 ", # -reverse ",
                                            FileTools:-JoinPath([path, "frame_*.jpg "]),
                                            FileTools:-JoinPath([path, "animation.gif"])
                                            );
ssystem(command_for_gif);

 

 

Download bug_report_maybe.mw

 

I would be grateful for any suggestions. Moreover I have run accross

?DocumentTools:-Components:-VideoPlayer

which I could not figure out how to use by the help pages (I tried to create an avi and import that). If someone has informations on that, please share!

Please Wait...