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