Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
Jorim Jaggi | b10e33f | 2015-02-04 21:57:40 +0100 | [diff] [blame] | 17 | package com.android.server.policy; |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 18 | |
| 19 | import android.view.animation.Interpolator; |
| 20 | |
| 21 | public class LogDecelerateInterpolator implements Interpolator { |
| 22 | |
| 23 | private int mBase; |
| 24 | private int mDrift; |
| 25 | private final float mLogScale; |
| 26 | |
| 27 | public LogDecelerateInterpolator(int base, int drift) { |
| 28 | mBase = base; |
| 29 | mDrift = drift; |
| 30 | |
| 31 | mLogScale = 1f / computeLog(1, mBase, mDrift); |
| 32 | } |
| 33 | |
| 34 | private static float computeLog(float t, int base, int drift) { |
| 35 | return (float) -Math.pow(base, -t) + 1 + (drift * t); |
| 36 | } |
| 37 | |
| 38 | @Override |
| 39 | public float getInterpolation(float t) { |
| 40 | return computeLog(t, mBase, mDrift) * mLogScale; |
| 41 | } |
| 42 | } |