drawEllipse()函數是GraphicsMagick庫中的內置函數,用於繪製具有指定坐標的橢圓。成功時該函數返回真實值。
用法:
drawEllipse( x0, y0, x1, y1, r0, r1 )
參數:該函數接受上述和以下所述的六個參數:
- x0:此參數存儲初始點的x坐標值。
- y0:此參數存儲初始點的y坐標值。
- x1:此參數存儲最終點的x坐標值。
- y1:此參數存儲終點的y坐標值。
- r0:此參數存儲橢圓的x-radius值。
- r1:此參數存儲橢圓的y-radius值。
返回值:此函數返回GraphicsMagick對象。
原始圖片:
範例1:
// Include gm library
var gm = require('gm').subClass({imageMagick:true});
// Import the image
gm('1.png')
// Set the color for the stroke
.stroke("#ffffff")
// Invoke drawEllipse function with
// x0 as 230, y0 as 45, x1 as 100,
// y1 as 89, r0 as 50 and r1 as 40
.drawEllipse(230, 45, 300, 89, 50, 40)
// Process and write the image
.write("drawEllipse1.png", function (err) {
if (!err) console.log('done');
});
輸出:
範例2:
// Include gm library
var gm = require('gm');
//Import the image
gm(600, 300, 'white')
// set the color for the stroke
.stroke("green", 3)
// Set the font
.font("Helvetica.ttf", 60)
//Call to drawText Function
.drawText(100, 280, "GeeksforGeeks!")
// Invoke drawEllipse function with x0
// as 230, y0 as 45, x1 as 100, y1 as
// 89, r0 as 50 and r1 as 40
.drawEllipse(290, 15, 300, 210, 20, 160)
// Process and write the image
.write("drawEllipse1.png", function (err) {
if (!err) console.log('done');
});
輸出:
參考:
相關用法
- Node.js GM drawLine()用法及代碼示例
- Node.js GM sharpen()用法及代碼示例
- Node.js GM drawArc()用法及代碼示例
- Node.js GM drawPolygon()用法及代碼示例
- Node.js GM drawCircle()用法及代碼示例
- Node.js GM drawBezier()用法及代碼示例
- Node.js GM blur()用法及代碼示例
- Node.js GM drawPolyline()用法及代碼示例
- Node.js GM drawRectangle()用法及代碼示例
- Node.js GM charcoal()用法及代碼示例
注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 Nodejs | GM drawEllipse() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。