API Reference › Math › Math.lerp
method

Math.lerp

Math.lerp(a, b, t) -> fixed

Linear interpolation: returns a when t is 0.0, b when t is 1.0, and a proportional blend in between — the exact value a + (b - a) * t. All three arguments are fixed and the result is fixed. It is the workhorse behind smooth motion: ease a camera toward a target, fade a value over time, or sample a gradient. Values of t outside 0..1 extrapolate past the endpoints.

Parameters

athe value returned at t = 0.0
bthe value returned at t = 1.0
tthe blend amount, normally 0.0..1.0

Example

program EaseCamera {
  var camera_x: fixed = 0.0
  var target_x: fixed = 100.0

  handler Follow phase Update {
    camera_x = Math.lerp(camera_x, target_x, 0.1)   # glides a tenth of the way each frame
  }
}
← All symbols