The objective: Create a slider that, when displaced from the center, increases-decreases the value of another variable at a rate proportional to the displacement.
So, I create a slider that automatically comes back to the center
Slider[Dynamic[var, {(var = #) &, (var = 0.) &}], {-1, 1}]
Now I want a second variable to be dynamically increased/decreased when var!=0.
My ideas are:
- insert in the previous dynamic, something that does the updating
- use an animator with its speed set by
var
whenvar!=0.
that updates the value
Problems with the above:
- How to control the speed of the updating given that I can't know for sure the intervals in which
val
will be updated, andUpdateIntervals
sets an upper bound? - How to make it work without it showing in the screen?
Any other alternatives are welcome (ideally I'd like an elegant solution).
Dynamic[y, {y=g[x]}]
I wasn't aware of. I thought the second argument was supposed to be a function and that they only made sense when the dynamic was "being set by a control". What does it do? $\endgroup$