Returns a function that interpolates from A to B.
It steps through the interpolation with each call to the returned function.
This means that the incrementAmount will hinge on the rate
at which the function is called. Alternatively, consider interpolatorInterval
which steps on the basis of clock time.
// Interpolate from 0..1 by 0.01 constv = interpolatorStepped(0.01, 100, 200); v(); // Each call returns a value closer to target // Eg: 100, 110, 120, 130 ...
Under the hood, it calls interpolate with an amount that
increases by incrementAmount each time.
When calling v() to step the interpolator, you can also pass
in new B and A values. Note that the order is swapped: the B (target) is provided first, and
then optionally A.
constv = interpolatorStepped(0.1, 100, 200); // Interpolate 100->200 v(300, 200); // Retarget to 200->300 and return result v(150); // Retarget 200->150 and return result
This allows you to maintain the current interpolation progress.
Returns a function that interpolates from A to B. It steps through the interpolation with each call to the returned function. This means that the
incrementAmount
will hinge on the rate at which the function is called. Alternatively, consider interpolatorInterval which steps on the basis of clock time.Under the hood, it calls
interpolate
with an amount that increases byincrementAmount
each time.When calling
v()
to step the interpolator, you can also pass in new B and A values. Note that the order is swapped: the B (target) is provided first, and then optionally A.This allows you to maintain the current interpolation progress.