Open In App
Related Articles

Fabric.js matrixToSVG() Method

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

The matrixToSVG() method is used to return something like “matrix(…numbers)” for the specified array of some numbers.

Syntax:

matrixToSVG(transform)

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

  • transform: This parameter holds the specified array containing some numbers.

Return Value: This method returns the transformed matrix for SVG something like “matrix(…numbers)”.

Example 1:

Javascript

<!DOCTYPE html>
<html>
 
<head>
    <script src=
    </script>
 
    <script type="text/javascript" src=
    </script>
</head>
 
<body>
    <script type="text/javascript">
 
        // Calling matrixToSVG() function over
        // the specified arrays
        console.log(fabric.util.matrixToSVG(
                [1, 2, 3, 4, 5, 6]));
        console.log(fabric.util.matrixToSVG([0]));
        console.log(fabric.util.matrixToSVG([2, 4, 6]));
    </script>
</body>
 
</html>

                    


Output:

matrix(1 2 3 4 5 6)
matrix(0)
matrix(2 4 6)

Example 2:

Javascript

<!DOCTYPE html>
<html>
 
<head>
    <script src=
    </script>
 
    <script type="text/javascript" src=
    </script>
</head>
 
<body>
    <script type="text/javascript">
     
        // Specifying some arrays
        var a = [2, 4];
        var b = [0.1, 2.4];
        var c = [1, 3, 5, 7];
 
        // Calling matrixToSVG() function over
        // the above specified arrays
        console.log(fabric.util.matrixToSVG(a));
        console.log(fabric.util.matrixToSVG(b));
        console.log(fabric.util.matrixToSVG(c));
    </script>
</body>
 
</html>

                    

Output:

matrix(2 4)
matrix(0.1 2.4)
matrix(1 3 5 7)


Last Updated : 04 Mar, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads