当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Fabric.js qrDecompose()用法及代码示例


qrDecompose()方法用于将指定的标准2×3矩阵分解为变换分量

用法:

qrDecompose( mat )

参数:此方法接受如上所述和以下描述的参数:

  • mat:此参数保存变换矩阵的指定数组。

返回值:此方法返回转换的组成部分。

范例1:



Javascript

<!DOCTYPE html> 
<html> 
  
<head> 
    <!-- Adding the FabricJS library --> 
    <script src= 
"https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.6.2/fabric.min.js"> 
    </script> 
</head> 
  
<body> 
    <script type="text/javascript"> 
  
        // Calling qrDecompose() function over 
        // the specified array of transform matrix 
        console.log(fabric.util 
            .qrDecompose([1, 2, 3, 4, 5, 6])); 
    </script> 
</body> 
  
</html>

输出:

{"angle":63.434948822922,"scaleX":2.23606797749979,"scaleY":-0.8944271909999159,
"skewX":65.55604521958347,"skewY":0,"translateX":5,"translateY":6}

范例2:

Javascript

<!DOCTYPE html> 
<html> 
  
<head> 
  
    <!-- Adding the FabricJS library --> 
    <script src= 
"https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.6.2/fabric.min.js"> 
    </script> 
</head> 
  
<body> 
    <script type="text/javascript"> 
  
        // Specifying some array of transform matrix 
        var a1 = [1, 2, 3]; 
        var a2 = [0, 6, 7, 8, 0, 0]; 
  
        // Calling qrDecompose() function over the 
        // above specified array of transform matrix 
        console.log(fabric.util.qrDecompose(a1)); 
        console.log(fabric.util.qrDecompose(a2)); 
    </script> 
  
</body> 
  
</html>

输出:

{"angle":63.434948822922,"scaleX":2.23606797749979,"scaleY":null,"skewX":null,"skewY":0}
{"angle":90,"scaleX":6,"scaleY":-7,"skewX":53.13010235415598,"skewY":0,
"translateX":0,"translateY":0}

相关用法


注:本文由纯净天空筛选整理自Kanchan_Ray大神的英文原创作品 Fabric.js qrDecompose() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。