您可以尝试运行以下代码在 html5 画布中绘制椭圆形 -
示例<!doctype html><html> <head> </head> <body> <canvas id="newcanvas" width="450" height="300"></canvas> <script> // canvas var c = document.getelementbyid('newcanvas'); var context = c.getcontext('2d'); var cx = 0; var cy = 0; var radius = 40; context.save(); context.translate(c.width / 2, c.height / 2); context.scale(2, 1); context.beginpath(); context.arc(cx, cy, radius, 0, 2 * math.pi, false); context.restore(); context.fillstyle = '#000000'; context.fill(); context.linewidth = 2; context.strokestyle = 'yellow'; context.stroke(); </script> </body></html>
输出
以上就是如何在html5画布中绘制椭圆?的详细内容。