melonJS
    Preparing search index...

    Function lerp

    • Linear interpolation between two scalar values. t = 0 returns a, t = 1 returns b. Values of t outside [0, 1] extrapolate — the result is NOT clamped.

      Don't use this for smooth follow at a fixed alpha per frame. x = lerp(x, target, 0.1) per frame converges 2× faster at 60 fps than at 30 fps — the visual feel changes with the frame rate. Use damp instead for frame-rate-independent smoothing.

      Parameters

      • a: number

        the value at t = 0

      • b: number

        the value at t = 1

      • t: number

        the interpolation parameter (typically 0..1, but not clamped)

      Returns number

      a + (b - a) * t

      math.lerp(0, 10, 0.5);  // 5
      math.lerp(0, 10, 1.5); // 15 (extrapolation past `b`)