melonJS
    Preparing search index...

    Function lerpArray

    • Linearly interpolate a value from an array at the given position. The array is treated as evenly spaced samples along the 0–1 range.

      Parameters

      • values: number[]

        array of values to interpolate between

      • position: number

        position along the array (0.0–1.0). Values above 1.0 clamp to the last element. Values below 0.0 extrapolate before the first element.

      Returns number

      interpolated value

      // interpolate halfway through a curve
      math.lerpArray([0, 10, 20], 0.5); // returns 10
      math.lerpArray([1, 0], 0.75); // returns 0.25