blob: ed5dc6fa7a510835edfe04389950f91bfb488e84 [file] [log] [blame]
Jorim Jaggi76a16232014-08-08 17:00:47 +02001/*
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 Jaggib10e33f2015-02-04 21:57:40 +010017package com.android.server.policy;
Jorim Jaggi76a16232014-08-08 17:00:47 +020018
19import android.view.animation.Interpolator;
20
21public 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}