• Create Account

Reversing an Ease? Ease-In, Ease-Out, Ease-InOut?

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

#1Servant of the Lord  Crossbones+   -  Reputation: 12494

Like
0Likes
Like

Posted 27 February 2013 - 01:54 PM

I'm looking over some easing equations at the moment, and viewing some code, and I got the code written for all the Ease-Ins.

Is there some way I can convert Ease-Ins to Ease-Outs without using entirely new equations?
Can I implement Ease-Outs as:

float EaseOut(blah)
{
float result = EaseIn(blah);
return reverse(result);
}


How do I generically reverse a Ease?

Looking at graphs like this, every Ease-Out is just a Ease-In rotated 180 degrees. Surely there's some way to create a function that will reverse any ease?

All my eases take a value between 0.0 to 1.0, and return a result from 0.0 to 1.0. (Actually, they can be given values less than 0.0 and greater than 1.0 and can return values less than 0.0 and greater than 1.0, but the 0.0 - 1.0 is the scale).

I can't just invert the result (1.0f - result), because that'd just flip the ease upside down. It seems I need to invert the position and the result.

Does this seem correct:

float DoEaseOut(EaseFunction easeFunction, float position)
{
float result = easeFunction(1.0f - position);
return 1.0f - result;
}

I'm not at a point where I can test the code.

Another question is, Ease-InOut seems to be:

if(less than 0.5)
{
result = EaseIn()
scale result from (0.0 - 1.0) to (0.0 - 0.5)
}
else
{
result = EaseOut()
scale result from (0.0 - 1.0) to (0.5 - 1.0)
}


Is that correct? Looking at some peoples' implementations, that sort-of seems to be what they are doing for some equations, but not for others.

So if I have all my easing equations as EaseIn equations, then I can use these:

float DoEaseOut(EaseFunction easeFunction, float position)
{
float result = easeFunction(1.0f - position);
return 1.0f - result;
}

float DoEaseInOut(EaseFunction easeFunction, float position)
{
if(position < 0.5f)
{
//Do the Ease-In.
float result = easeFunction(position * 2.0f);

//Scale to (0.0 - 0.5).
return (result * 0.5f);
}
else
{
//Do the Ease-Out.
float result = DoEaseOut(easeFunction, (position * 2.0f) - 1.0f);

//Scale to (0.5 - 1.0).
return (result * 0.5f) + 0.5f;
}
}

And just pass in the desired Ease-In functions?

Edited by Servant of the Lord, 27 February 2013 - 01:59 PM.

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.                                                                                                                                                       [Need free cloud storage? I personally like DropBox]

#2Álvaro  Crossbones+   -  Reputation: 7964

Like
1Likes
Like

Posted 27 February 2013 - 02:44 PM

There is at least one mistake in your code, but your general ideas are correct. You should use your code to generate a few graphs and then you'll find any mistakes easily.

#3Servant of the Lord  Crossbones+   -  Reputation: 12494

Like
0Likes
Like

Posted 27 February 2013 - 10:20 PM

I followed your advice and generated some graphs. It looks like it's working. What mistakes are you seeing in the code?

Bounce EaseIn

Bounce EaseOut

Bounce EaseInOut

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.                                                                                                                                                       [Need free cloud storage? I personally like DropBox]

#4Álvaro  Crossbones+   -  Reputation: 7964

Like
1Likes
Like

Posted 28 February 2013 - 01:25 PM

Oh, never mind. I thought you had a sign error but I was wrong.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS