如何修改此缓动函数反弹少? [英] How do I modify this easing function to bounce less?

查看:214
本文介绍了如何修改此缓动函数反弹少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想修改Flash CS3中的供给 fl.motion.easing.bounce 功能,使生成的动画反弹较少。我AP preciate那反弹少是一个有点模糊,但我理解的功能倒是AP preciate任何帮助。

感谢。

  / **
 *参数t指定当前时间,介于0和持续时间的包容性。
 *
 *参数B指定动画属性的初始值。
 *
 * @参数Ç指定动画属性的更改总计。
 *
 *参数d指定运动的持续时间。
 *
 返回:在指定时间的插补属性的值。
 * /
公共静态函数easeOut(T:编号,B:号码,
                               C:号码,D:数字):号码
{
    如果((吨/ = D)≤(1 / 2.75))
        回C *(7.5625 * T * T)+ B;

    否则如果(吨≤(2 / 2.75))
        回C *(7.5625 *(T  -  =(1.5 / 2.75))* T + 0.75)+ B;

    否则如果(吨≤(2.5 / 2.75))
        回C *(7.5625 *(T  -  =(2.25 / 2.75))* T + 0.9375)+ B;

    其他
        回C *(7.5625 *(T  -  =(2.625 / 2.75))* T + 0.984375)+ B;
}
 

解决方案

基本上,该函数返回取决于4个因素在新的位置的插值值:动画的当前时间,该属性的初始值是动态的,总的变化动画要做,和动画的总持续时间。

你有什么存在对不同的定时检查:如果动画仍然没有达到aprox的总时长的36%(1 / 2.75),应用第一个公式;如果它是在36%和72%,施加第二;等等。

每一个公式是根据第一棵树参数的函数,所以基本上你需要调整他们一点点。

我会建议与硬codeD 7.5625玩(使之更大,下看到的结果),直到您满意为止。


7.5625 Math.pow(2.75,2); ,但硬coded到节省处理。

I'm trying to modify Flash CS3's supplied fl.motion.easing.bounce function to make the resulting animation bounce less. I appreciate that 'bounce less' is a bit vague, but I'd appreciate any help in understanding the function.

Thanks.

 /**
 *  @param t Specifies the current time, between 0 and duration inclusive.
 *
 *  @param b Specifies the initial value of the animation property.
 *
 *  @param c Specifies the total change in the animation property.
 *
 *  @param d Specifies the duration of the motion.
 *
 *  @return The value of the interpolated property at the specified time.     
 */  
public static function easeOut(t:Number, b:Number,
                               c:Number, d:Number):Number
{
    if ((t /= d) < (1 / 2.75))
        return c * (7.5625 * t * t) + b;

    else if (t < (2 / 2.75))
        return c * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75) + b;

    else if (t < (2.5 / 2.75))
        return c * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375) + b;

    else
        return c * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375) + b;
}

解决方案

Basically, the function returns an interpolated value for the new position depending on 4 factors: current time of animation, initial value of the property being animated, total change of the animation to be done, and the total duration of the animation.

What you have there is a check for different timings: if the animation still didn't reach aprox 36% (1 / 2.75) of total duration, apply the first equation; if it's between 36% and 72%, apply the second; etc.

Every equation is a function depending on the first tree arguments, so basically you need to tweak them a little bit.

I'd suggest playing with that hard-coded 7.5625 (make it greater and lower to see the results) until you're satisfied.


The 7.5625 is Math.pow(2.75, 2);, but hard-coded to save on processing.

这篇关于如何修改此缓动函数反弹少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆