The multiplyTransformMatrices() method is used to multiply two specified matrices to nest transformation. For example, if the function is multiplyTransformMatrices(a, b), it means matrix a will be multiplied by matrix b.
Syntax:
multiplyTransformMatrices(a, b, is2x2)
Parameters: This method accepts a parameter as mentioned above and described below:
- a: This parameter holds the first specified transform matrix.
- b: This parameter holds the second specified transform matrix.
- is2x2: This parameter is a Boolean value that holds the flag to multiply matrices as 2×2 matrices.
Return Value: This method returns the product of the two specified transform matrices.
Example 1:
HTML
<!DOCTYPE html> < html >
< head >
< script src =
</ script >
< script type = "text/javascript" src =
</ script >
< script type = "text/javascript" src =
</ script >
</ head >
< body >
< script type = "text/javascript" >
// Calling multiplyTransformMatrices() function over
// some specified arrays
console.log(fabric.util.multiplyTransformMatrices([1, 2], [3, 4]));
console.log(fabric.util.multiplyTransformMatrices([1, 2], [3, 4], true));
console.log(fabric.util.multiplyTransformMatrices([1, 2], [3, 4], false));
console.log(fabric.util.multiplyTransformMatrices([1, 2, 3, 4],
[5, 6, 7, 8]));
console.log(fabric.util.multiplyTransformMatrices([1, 2, 3, 4],
[5, 6, 7, 8], true));
console.log(fabric.util.multiplyTransformMatrices([1, 2, 3, 4],
[5, 6, 7, 8], false));
</ script >
</ body >
</ html >
|
Output:
[null,null,null,null,null,null] [null,null,null,null,0,0] [null,null,null,null,null,null] [23,34,31,46,null,null] [23,34,31,46,0,0] [23,34,31,46,null,null]
Example 2:
HTML
<!DOCTYPE html> < html >
< head >
< script src =
</ script >
< script type = "text/javascript" src =
</ script >
< script type = "text/javascript" src =
</ script >
</ head >
< body >
< script type = "text/javascript" >
// Specifying some arrays
var a = [2, 4, 6, 8];
var b = [1, 3, 5, 7];
// Calling multiplyTransformMatrices() function over
// the above specified arrays
console.log(fabric.util.multiplyTransformMatrices(a, b, true));
console.log(fabric.util.multiplyTransformMatrices(a, b, false));
</ script >
</ body >
</ html >
|
Output:
[20,28,52,76,0,0] [20,28,52,76,null,null]