Jump to content
  • Advertisement
Sign in to follow this  
Servant of the Lord

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

This topic is 2000 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

 

easinggraphs.png

 

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

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!