Normand Briere
2018-07-01 655810d1c4e710e7c85772b8dde96772dbcf274b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package aurelienribon.tweenengine.paths;
 
import aurelienribon.tweenengine.TweenPath;
 
/**
 * @author Aurelien Ribon | http://www.aurelienribon.com/
 */
public class Linear implements TweenPath {
   @Override
   public float compute(float t, float[] points, int pointsCnt) {
       int segment = (int) Math.floor((pointsCnt-1) * t);
       segment = Math.max(segment, 0);
       segment = Math.min(segment, pointsCnt-2);
 
       t = t * (pointsCnt-1) - segment;
 
       return points[segment] + t * (points[segment+1] - points[segment]);
   }
}