<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>用canvas画太极图</title>
<style>
* {
margin: 0;
padding: 0;
}
canvas {
margin-left: -5px;
}
canvas:hover {
transform: rotate(3600deg);
transition: all 10s linear;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="500" height="500">
您的浏览器不支持 HTML5 canvas 标签。
</canvas>
<script>
var mc = document.getElementById("myCanvas");
var ctx = mc.getContext("2d");
//绘制太极图
ctx.arc(250,250,200,0,Math.PI*2);
ctx.fill();
ctx.beginPath();
ctx.arc(250,250,200,-Math.PI/2,Math.PI/2);
ctx.fillStyle="#fff";
ctx.fill();
ctx.beginPath();
ctx.arc(250,150,100,0,Math.PI*2);
ctx.fillStyle="#000";
ctx.fill();
ctx.beginPath();
ctx.arc(250,350,100,0,Math.PI*2);
ctx.fillStyle="#fff";
ctx.fill();
ctx.beginPath();
ctx.arc(250,150,30,0,Math.PI*2);
ctx.fillStyle="#fff";
ctx.fill();
ctx.beginPath();
ctx.arc(250,350,30,0,Math.PI*2);
ctx.fillStyle="#000";
ctx.fill();
ctx.beginPath();
</script>
</body>
</html>
canvas实现 旋转太极图(第一发)
最新推荐文章于 2021-07-01 08:29:28 发布