📜  Node.js GM shade()函数

📅  最后修改于: 2022-05-13 01:56:37.500000             🧑  作者: Mango

Node.js GM shade()函数

shade()函数是 GraphicsMagick 库中的一个内置函数,用于使用远处光源对图像进行着色。该函数在成功时返回真值。

句法:

shade( azimuthal angle, elevation angle )

参数:此函数接受上面提到的两个参数,如下所述:

  • 方位角:该参数存储方位角的值。
  • 仰角:该参数存储仰角的值。

返回值:此函数返回添加了图像的 GraphicsMagick 对象。

原图:

例子:

// Include gm library
var gm = require('gm');
  
// Import the image
gm('gfg.png')
  
// Set stroke color
.stroke("#fe1232")
  
// Set fill color
.fill("#1200ff")
  
// Draw Rectangle using drawRectangle function
.drawRectangle(10, 2, 130, 30, 1, 2)
  
// Invoke shadefunction with azimuthal
// as 45 and elevation angle as 90
.shade(45, 90)
  
// Process and Write the image
.write("shade1.png", function (err) {
  if (!err) console.log('done');
});

输出:

参考:

  • http://www.graphicsmagick.org/GraphicsMagick.html#details-shade
  • https://www.npmjs.com/package/gm