Advanced
interpolate has a few different ways of being used
The options for the interpolate function can be left out. It has a single property, limits
which determines how to behave if interpolation amount exceeds 0..1.
- ‘clamp’: clamp returned value to within A & B (inclusive). This is the default.
- ‘wrap’: value wraps from end to start
- ‘ignore’: allow return values which exceed A & B.
For example:
Interpolators
The interpolators Numbers.interpolatorInterval and Numbers.interpolatorStepped use the same options as Numbers.interpolate .
This allows us to use an easing curve for non-linear interpolation, determine what to do if interpolation range is breached and provide a custom transform function. For more: Type Numbers.InterpolateOptions
Re-targeting
The interpolators both return a function to compute the interpolated value. We can use this to re-target the interpolation, allowing A and/or B points to be adjusted from their initial values.
Note:
- Order of parameters is ‘B, A’; the opposite when creating. This is because it’s more common to want to only adjust the target value.
- The change internally mutates the interpolator. Subsequent calls to the function make use of the changed A & B values.