Skip to content
Related Articles

Related Articles

Node.js | GM shade() Function
  • Last Updated : 14 Jan, 2020

The shade() function is an inbuilt function in the GraphicsMagick library which is used to shade the image using a distant light source. The function returns the true value on success.

Syntax:

shade( azimuthal angle, elevation angle )

Parameters: This function accept two parameters as mentioned above and described below:

  • azimuthal angle: This parameter stores the value of the azimuthal angle.
  • elevation angle: This parameter stores the value of the elevation angle.

Return Value: This function returns GraphicsMagick object with image added.

Original Image:



Example:




// 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');
});

Output:

Reference:

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :