Hi,
I don't know if i'm daft or what; I don't see an obvious way of porting typical easing functions: (t, b, c, d) to starlings transition function (ratio).
Any help would be appreciated.
Thanks.
Hi,
I don't know if i'm daft or what; I don't see an obvious way of porting typical easing functions: (t, b, c, d) to starlings transition function (ratio).
Any help would be appreciated.
Thanks.
Actually, I used Robert Penner's easing functions as a starting point; but I could never understand why he used so many parameters.
The original functions are defined like this:
function someEasing(t:Number, b:Number, c:Number, d:Number):Number;
where:
* t → current time
* b → start value
* c → end value
* d → total time
In Starling, I made two simple changes:
* Instead of time, I used 'ratio'. Which simply means that "d" (total time) is always "1".
* Start and end values are simply zero and one.
In other words, all but one parameters become constants:
* t → current time = ratio
* b → start value = 0
* c → end value = 1
* d → total time = 1
With that knowledge, it's easy to convert from Robert's original functions to the Starling variants.
For example, here's linear easing. (I omit the parameter types below for clarity.)
// Penner: function linear(t, b, c, d) { return c * t / d + b; } // Starling: function linear(ratio) { // return 1 * ratio / 1 + 0; return ratio; }
Or Quintic easing:
// Penner function easeInQuint(t, b, c, d) { return c*(t/=d)*t*t*t*t + b; } // Starling function easeInQuint(ratio) { //return 1*(ratio/=1)*ratio*ratio*ratio*ratio + 0; return ratio*ratio*ratio*ratio*ratio; }
I hope that helps!
Perfect response; much appreciated.
This would go great in the custom transitions section of the wiki/manual.
Thanks.
I'm glad it helped! You're right, that information might be useful for others, as well. I'll try to find a good place for it, either in the manual or the wiki.
Cheers!
You must log in to post.