Open In App

Fabric.js easeInExpo() Method

In games or animations, there are many moving objects which can move them from point A to B in a linear fashion, but after applying the easing function, it can make it look more natural. An easing function says how animation progress. In this way, a straight motion can take an interesting shape.

Easing functions specify the rate of change of a parameter over time. It is whose equations which make something move slowly at the start and speed up, or slow down near the end. The most common set of easing equations come from Robert Penner’s book and webpage.



The easeInExpo() method is used for exponential in-easing.

Syntax:



easeInExpo(t, b, c, d)

Parameters: This method accepts four parameters 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 easeInExpo() function
        function easeInExpo(t, b, c, d) {
            return (t == 0) ? b : c * Math.pow(
                2, 10 * (t / d - 1)) + b;
        }
  
        // Calling the easeInExpo() function over
        // the specified parameter values
        console.log(fabric.util.ease
            .easeInExpo(1, 2, 3, 4));
    </script>
</body>
  
</html>

Output:

2.01657281518406

Example 2:




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

Output:

10.701538780193358

Article Tags :