Skip to main content

move_toward

Function move_toward 

pub fn move_toward(from: f64, to: f64, delta: f64) -> f64
Expand description

Moves from toward to by the delta amount. Will not go past to.

Use a negative delta value to move away.

move_toward(5, 10, 4)    # Returns 9
move_toward(10, 5, 4)    # Returns 6
move_toward(5, 10, 9)    # Returns 10
move_toward(10, 5, -1.5) # Returns 11.5