1/* 2 * Copyright (C) 2015 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 17package android.support.design.widget; 18 19import android.support.v4.view.animation.FastOutLinearInInterpolator; 20import android.support.v4.view.animation.FastOutSlowInInterpolator; 21import android.support.v4.view.animation.LinearOutSlowInInterpolator; 22import android.view.animation.DecelerateInterpolator; 23import android.view.animation.Interpolator; 24import android.view.animation.LinearInterpolator; 25 26class AnimationUtils { 27 28 static final Interpolator LINEAR_INTERPOLATOR = new LinearInterpolator(); 29 static final Interpolator FAST_OUT_SLOW_IN_INTERPOLATOR = new FastOutSlowInInterpolator(); 30 static final Interpolator FAST_OUT_LINEAR_IN_INTERPOLATOR = new FastOutLinearInInterpolator(); 31 static final Interpolator LINEAR_OUT_SLOW_IN_INTERPOLATOR = new LinearOutSlowInInterpolator(); 32 static final Interpolator DECELERATE_INTERPOLATOR = new DecelerateInterpolator(); 33 34 /** 35 * Linear interpolation between {@code startValue} and {@code endValue} by {@code fraction}. 36 */ 37 static float lerp(float startValue, float endValue, float fraction) { 38 return startValue + (fraction * (endValue - startValue)); 39 } 40 41 static int lerp(int startValue, int endValue, float fraction) { 42 return startValue + Math.round(fraction * (endValue - startValue)); 43 } 44 45} 46