H5画布绘制透明圆环
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>透明圆环</title>
<style>
#myCanvas {
box-shadow: 0 0 5px black;
margin-top: 50px;
margin-left: 50px;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="500px" height="500px"></canvas>
</body>
<script>
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "orange";
ctx.fillRect(0, 0, 250, 250);
ctx.fillStyle = "#ADFE2F";
ctx.fillRect(250, 0, 250, 250);
ctx.fillStyle = "red";
ctx.fillRect(0, 250, 250, 250);
ctx.fillStyle = "skyblue";
ctx.fillRect(250, 250, 250, 250);
ctx.fillStyle = "white";
ctx.globalAlpha = 0.2;
for(var i=0;i<10;i++) {
ctx.beginPath();
ctx.arc(250, 250, 25 + 25*i, 0, Math.PI*2, false);
ctx.fill();
}
</script>
</html>