• Create Account

### #ActualServant of the Lord

Posted 27 February 2013 - 01:59 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?

### #2Servant of the Lord

Posted 27 February 2013 - 01:56 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);

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

And just pass in the desired Ease-In functions?

### #1Servant of the Lord

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);

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

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

And just pass in the desired Ease-In functions?

PARTNERS