Open In App

Fabric.js easeOutQuad() Method

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

The Easing function is the rate of change of a parameter over time. It is the kind of equation that 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 easeOutQuad() method is used for quadratic easing out.

Syntax:



easeOutQuad(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, that is the position of the object at a particular time.

Example 1:




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

Output:

3.3125
4.326530612244898
6.625

Example 2:




<!DOCTYPE html>
<html>
  
<head>
  <!-- Adding the FabricJS library -->
  <script src=
  </script>
</head>
  
<body>
<script type="text/javascript">
  
 // Initializing easeOutQuad() function
 function easeOutQuad (t, b, c, d) {
    return -c * (t /= d) * (t - 2) + b;
 }
   
 // Initializing the parameters with its values
 var t1 = 5;
 var b1 = 10;
 var c1 = 40;
 var d1 = 12;
 var t2 = 12;
 var b2 = 13;
 var c2 = 17;
 var d2 = 22;
  
 // Calling the easeOutQuad() function over
 // the specified parameter values
 console.log(fabric.util.ease.easeOutQuad(t1, b1, c1, d1)); 
 console.log(fabric.util.ease.easeOutQuad(t2, b2, c2, d2)); 
</script>
  
</body>
  
</html>

Output:

36.388888888888886
26.48760330578512

Article Tags :