如何在HTML5画布中绘制椭圆形?
您可以尝试运行以下代码在HTML5画布中绘制椭圆形-
示例
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<canvas id="newCanvas" width="450" height="300"></canvas>
<script>
//画布
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>热门推荐
6 保研的祝福语简短
10 年轻20岁祝福语简短
11 朋友结婚祝福语信息简短
12 女孩婚礼贺卡祝福语简短
13 30段点歌简短祝福语
14 虎年春节祝福语图文简短
15 写给后妈祝福语大全简短
16 简短回复生日祝福语
17 校长送毕业祝福语简短
18 毕业立体贺卡祝福语简短