ixfx
    Preparing search index...

    Function spring

    • Produces values according to rough spring physics.

      import { continuously } from "https://unpkg.com/ixfx/dist/flow.js"
      import { spring } from "https://unpkg.com/ixfx/dist/modulation.js"

      const s = spring();

      continuously(() => {
      const result = s.next();
      if (result.done) return false; // Exit loop
      const value = result.value;
      // Value is mostly within 0..1 range but will exceed these limits
      }, 10).start();

      Parameters to the spring can be provided.

      import { spring } from "https://unpkg.com/ixfx/dist/modulation.js"
      const s = spring({
      mass: 5,
      damping: 10
      stiffness: 100
      });

      If you don't want to use a generator: springValue.

      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.

      Parameters

      • opts: Partial = {}

        Options for spring

      • OptionaltimerOrFreq: number | Timer

        Timer to use, or frequency

      Returns Generator<number, void, unknown>