1-
21// Translation to C# from https://easings.net/
32// by LTMX - https://github.com/LTMX
43
5-
6- using static Unity . Mathematics . math ;
7-
84namespace UME
95{
106 public static partial class UnityMathematicsExtensions
@@ -17,13 +13,13 @@ public static partial class UnityMathematicsExtensions
1713 public static float easeInOutQuad ( this float x ) => x < 0.5 ? 2 * x * x : 1 - ( - 2 * x + 2 ) . sqr ( ) / 2 ;
1814 public static float easeInCubic ( this float x ) => x . cube ( ) ;
1915 public static float easeOutCubic ( this float x ) => 1 - ( 1 - x ) . cube ( ) ;
20- public static float easeInOutCubic ( this float x ) => x < 0.5 ? 4 * x * x * x : 1 - ( - 2 * x + 2 ) . cube ( ) / 2 ;
16+ public static float easeInOutCubic ( this float x ) => x < 0.5 ? 4 * x . cube ( ) : 1 - ( - 2 * x + 2 ) . cube ( ) / 2 ;
2117 public static float easeInQuart ( this float x ) => x * x * x * x ;
2218 public static float easeOutQuart ( this float x ) => 1 - pow ( 1 - x , 4 ) ;
23- public static float easeInOutQuart ( this float x ) => x < 0.5 ? 8 * x * x * x * x : 1 - pow ( - 2 * x + 2 , 4 ) / 2 ;
24- public static float easeInQuint ( this float x ) => x * x * x * x * x ;
19+ public static float easeInOutQuart ( this float x ) => x < 0.5 ? 8 * x . quart ( ) : 1 - pow ( - 2 * x + 2 , 4 ) / 2 ;
20+ public static float easeInQuint ( this float x ) => x . quint ( ) ;
2521 public static float easeOutQuint ( this float x ) => 1 - pow ( 1 - x , 5 ) ;
26- public static float easeInOutQuint ( this float x ) => x < 0.5 ? 16 * x * x * x * x * x : 1 - pow ( - 2 * x + 2 , 5 ) / 2 ;
22+ public static float easeInOutQuint ( this float x ) => x < 0.5 ? 16 * x . quint ( ) : 1 - pow ( - 2 * x + 2 , 5 ) / 2 ;
2723 public static float easeInExpo ( this float x ) => x == 0 ? 0 : exp2 ( 10 * x - 10 ) ;
2824 public static float easeOutExpo ( this float x ) => x == 1 ? 1 : 1 - exp2 ( - 10 * x ) ;
2925 public static float easeInOutExpo ( this float x ) {
@@ -42,7 +38,7 @@ public static float easeInOutCirc(this float x){
4238 public static float easeInBack ( this float x ) {
4339 const float c1 = 1.70158f ;
4440 const float c3 = c1 + 1 ;
45- return c3 * x * x * x - c1 * x * x ;
41+ return c3 * x . cube ( ) - c1 * x . sqr ( ) ;
4642 }
4743 public static float easeOutBack ( this float x ) {
4844 const float c1 = 1.70158f ;
@@ -74,9 +70,8 @@ public static float easeInOutElastic(this float x) {
7470 return - ( exp2 ( 20 * x - 10 ) * sin ( ( 20 * x - 11.125f ) * c5 ) ) / 2 ;
7571 return ( exp2 ( - 20 * x + 10 ) * sin ( ( 20 * x - 11.125f ) * c5 ) ) / 2 + 1 ;
7672 }
77- public static float easeInBounce ( this float x ) {
78- return 1 - easeOutBounce ( 1 - x ) ;
79- }
73+ public static float easeInBounce ( this float x ) => 1 - easeOutBounce ( 1 - x ) ;
74+
8075 public static float easeOutBounce ( this float x ) {
8176 const float n1 = 7.5625f ;
8277 const float d1 = 2.75f ;
@@ -92,7 +87,5 @@ public static float easeInOutBounce(this float x){
9287 ? ( 1 - easeOutBounce ( 1 - 2 * x ) ) / 2
9388 : ( 1 + easeOutBounce ( 2 * x - 1 ) ) / 2 ;
9489 }
95-
9690 }
97-
9891}
0 commit comments