stroke()函数是GraphicsMagick库中的内置函数,用于设置用于绘制对象轮廓的笔触的颜色和宽度。
用法:
stroke( color, width )
参数:该函数接受上述和以下所述的两个参数:
- color:此参数存储笔划的颜色。
 - width:这是一个可选参数,用于存储对象的宽度。
 
返回值:此函数返回添加了图像的GraphicsMagick对象。
原始图片:

范例1:
// Include gm library 
var gm = require('gm'); 
  
// Import the image 
gm('1.png') 
  
// Set stroke color and size 
.stroke("#fe1232", 5) 
  
// Set fill color 
.fill("#56f864") 
  
// Draw Circle using drawCircle function 
.drawCircle(120, 50, 100, 60).stroke() 
  
// Process and Write the image 
.write("1a.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) 
  
// Process and Write the image 
.write("1a.png", function (err) { 
    if (!err) console.log('done'); 
});输出:

参考:
相关用法
- p5.js stroke()用法及代码示例
 - Node.js GM blur()用法及代码示例
 - Node.js GM sharpen()用法及代码示例
 - Node.js GM charcoal()用法及代码示例
 - CSS stroke-linejoin用法及代码示例
 - CSS stroke-dasharray用法及代码示例
 - CSS stroke-linecap用法及代码示例
 - CSS stroke-opacity用法及代码示例
 - CSS stroke-dashoffset用法及代码示例
 - CSS stroke-width用法及代码示例
 - CSS stroke-miterlimit用法及代码示例
 - HTML canvas stroke()用法及代码示例
 
注:本文由纯净天空筛选整理自sarthak_ishu11大神的英文原创作品 Node.js | GM stroke() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
