Skip to main content

lerp

Function lerp 

pub fn lerp(from: &Variant, to: &Variant, weight: &Variant) -> Variant
Expand description

Linearly interpolates between two values by the factor defined in weight. To perform interpolation, weight should be between 0.0 and 1.0 (inclusive). However, values outside this range are allowed and can be used to perform extrapolation. If this is not desired, use [method clampf] to limit weight.

Both from and to must be the same type. Supported types: int, float, Vector2, Vector3, Vector4, Color, Quaternion, Basis, Transform2D, Transform3D.

lerp(0, 4, 0.75) # Returns 3.0

See also [method inverse_lerp] which performs the reverse of this operation. To perform eased interpolation with [method lerp], combine it with [method ease] or [method smoothstep]. See also [method remap] to map a continuous series of values to another.

Note: For better type safety, use [method lerpf], lerp, lerp, lerp, lerp, slerp, slerp, interpolate_with, or interpolate_with.