1
$\begingroup$

Can I get Manipulateto allow me, once the plot appears, to hover my mouse over the plot and scroll my mouse wheel to vary the parameter $a$? Currently I need to drag the bar manually.

Manipulate[Plot[Sin[x (1 + a x)], {x, 0, 6}], {a, 0, 2}]

enter image description here

I'm looking to use it for loading chess game .gif files i.e. to create a notebook of opening variations, so I need lots of mouse over access to many animations to explore openings quickly.

$\endgroup$
4
  • $\begingroup$ Last time I looked into this, it didn't really seem possible (not even with some very desperate hacky attempts). Things might have changed of course, or I could have missed something, but I wouldn't be surprised if what you want is still not feasible $\endgroup$
    – Lukas Lang
    Commented May 12 at 18:04
  • $\begingroup$ Is there a way of controlling it with the keyboard? $\endgroup$
    – apg
    Commented May 12 at 18:31
  • 1
    $\begingroup$ this approach may not be desperate, though I think that if it's possible it's very hacky and don't worth to try. (I use it for a similar problem) $\endgroup$
    – andre314
    Commented May 12 at 18:32
  • $\begingroup$ Will try this now, thanks! $\endgroup$
    – apg
    Commented May 12 at 19:39

1 Answer 1

1
$\begingroup$

Using the hack suggested by @andre314, you can use

DynamicModule[{x = {0.1, 0.}, a = 1}, 
 Pane[Pane[Dynamic[Plot[Sin[x  (1 + a  x)], {x, 0, 7}], {x, 0, 6}], 
   ImageSize -> {Full, 1100}, AppearanceElements -> None, 
   Scrollbars -> None], ImageSize -> {Full, 1000}, 
  AppearanceElements -> None  Scrollbars -> {False, True}, 
  ScrollPosition -> Dynamic[x, Function[If[#[[2]] >= x[[2]], a--, a++];
     x[[2]] = Mod[x[[2]] + 0.001, 0.1, 0.1];]]]]

which can produce different curves on mouse scrolling

enter image description here

(a few mouse scrolls...)

enter image description here

and for the chess example, save e.g. this chess gif as chessgame.gif, then try

frames = Import["chessgame.gif"];
(*This gives periodic boundary conditions to the scrolling*)
cycle[a_, frames_] := 
  Module[{}, 
   If[Mod[a, Length@frames] > 0, 
    out = frames[[Mod[a, Length@frames]]]]; 
   If[Mod[a, Length@frames] == 0, 
    out = frames[[Mod[a, Length@frames] + 1]]]; out];
(*This gives the animation itself*)
DynamicModule[{x = {0.1, 0.}, a = 1}, 
 Pane[Pane[Dynamic[cycle[a, frames]], ImageSize -> {Full, 1100}, 
   AppearanceElements -> None, Scrollbars -> None], 
  ImageSize -> {Full, 1000}, 
  AppearanceElements -> None  Scrollbars -> {False, True}, 
  ScrollPosition -> Dynamic[x, Function[If[#[[2]] >= x[[2]], a--, a++];
     x[[2]] = Mod[x[[2]] + 0.001, 0.1, 0.1];]]]]

which gives a scrolling chess animation

enter image description here

(a few mouse scrolls...)

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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