How To Acheive Ballistic Easing Effect In Tweenjs
Perhaps a simple one, I'm animating along a curved path and wanted to apply an easing profile that eases out on the first half of the tween, and in on the second half. So a fast-sl
Solution 1:
TweenJS API docs say:
The Ease class provides a collection of easing functions for use with TweenJS. It does not use the standard 4 param easing signature. Instead it uses a single param which indicates the current linear ratio (0 to 1) of the tween.
Guided by Custom Easing Functions issue/article on GitHub, there is a way to define your custom function. Just go on and create your Bezier easing function, than transform it to linear.
You will get this kind of Bezier's function:
function(t:Number, b:Number, c:Number, d:Number):Number {
varts:Number=(t/=d)*t;
vartc:Number=ts*t;
return b+c*(0.699999999999999*tc*ts + -1.75*ts*ts + 3.9*tc + -4.1*ts + 2.25*t);
}
And your TweenJS easing will be:
var myEasing = function( k ) {
var t = (k*100);
var d = 100;
var ts=(t/=d)*t;
var tc=ts*t;
return (0.699999999999999*tc*ts + -1.75*ts*ts + 3.9*tc + -4.1*ts + 2.25*t);
};
In your code you will use it this way:
createjs.Tween.get(shape2).to({guide:{ path:[0,200, 200,100, 400,200] }},2000, myEasing);
Check it on updated Fiddle.
Post a Comment for "How To Acheive Ballistic Easing Effect In Tweenjs"