AccelerateInterpolator

AccelerateInterpolator的源码如下:

package android.view.animation;

public class AccelerateInterpolator extends BaseInterpolator {

    private final float mFactor;
    private final double mDoubleFactor;

    public AccelerateInterpolator() {
        mFactor = 1.0f;
        mDoubleFactor = 2.0;
    }

    public AccelerateInterpolator(float factor) {
        mFactor = factor;
        mDoubleFactor = 2 * mFactor;
    }

    public float getInterpolation(float input) {
        if (mFactor == 1.0f) {
            return input * input;
        } else {
            return (float)Math.pow(input, mDoubleFactor);
        }
    }
}

float getInterpolation(float input)的实现,可以知道,这个可以用数学函数表达为y=x^n,x∈[0,1],n∈[-∞,+∞],n是常数

Matlab的命令窗口中输入如下命令:

grid on;
x = linspace(0,1,100);

plot(x,x.^2);
text(0.5,0.3,'y=x^2');
hold on;

plot(x,x.^4);
text(0.7,0.3,'y=x^4');
hold on;

plot(x,x.^8);
text(0.85,0.3,'y=x^8')

得到下面的曲线图:

Matlab的命令窗口中输入如下命令:

grid on;
x = linspace(0,1,100);

plot(x,x.^0.2);
text(0.4,0.5,'y=pow(x,0.2)');
hold on;

plot(x,x.^0.4);
text(0.4,0.7,'y=pow(x,0.4)');
hold on;

plot(x,x.^0.8);
text(0.4,0.85,'y=pow(x,0.8)')

得到下面的曲线图:

从上面的函数图可以看出,当AccelerateInterpolator构造方法传入的参数大于0.5的时候,才是加速的,否则就不是加速的。