如何申请缓动动画功能上的视图机器人视图、机器人、功能、动画

2023-09-05 10:11:17 作者:可爱不是外表而是内心

我要应聘翻译动画在Android 视图(按键)..使用自定义的 ..那里的缓和作用是:

I want to apply translate animation on android view (button).. using a custom interpolator..where the easing function is:

public static float easeOut(float t,float b , float c, float d) {
    if ((t/=d) < (1/2.75f)) {
       return c*(7.5625f*t*t) + b;
    } else if (t < (2/2.75f)) {
       return c*(7.5625f*(t-=(1.5f/2.75f))*t + .75f) + b;
    } else if (t < (2.5/2.75)) {
       return c*(7.5625f*(t-=(2.25f/2.75f))*t + .9375f) + b;
    } else {
       return c*(7.5625f*(t-=(2.625f/2.75f))*t + .984375f) + b;
    }
}

我有一个使用自定义的内插这样一个例子:

I have an example that uses the custom interpolator like this:

该intreplator是:

The intreplator is :

public class HesitateInterpolator implements Interpolator {
    public HesitateInterpolator() {
    }

    public float getInterpolation(float t) {
        float x = 2.0f * t - 1.0f;
        return 0.5f * (x * x * x + 1.0f);
    }
}

和使用这样的:

ScaleAnimation anim = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f);
anim.setInterpolator(new HesitateInterpolator());

我的问题是: 这些是什么值B,C,D为??

My question is: What are these values b,c,d for ??

推荐答案

根据罗伯特·彭纳的缓解作用的,正如< A HREF =htt​​ps://github.com/danro/jquery-easing/blob/master/jquery.easing.js>这里:

T:当前时间,B:期初数,C:变化中值,D:病程

t: current time, b: begInnIng value, c: change In value, d: duration

如果要实现自定义插补,你必须做出这样的事情:

If you want to implement your custom Interpolator, you have to make something like this:

(这将是实现了 easeInOutQuint

public class MVAccelerateDecelerateInterpolator implements Interpolator {

    // easeInOutQuint
    public float getInterpolation(float t) {
        float x;
        if (t<0.5f)
        { 
            x = t*2.0f;
            return 0.5f*x*x*x*x*x;
        }
        x = (t-0.5f)*2-1;
        return 0.5f*x*x*x*x*x+1;
    }
}

编辑: 实现你需要一些数学知识的缓动函数,考虑到 getInterpolation 方法只能得到t参数,从0.0到1.0。

to implement the easing function you need some math knowledge, considering that the getInterpolation method gets only the t parameter, from 0.0 to 1.0.

因此​​,基本上需要开发AY(吨)的功能,用叔从0到1,并与y值从0到1,如下所示:

So basically you need to develop a y(t) function, with t from 0 to 1, and with y values from 0 to 1, as shown below:

你改变什么是曲线获得从0到1(在图像中的绿色行是线性的,例如)。你需要'正常化'的宽松政策职能留在(0,1)×(0,1)的平方,你可以在我的 easeInOutQuint 实施见。

What you change is the curve to get from 0 to 1 (in the image the green line is the linear one, for example). You need to 'normalize' the easing functions to remain in the (0, 1) x (0, 1) square, as you can see in my easeInOutQuint implementation.