1. //These functions assume 'position' is of the _scale_ (0.0 to 1.0), though they can be outside that _range_.
2.
3. //For consistency, this 'Coverts' an EaseIn function to... an EaseIn function. It doesn't actually do anything.
4. inline float DoEaseIn(EaseFunction easeFunction, float position) { return easeFunction(position); }
5.
6. //Converts a EaseIn function to an EaseOut function.
7. float DoEaseOut(EaseFunction easeFunction, float position)
8. {
9. float result = easeFunction(1.0f - position);
10. return (1.0f - result);
11. }
12.
13. //Converts a EaseIn function to an EaseInOut function.
14. float DoEaseInOut(EaseFunction easeFunction, float position)
15. {
16. //If less than halfway, Ease-In.
17. if(position < 0.5f)
18. {
19. //Doubles the positon to scales it from (0.0 - 0.5) to (0.0 - 1.0)
20. float result = easeFunction(position * 2.0f);
21.
22. //Scale to (0.0 - 0.5), by halfing the result.
23. return (result * 0.5f);
24. }
25. //If more than halfway, Ease-Out.
26. else
27. {
28. //Scales the position from (0.5 - 1.0) to (0.0 - 1.0)
29. float result = DoEaseOut(easeFunction, (position * 2.0f) - 1.0f);
30.
31. //Scale to (0.5 - 1.0), by halfing the result and then adding half.
32. return (result * 0.5f) + 0.5f;
33. }
34. }
35.
36. //Converts an EaseIn function to an EaseOutIn function.
37. float DoEaseOutIn(EaseFunction easeFunction, float position)
38. {
39. //If less than halfway, Ease-Out.
40. if(position < 0.5f)
41. {
42. //Doubles the positon to scales it from (0.0 - 0.5) to (0.0 - 1.0)
43. float result = DoEaseOut(easeFunction, position * 2.0f);
44.
45. //Scale to (0.0 - 0.5), by halfing the result.
46. return (result * 0.5f);
47. }
48. //If more than halfway, Ease-In.
49. else
50. {
51. //Scales the position from (0.5 - 1.0) to (0.0 - 1.0)
52. float result = easeFunction((position * 2.0f) - 1.0f);
53.
54. //Scale to (0.5 - 1.0), by halfing the result and then adding half.
55. return (result * 0.5f) + 0.5f;
56. }
57. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout

Standard output is empty