Node.js GM drawEllipse() Function
The drawEllipse() function is an inbuilt function in the GraphicsMagick library which is used to draw an ellipse with specified coordinates. The function returns the true value of success.
Syntax:
drawEllipse( x0, y0, x1, y1, r0, r1 )
Parameters: This function accepts six parameters as mentioned above and described below:
- x0: This parameter stores the x-coordinate value of the initial point.
- y0: This parameter stores the y-coordinate value of the initial point.
- x1: This parameter stores the x-coordinate value of the final point.
- y1: This parameter stores the y-coordinate value of the final point.
- r0: This parameter stores the x-radius value of the ellipse.
- r1: This parameter stores the y-radius value of the ellipse.
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" )
.drawEllipse(230, 45, 300, 89, 50, 40)
.write( "drawEllipse1.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)
.drawText(100, 280, "GeeksforGeeks!" )
.drawEllipse(290, 15, 300, 210, 20, 160)
.write( "drawEllipse1.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Reference:
Last Updated :
29 Mar, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...