blob: 4c5f6f08c4e25e5f19e9bb01b3c49a9d56ca8557 [file] [log] [blame]
Adam Cohen6c5891a2014-07-09 23:53:15 -07001package com.android.launcher3;
2
3import android.animation.TimeInterpolator;
4
5public class LogDecelerateInterpolator implements TimeInterpolator {
6
7 int mBase;
8 int mDrift;
9 final float mLogScale;
10
11 public LogDecelerateInterpolator(int base, int drift) {
12 mBase = base;
13 mDrift = drift;
14
15 mLogScale = 1f / computeLog(1, mBase, mDrift);
16 }
17
18 static float computeLog(float t, int base, int drift) {
19 return (float) -Math.pow(base, -t) + 1 + (drift * t);
20 }
21
22 @Override
23 public float getInterpolation(float t) {
24 return computeLog(t, mBase, mDrift) * mLogScale;
25 }
26}