pkg.re/essentialkaos/ek@v12.36.0+incompatible/easing/quint.go (about)

     1  package easing
     2  
     3  // ////////////////////////////////////////////////////////////////////////////////// //
     4  //                                                                                    //
     5  //                         Copyright (c) 2021 ESSENTIAL KAOS                          //
     6  //      Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>     //
     7  //                                                                                    //
     8  // ////////////////////////////////////////////////////////////////////////////////// //
     9  
    10  // QuintIn accelerating from zero velocity
    11  // https://easings.net/#easeInQuint
    12  func QuintIn(t, b, c, d float64) float64 {
    13  	if t > d {
    14  		return c
    15  	}
    16  
    17  	t /= d
    18  	return c*t*t*t*t*t + b
    19  }
    20  
    21  // QuintOut decelerating to zero velocity
    22  // https://easings.net/#easeOutQuint
    23  func QuintOut(t, b, c, d float64) float64 {
    24  	if t > d {
    25  		return c
    26  	}
    27  
    28  	t /= d
    29  	t--
    30  
    31  	return c*(t*t*t*t*t+1) + b
    32  }
    33  
    34  // QuintInOut acceleration until halfway, then deceleration
    35  // https://easings.net/#easeInOutQuint
    36  func QuintInOut(t, b, c, d float64) float64 {
    37  	if t > d {
    38  		return c
    39  	}
    40  
    41  	t /= d / 2
    42  
    43  	if t < 1 {
    44  		return c/2*t*t*t*t*t + b
    45  	}
    46  
    47  	t -= 2
    48  
    49  	return c/2*(t*t*t*t*t+2) + b
    50  }