當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Node.js GM swirl()用法及代碼示例

swirl()函數是GraphicsMagick庫中的內置函數,用於圖像中心附近。度數指定漩渦的緊密度。

用法:

swirl( angle )

參數:該函數接受上麵提到並在下麵描述的單個參數:


  • angle:此參數存儲旋流角度。

返回值:此函數返回GraphicsMagick旋流圖像。

原始圖片:

範例1:

// Include gm library 
var gm = require('gm'); 
  
// Import the image 
gm('1.png') 
  
// Invoke swirl function with 
// an angle values as 45 
.swirl(45) 
  
// Process and Write the image 
.write("swirl1.png", function (err) { 
    if (!err) console.log('done'); 
});

輸出:

範例2:

// Include gm library 
var gm = require('gm'); 
   
// Import the image 
gm('1.png') 
   
// Set stroke color 
.stroke("#fe1232") 
   
// Set fill color 
.fill("#1200ff") 
   
// Draw Rectangle using drawRectangle function 
.drawRectangle(10, 2, 130, 30, 1, 2) 
   
// Invoke swirl function with 
// an angle value as -270  
.swirl(-270) 
   
// Process and Write the image 
.write("swirl2.png", function (err) { 
    if (!err) console.log('done'); 
});

輸出:

參考:



相關用法


注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 Node.js | GM swirl() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。