Reputation: 19479
public static float BackInOut(float from, float to, float time)
{
const float s = 1.70158f * 1.525f;
to -= from;
if ((time /= .5f) < 1f)
// 5 6 3 4 0 1 2 7
return to * .5f * (time * time * ((s + 1f) * time - s)) + from;
// 3 0 1 2
return to * .5f * ((time -= 2) * time * ((s + 1f) * time + s) + 2f) + from;
}
In the second return is time used before (and after) being modified? Yes?
// 1 0 2 3
return to * .5f * ((time -= 2) * time * ((s + 1f) * time + s) + 2f) + from;
Or only after, like this? Idk?
Thanks.
source: http://robertpenner.com/easing/
EDIT:
Tried to simplify:
using System;
namespace New_folder
{
class Program
{
static public int s { get; set; } = 2;
static private int _test = 10;
static public int time
{
get
{
Console.WriteLine(_test);
return _test;
}
set { _test = value; }
}
static public void Main(string[] args)
{
var test = (time -= 2) * time * ((s + 1f) * time + s);
}
}
}
This shows: 10 8 8
which shows that my second guess is right and time is only used after modification i think
I guess i was just confused. It goes into the right branch just to evaluate the deepest nesting then when back on higher level goes back to ltr and does not care where it was duh
thanks
Upvotes: 0
Views: 43
Reputation: 12858
To answer your question "In the second return is time used before (and after) being modified? Yes?"
How about this?
public int ReturnZeroIfValueIsNegative(int x)
{
if ((x += 100) <= 100) // the "+=" operator changed the value of x
{
return 0;
}
return x; // this will return the altered value of x
}
The above may be re-written to
x = x + 100;
if (x <= 100)
{
return 0;
}
return x;
You could take a look here for a general explanation regarding the order of operations for programming languages.
Upvotes: 1