Open In App

Fabric.js easeInOutQuint() Method

In animation and games, it can be seen that many objects are moving from one point to other linearly. But after using Easing function, the object’s way of progressing can take a different natural and interesting shape.

Easing functions is the rate of change of a parameter over time. It is those kind of equations which moves slowly at the start and speed up, and slow down at the end. These set of equations are taken from Robert Penner’s book and webpage.



The easeInOutQuint() method is used for quintic easing in and out.

Syntax:



easeInOutQuint(t, b, c, d)

Parameters: This method accepts four parameter as mentioned above and described below:

Return Value: This method returns the eased position of the object i.e., the position of the object at a specific time.

Example 1:




<!DOCTYPE html>
<html>
  
<head>
  <!-- Adding the FabricJS library -->
  <script src=
  </script>
</head>
  
<body>
<script type="text/javascript">
  
 // Initializing easeInOutQuint() function
 function easeInOutQuint (t, b, c, d) {
    if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
    return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
 }
  
 // Calling the easeInOutQuint() function over
 // the specified parameter values
 console.log(fabric.util.ease.easeInOutQuint(1, 2, 3, 4)); 
</script>
  
</body>
  
</html>

Output:

2.046875

Example 2:




<!DOCTYPE html>
<html>
  
<head>
  <!-- Adding the FabricJS library -->
  <script src=
  </script>
</head>
  
<body>
<script type="text/javascript">
  
 // Initializing easeInOutQuint() function
 function easeInOutQuint (t, b, c, d) {
    if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
    return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
 }
   
 // Initializing the parameters with its values
 var t = 5;
 var b = 10;
 var c = 40;
 var d = 12;
  
 // Calling the easeInOutQuint() function over
 // the specified parameter values
 console.log(fabric.util.ease.easeInOutQuint(t, b, c, d)); 
</script>
  
</body>
  
</html>

Output:

18.03755144032922

Article Tags :