pub fn smooth_move(destination: Point, duration: Option<f64>) -> Result<(), MouseError> {
    if !screen::is_point_visible(destination) {
        return Err(MouseError::OutOfBounds);
    }

    let start_position = location();
    let distance = (start_position.x - destination.x).hypot(start_position.y - destination.y);
    let step_count = distance.ceil() as i64;
    let interval: u64 = duration
        .map(|d| (d * 1000.0) / distance)
        .unwrap_or(1.0)
        .round() as u64;

    for step in 1..step_count + 1 {
        let position = Point::new(
            (destination.x - start_position.x) * (step as f64 / step_count as f64)
                + start_position.x,
            (destination.y - start_position.y) * (step as f64 / step_count as f64)
                + start_position.y,
        );

        try!(move_to(position));
        std::thread::sleep(std::time::Duration::from_millis(interval));
    }

    Ok(())
}
/// Gradually moves the mouse to a coordinate in a straight line in the given
/// time frame (in seconds). If no duration is given a 1 millisecond delay is
/// defaulted to between mouse movements.
///
/// Returns `MouseError` if coordinate is outside the screen boundaries.
Gradually moves the mouse to a coordinate in a straight line in the given
time frame (in seconds). If no duration is given a 1 millisecond delay is
defaulted to between mouse movements.

Returns `MouseError` if coordinate is outside the screen boundaries.
Gradually moves the mouse to a coordinate in a straight line in the given time frame ( in seconds ) . If no duration is given a 1 millisecond delay is defaulted to between mouse movements . Returns ` MouseError ` if coordinate is outside the screen boundaries .
pub fn smooth_move(destination: Point, duration: Option<f64>) -> Result<(), MouseError> {
    if !screen::is_point_visible(destination) {
        return Err(MouseError::OutOfBounds);
    }
    let start_position = location();
    let distance = (start_position.x - destination.x).hypot(start_position.y - destination.y);
    let step_count = distance.ceil() as i64;
    let interval: u64 = duration
        .map(|d| (d * 1000.0) / distance)
        .unwrap_or(1.0)
        .round() as u64;
    for step in 1..step_count + 1 {
        let position = Point::new(
            (destination.x - start_position.x) * (step as f64 / step_count as f64)
                + start_position.x,
            (destination.y - start_position.y) * (step as f64 / step_count as f64)
                + start_position.y,
        );
        try!(move_to(position));
        std::thread::sleep(std::time::Duration::from_millis(interval));
    }
    Ok(())
}
pub fn smooth_move ( destination : Point , duration : Option < f64 > ) -> Result < ( ) , MouseError > { if ! screen :: is_point_visible ( destination ) { return Err ( MouseError :: OutOfBounds ) ; } let start_position = location ( ) ; let distance = ( start_position . x - destination . x ) . hypot ( start_position . y - destination . y ) ; let step_count = distance . ceil ( ) as i64 ; let interval : u64 = duration . map ( | d | ( d * 1000.0 ) / distance ) . unwrap_or ( 1.0 ) . round ( ) as u64 ; for step in 1 .. step_count + 1 { let position = Point :: new ( ( destination . x - start_position . x ) * ( step as f64 / step_count as f64 ) + start_position . x , ( destination . y - start_position . y ) * ( step as f64 / step_count as f64 ) + start_position . y , ) ; try ! ( move_to ( position ) ) ; std :: thread :: sleep ( std :: time :: Duration :: from_millis ( interval ) ) ; } Ok ( ( ) ) }
Gradually moves the mouse to a coordinate in a straight line in the given
time frame (in seconds).
Gradually moves the mouse to a coordinate in a straight line in the given time frame ( in seconds ) .
destination
Point
duration
Option<f64>
destination
Point
duration
Option<f64>