代码
提交代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>慕课网Wiki</title>
<style>
#imooc{
border:1px solid #ccc;
}
</style>
</head>
<body>
<canvas id="imooc">您的浏览器不支持 HTML5 canvas 标签</canvas>
<script>
const canvas = document.getElementById('imooc');
canvas.width=600
canvas.height=300
const ctx = canvas.getContext('2d');
ctx.strokeStyle="#456795";
ctx.lineWidth=8;
ctx.arc(150, 150, 100, 0, 1*Math.PI, false); // 绘制半圆,传递了第六个参数为 true
ctx.closePath()
ctx.stroke();
ctx.beginPath();
ctx.arc(450, 150, 100, 0, 1*Math.PI, true); // 绘制半圆,传递了第六个参数为 true
ctx.closePath()
ctx.stroke();
</script>
</body>
</html>
运行结果