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