Adam Cohen | 6c5891a | 2014-07-09 23:53:15 -0700 | [diff] [blame] | 1 | package com.android.launcher3; |
| 2 | |
| 3 | import android.animation.TimeInterpolator; |
| 4 | |
| 5 | public 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 | } |