Optional
timerOrFreq: number | Timerimport { Modulation, Data } from "https://unpkg.com/ixfx/dist/bundle.js"
let state = {
spring: Modulation.springValue()
}
function loop() {
const d = Data.resolveFields(state);
// Apply calculated spring value to compute x value
const x = window.innerWidth * d.spring;
window.requestAnimationFrame(loop);
}
loop();
Note that the generated value can exceed 0..1 range. This is by design, since a spring can 'overshoot'. See Data.Normalise for functions to normalise.
The same as spring but instead of a generator we get a value. When the spring is done, 1 is returned instead of undefined.
Options can be provided: