Node.js GM drawBezier() Function
Last Updated :
30 Mar, 2023
The drawBezier() function is an inbuilt function in the GraphicsMagick library which is used to draw the Bezier curve with specified coordinates. The function returns the true value of success.
Syntax:
drawBezier( [x0, y0], ..., [xn, yn] )
Parameters: This function accepts the array of points having 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( "#ffffff" )
.drawBezier([30, 20], [390, 70], [140, 110],
[45, 56], [98, 45], [123, 65])
.write( "drawBezier1.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)
.drawBezier([30, 20], [390, 70], [140, 110],
[45, 56], [98, 45], [123, 65], [500, 250])
.drawText(100, 280, "GeeksforGeeks!" )
.write( "drawBezier1.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Reference:
Share your thoughts in the comments
Please Login to comment...