0
$\begingroup$

I'm trying to animate a large Graphics output, and it is returning $Aborted. I'm confused because when I use Dynamic and Slider, the graphics output is exactly what I want, i.e., I can 'animate' the graphic manually through Dynamic.

Here's what I'm doing:

I have two large Graphics, called graphic, which are identical and one is being translated over the other. Here is how I'm 'dynamically' translating the graphics, and it works great despite the massive graphics size, almost no delay.

{Slider[Dynamic[x]], Dynamic[x]}
{Slider[Dynamic[y]], Dynamic[y]}
Show[{Graphics[{EdgeForm[Black], graphic}, 
   PlotRange -> {{-2, 2}, {-2, 2}}], 
  Graphics[Translate[{Opacity[0.3], EdgeForm[Gray], graphic}, 
    Dynamic[{x, y}]]]}]

Here is what the output looks like after I slide the 'x' slider:

enter image description here

What I want to do, though, is animate this translation. For example, I want to slide it along, {x,0,2,0.1} "Slide it in the x direction from 0 to 2 with stepsize 0.1" and animate the output. Since the Dynamic worked so well, I thought I could simply replace this with an Animate wrapper:

Animate[Show[{Graphics[{EdgeForm[Black], graphic}, 
    PlotRange -> {{-2, 2}, {-2, 2}}], 
   Graphics[
    Translate[{Opacity[0.3], EdgeForm[Gray], graphic}, {t, 0}]]}], {t,
   0.5, 1, 0.1}]

However, this does not work, and Aborts.

Is there a way for me to Animate this object in a way that's similar to how Mathematica handles the Dynamic output? Also worth noting, probably, when I try to wrap this in a Manipulate, I also get an Abort, so Dynamic has been the only way this is working for me.

Also, I don't know if this matters, the graphic is composed of many Polygons. I don't know if there is a more efficient way of implementing this translation dynamic either, because the graphic itself isn't changing, only the position.

$\endgroup$
  • 1
    $\begingroup$ Try {Manipulator[Dynamic[t], {0.5, 1, 0.1}], Dynamic[t]} $\endgroup$ – Algohi Mar 7 '15 at 4:44
  • $\begingroup$ @Algohi I already have it working with a Dynamic Slider. My goal is to try and output a .gif of an animation. Would Manipulator help with that? $\endgroup$ – Jesse Mar 7 '15 at 23:32
  • 1
    $\begingroup$ @Nasser I don't know what you mean? Do you want to see the code that generates the graphic? $\endgroup$ – Jesse Mar 7 '15 at 23:33
2
$\begingroup$

Slider does not allow play button but Manipulator does.

This is an example and I don't know if it fits you need.

Grid[{{Manipulator[Dynamic[x]], Dynamic[x]},
  {Manipulator[Dynamic[y]], Dynamic[y]},
  {Show[{Graphics[{EdgeForm[Black], Dynamic@Circle[{x, y}, 1]}, 
      PlotRange -> {{-2, 2}, {-2, 2}}], 
     Graphics[
      Translate[{Opacity[0.3], EdgeForm[Gray], 
        Dynamic@Circle[{x, y}, 1]}, Dynamic[{x, y}]]]}]}}]

enter image description here

$\endgroup$
  • $\begingroup$ Okay, I'll try using Manipulator. Will I be able to output the animation from the play button as a gif? $\endgroup$ – Jesse Mar 7 '15 at 23:59
  • $\begingroup$ Yes you can. check this: mathematica.stackexchange.com/questions/27202/… $\endgroup$ – Algohi Mar 8 '15 at 0:04
  • $\begingroup$ Thanks for these suggestions. I've tried the Manipulator as you suggested, with slightly better results. You were right, now I can press the play button and somewhat get an animation. However, the animation doesn't correspond exactly to the manipulator. I guess the lag in the Dynamic updating is slower than the Manipulator cycling through the values. As a result, the 'animation' doesn't show every option from the Manipulator. However, it doesn't Abort, which is better. Do you have any ideas why Animate wouldn't work? $\endgroup$ – Jesse Mar 8 '15 at 0:15
  • $\begingroup$ @Jesse Animate and Manipulate has a sophisticated way of evaluating the arguments. there are a lot of issue about them like this: mathematica.stackexchange.com/questions/75380/… $\endgroup$ – Algohi Mar 8 '15 at 2:57
  • $\begingroup$ Hm, is there anyway to use Dynamic to make a table of the figures and then combine that into a gif? I tried to create a Table, but it took way too long to generate the new image each time, but using Dynamic obviously allows me to do almost instantly. Is there any way to apply the quickness of Dynamic to generating the tables, considering that Animate and Manipulate aren't working for me? $\endgroup$ – Jesse Mar 8 '15 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.