AutoRand animating a controller with randomsteps.
Inherits from: Object
See also: AutoLoop
Creation / Class Methods
*new (ctl, spec, rd, exp, dt)
make an AutoRand
ctl - the controller to randomize. e.g. an NumberBox, or EZSlider etc.
spec - its controlSpec,
rd - the normalized random offset (between 0 and 1) by which to mutate.
exp - the exponent for the random distribution:
1 is linear distribution,
2 is quadratically nearer the previous value
dt - a number, function or stream for the wait time between random moves.
(
w = Window("autorand").front; w.addFlowLayout;
e = EZSlider(w, 300@20, \freq, \freq); // the controller to randomize
a = AutoRand(e, e.controlSpec,
rd: 0.2, // normalized variation is 0.2
exp: 1, // distrib is linear
dt: 0.5 // every half second
); // the autorand:
a.makeButton(w, Rect(0,0,20,20));
)
Accessing Instance and Class Variables
ctl the control to be randomly animated
tpx the taskproxy doing the random jumps
spec the controlspec by which to unmap
rd_(val) set the maximum random jump value, between 0 and 1
rd get the maximum random jump value
a.rd_(1.0);
exp_(val) set the exponent for the distribution shape : 1 is lin, 2 is quadratic etc.
exp set the exponent for the distribution shape
a.exp_(3); // higher exponents mean: prefer smaller jumps, big ones rarely
dt_(val) set the function or value for the wait time between random moves.
dt
instance methods:
play
a.play;
stop
a.stop;
makeButton (parent, bounds)
Put a stop/start button on a parent view or window
parent - the parent view (window or compositeview)
bounds - a rect with the button size.