思路
先画在环下面的,如下图,最后将剩下的全部画出来
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<canvas id="c1" width="400px" height="400" style="border: 1px solid black;"></canvas>
<script>
var c = document.getElementById("c1");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(150, 150, 50, Math.PI, 0);
ctx.lineWidth = 5;
ctx.strokeStyle = "#eecd40";
ctx.stroke();
ctx.beginPath();
ctx.arc(260, 150, 50, Math.PI, 0);
ctx.lineWidth = 5;
ctx.strokeStyle = "#198e4a";
ctx.stroke();
ctx.beginPath();
ctx.arc(100, 100, 50, 0, 2 * Math.PI);
ctx.lineWidth = 5;
ctx.strokeStyle = "#163b62";
ctx.stroke();
ctx.beginPath();
ctx.arc(210, 100, 50, 0, 2 * Math.PI);
ctx.lineWidth = 5;
ctx.strokeStyle = "#000000";
ctx.stroke();
ctx.beginPath();
ctx.arc(320, 100, 50, 0, 2 * Math.PI);
ctx.lineWidth = 5;
ctx.strokeStyle = "#bf0628";
ctx.stroke();
ctx.beginPath();
ctx.arc(150, 150, 50, -0.1 * Math.PI, 1.1 * Math.PI);
ctx.lineWidth = 5;
ctx.strokeStyle = "#ecc729";
ctx.stroke();
ctx.beginPath();
ctx.arc(260, 150, 50, -0.1 * Math.PI, 1.1 * Math.PI);
ctx.lineWidth = 5;
ctx.strokeStyle = "#198e4a";
ctx.stroke();
</script>
</body>
</html>