All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sikuli.basics.AnimatorTimeBased Maven / Gradle / Ivy

There is a newer version: 2.0.5
Show newest version
/*
 * Copyright (c) 2010-2016, Sikuli.org, sikulix.com
 * Released under the MIT License.
 *
 */

package org.sikuli.basics;

public class AnimatorTimeBased implements Animator {

  private long _begin_time;
  private boolean _running;
  private AnimatorTimeValueFunction _func;

  public AnimatorTimeBased(AnimatorTimeValueFunction func) {
    _begin_time = -1;
    _running = true;
    _func = func;
  }

  @Override
  public float step() {
    if (_begin_time == -1) {
      _begin_time = System.currentTimeMillis();
      return _func.getValue(0);
    }

    long now = System.currentTimeMillis();
    long delta = now - _begin_time;
    float ret = _func.getValue(delta);
    _running = !_func.isEnd(delta);
    return ret;
  }

  @Override
  public boolean running() {
    return _running;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy