Node.js GM drawPolyline() Function
The drawPolyline() function is an inbuilt function in the GraphicsMagick library which is used to draw polylines with specified coordinates. The function returns the true value of success.
Syntax:
drawPolyline( [x0, y0], ..., [xn, yn] )
Parameters: This function accepts the array of x and y coordinates.
Return Value: This function returns the GraphicsMagick object.
Original Image:
Example 1:
javascript
const gm = require( 'gm' ).subClass({imageMagick: true });
gm( '1.png' )
.stroke( "#000000" )
.drawPolyline([12, 60], [45, 79], [80, 120], [300, 32])
.write( "drawPolyline1.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Example 2:
javascript
const gm = require( 'gm' );
gm(600, 300, 'white' )
.stroke( "green" , 3)
.font( "Helvetica.ttf" , 60)
.drawPolyline([12, 60], [45, 79], [80, 120],
[300, 32], [400, 150], [500, 200])
.drawText(100, 280, "GeeksforGeeks!" )
.write( "drawPolyline1.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Reference:
Last Updated :
30 Mar, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...