Open In App

Fabric.js invertTransform() Method

Last Updated : 02 Mar, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

The invertTransform() method is used to return the inverted form of the specified array transform. This function computes the bit-wise Inversion of an array element.

Syntax:

invertTransform(t)

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

  • t: This parameter holds the specified array transform.

Return Value: This method returns the inverted form of the specified array transform.

Example 1:

Javascript




<!DOCTYPE html>
<html>
 
<head>
    <!-- Adding the FabricJS library -->
    <script src=
    </script>
</head>
 
<body>
    <script type="text/javascript">
 
        // Calling invertTransform() function over
        // some array transform
        console.log(fabric.util
            .invertTransform([1, 2, 3]));
 
        console.log(fabric.util
            .invertTransform([1, 2, 3, 4]));
 
        console.log(fabric.util
            .invertTransform([1, 2, 3, 4, 5]));
 
        console.log(fabric.util
            .invertTransform([1, 2, 3, 4, 5, 6]));
    </script>
</body>
 
</html>


Output:

[null,null,null,null,null,null]
[-2,1,1.5,-0.5,null,null]
[-2,1,1.5,-0.5,null,null]
[-2,1,1.5,-0.5,1,-2]

Example 2:

Javascript




<!DOCTYPE html>
<html>
 
<head>
    <!-- Adding the FabricJS library -->
    <script src=
    </script>
</head>
 
<body>
    <script type="text/javascript">
 
        // Specifying some arrays
        var array1 = [5, 10, 15, 20];
        var array2 = [1, 3, 5, 7, 9, 11];
 
        // Calling invertTransform() function
        // over the above array transform
        console.log(fabric.util.invertTransform(array1));
        console.log(fabric.util.invertTransform(array2));
    </script>
</body>
 
</html>


Output:

[-0.4,0.2,0.3,-0.1,null,null]
[-0.875,0.375,0.625,-0.125,1,-2]


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads