Guest User

simpleEasing.gml

a guest
Aug 25th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define simpleEasing
  2. ///simpleEasing(Easing Function, Current Time, Beginning Value, Change In Value, Duration[, Ratio])
  3. __e = argument0; //Easing Function
  4. __t = argument1; //Current Time
  5. __b = argument2; //Beginning Value
  6. __c = argument3; //Change in Value
  7. __d = argument4; //Duration
  8. __s = 1.70158; //Ratio
  9. if (argument_count > 5){
  10.     __s = argument[5];
  11. }
  12.  
  13. if(script_exists(__e)){
  14.     if(__t/__d < 1){
  15.         return script_execute(__e);
  16.     } else {
  17.         return __b + __c;
  18.     }
  19. }
  20. #define easeInSine
  21. return -__c * cos(__t/__d * (pi/2)) + __c + __b;
  22. #define easeOutSine
  23. return __c * sin(__t/__d * (pi/2)) + __b;
  24. #define easeInOutSine
  25. return -__c/2 * (cos(pi*__t/__d)-1)+__b;
  26. #define easeInQuad
  27. __t /= __d;
  28. return __c*(__t)*__t + __b;
  29. #define easeOutQuad
  30. __t /= __d;
  31. return -__c * (__t)*(__t - 2) + __b;
  32. #define easeInOutQuad
  33. __t /= __d/2;
  34. if(__t < 1) return __c/2*__t*__t + __b;
  35. return -__c/2 * ((--__t)*(__t-2) - 1) + __b;
  36. #define easeInCubic
  37. __t /= __d;
  38. return __c * power(__t,3) + __b;
  39. #define easeOutCubic
  40. __t /= __d - 1;
  41. return __c * (power(__t,3) + 1) + __b;
  42. #define easeInOutCubic
  43. __t /= __d/2;
  44. if(__t < 1){
  45.     return __c/2*power(__t,3) + __b;
  46. } else {
  47.     __t -= 2;
  48.     return __c / 2 * (power(__t,3) + 2) + __b;
  49. }
  50. #define easeInQuart
  51. __t /= __d;
  52. return __c * power(__t,4) + __b;
  53. #define easeOutQuart
  54. __t =  __t/__d-1;
  55. return -__c * (power(__t,4) - 1) + __b;
  56. #define easeInOutQuart
  57. __t /= __d/2;
  58. if(__t < 1){
  59.     return __c/2*power(__t,4)+__b;
  60. } else {
  61.     __t -= 2;
  62.     return -__c/2 * (power(__t,4) - 2) + __b;
  63. }
  64. #define easeInQuint
  65. __t /= __d;
  66. return __c * power(__t,5) + __b;
  67. #define easeOutQuint
  68. __t =  __t/__d-1;
  69. return __c * (power(__t,5) + 1) + __b;
  70. #define easeInOutQuint
  71. __t /= __d/2;
  72. if(__t < 1){
  73.     return __c/2*power(__t,5)+__b;
  74. } else {
  75.     __t -= 2;
  76.     return __c/2 * (power(__t,5) + 2) + __b;
  77. }
  78. #define easeInExpo
  79. if(__t == 0) return __b;
  80. else return __c * power(2, 10 * (__t/__d - 1)) + __b;
  81. #define easeOutExpo
  82. return __c * (-power(2, -10 * __t/__d) + 1) + __b;
  83. #define easeInOutExpo
  84. if(__t == 0) return __b;
  85. __t /= __d/2;
  86. if(__t < 1) return __c/2 * power(2, 10 * (__t -1)) + __b;
  87. else return __c/2 * (-power(2, -10 * --__t) + 2) + __b;
  88. #define easeInCirc
  89. __t /= __d;
  90. return -__c * (sqrt(1 - __t * __t) - 1) + __b;
  91. #define easeOutCirc
  92. __t = __t/__d-1;
  93. return __c * sqrt(1 - __t*__t) + __b;
  94. #define easeInOutCirc
  95. __t /= __d/2;
  96. if(__t < 1) {
  97.     return -__c/2 * (sqrt(1 - __t * __t) - 1) + __b;
  98. } else {
  99.     __t -= 2;
  100.     return __c/2 * (sqrt(1 - __t * __t) + 1) + __b;
  101. }
  102. #define easeInBack
  103. __t /= __d;
  104. return __c * __t * __t * ((__s+1)*__t - __s) + __b;
  105. #define easeOutBack
  106. __t = __t/__d-1;
  107. return __c * (__t * __t * ((__s+1)*__t + __s) + 1) + __b;
  108. #define easeInOutBack
  109. __t /= __d / 2;
  110. __s*=1.525
  111. if(__t < 1){
  112.     return __c/2*(__t*__t*((__s + 1)*__t-__s)) + __b;
  113. } else {
  114.     __t -= 2;
  115.     __s *= 1.525;
  116.     return __c/2 * (__t*__t*((__s+1)*__t+__s) + 2) + __b;
  117. }
  118. #define easeInElastic
  119. __s = 1.70158;
  120. __p = 0;
  121. __a = __c;
  122.  
  123. if(__t == 0) return __b;
  124. __t /= __d;
  125. if(!__p) __p = __d * 0.3;
  126. if(__a < abs(__c))
  127. {
  128.     __a = __c;
  129.     __s = __p / 4;
  130. }
  131. else __s = __p / (2 * pi) * arcsin(__c / __a);
  132. return -(__a * power(2, 10 * (--__t)) * sin((__t * __d - __s) * (2 * pi) / __p)) + __b;
  133. #define easeOutElastic
  134. __s = 1.70158;
  135. __p = 0;
  136. __a = __c;
  137.  
  138. if(__t == 0) return __b;
  139. __t /= __d;
  140. if(!__p) __p = __d * 0.3;
  141. if(__a < abs(__c))
  142. {
  143.     __a = __c;
  144.     __s = __p / 4;
  145. }
  146. else __s = __p / (2 * pi) * arcsin(__c / __a);
  147. return __a * power(2, -10 * __t) * sin((__t * __d - __s) * (2 * pi) / __p) + __c + __b;
  148. #define easeInOutElastic
  149. __s = 1.70158;
  150. __p = 0;
  151. __a = __c;
  152.  
  153. if(__t == 0) return __b;
  154. __t /= __d/2;
  155. if(__t == 2) return __b + __c;
  156. if(!__p) __p = __d * (0.3*1.5);
  157. if(__a < abs(__c))
  158. {
  159.     __a = __c;
  160.     __s = __p / 4;
  161. }
  162. else __s = __p / (2 * pi) * arcsin(__c / __a);
  163. if(__t<1){
  164.     return -0.5*(__a * power(2, 10 * (--__t)) * sin((__t * __d - __s) * (2 * pi) / __p)) + __b;
  165. } else {
  166.     return __a * power(2, -10 * (--__t)) * sin((__t * __d - __s) * (2 * pi) / __p)*0.5 + __c + __b;
  167. }
  168. #define easeInBounce
  169. __t = __d - __t;
  170. temp__b = __b;
  171. __b = 0;
  172. __t /= __d;
  173. if(__t < (1/2.75)){
  174.     return __c - __c*(7.5625*__t*__t) + __b + temp__b;
  175. } else if (__t < (2/2.75)) {
  176.     __t -= (1.5/2.75);
  177.     return __c - __c*(7.5625*__t*__t + 0.75) + __b + temp__b;
  178. } else if (__t < (2.5/2.75)) {
  179.     __t -= (2.25/2.75);
  180.     return __c - __c*(7.5625*__t*__t + 0.9375) + __b + temp__b;
  181. } else {
  182.     __t -= (2.625/2.75);
  183.     return __c - __c*(7.5625*__t*__t + 0.984375) + __b + temp__b;
  184. }
  185. #define easeOutBounce
  186. __t /= __d;
  187. if(__t < (1/2.75)){
  188.     return __c*(7.5625*__t*__t) + __b;
  189. } else if (__t < (2/2.75)) {
  190.     __t -= (1.5/2.75);
  191.     return __c*(7.5625*__t*__t + 0.75) + __b;
  192. } else if (__t < (2.5/2.75)) {
  193.     __t -= (2.25/2.75);
  194.     return __c*(7.5625*__t*__t + 0.9375) + __b;
  195. } else {
  196.     __t -= (2.625/2.75);
  197.     return __c*(7.5625*__t*__t + 0.984375) + __b;
  198. }
  199. #define easeInOutBounce
  200. if(__t < __d/2){
  201.     __t *= 2;
  202.     __t = __d - __t;
  203.     temp__b = __b;
  204.     __b = 0;
  205.     __t /= __d;
  206.     if(__t < (1/2.75)){
  207.         return (__c - __c*(7.5625*__t*__t) + __b) * 0.5 + temp__b;
  208.     } else if (__t < (2/2.75)) {
  209.         __t -= (1.5/2.75);
  210.         return (__c - __c*(7.5625*__t*__t + 0.75) + __b) * 0.5 + temp__b;
  211.     } else if (__t < (2.5/2.75)) {
  212.         __t -= (2.25/2.75);
  213.         return (__c - __c*(7.5625*__t*__t + 0.9375) + __b) * 0.5 + temp__b;
  214.     } else {
  215.         __t -= (2.625/2.75);
  216.         return (__c - __c*(7.5625*__t*__t + 0.984375) + __b) * 0.5 + temp__b;
  217.     }
  218. } else {
  219.     __t = __t*2-__d;
  220.     temp__b = __b;
  221.     __b = 0;
  222.    
  223.     __t /= __d;
  224.     if(__t < (1/2.75)){
  225.         return (__c*(7.5625*__t*__t) + __b) * 0.5 + __c * 0.5 + temp__b;
  226.     } else if (__t < (2/2.75)) {
  227.         __t -= (1.5/2.75);
  228.         return (__c*(7.5625*__t*__t + 0.75) + __b) * 0.5 + __c * 0.5 + temp__b;
  229.     } else if (__t < (2.5/2.75)) {
  230.         __t -= (2.25/2.75);
  231.         return (__c*(7.5625*__t*__t + 0.9375) + __b) * 0.5 + __c * 0.5 + temp__b;
  232.     } else {
  233.         __t -= (2.625/2.75);
  234.         return (__c*(7.5625*__t*__t + 0.984375) + __b) * 0.5 + __c * 0.5 + temp__b;
  235.     }
  236. }
Advertisement
Add Comment
Please, Sign In to add comment