Canvas实现太极图案并旋转
来源:互联网 发布:linux 系统编程delay 编辑:程序博客网 时间:2024/05/16 06:19
效果如下:
<!DOCTYPE HTML>
<html><body>
<canvas id="myCanvas" width="500" height="500" >your browser does not support the canvas tag </canvas>
<script type="text/javascript">
var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext("2d");
var angle = 0;
var count = 360;
var clrA = '#000';
var clrB = 'red';
function taiji(x, y, radius, angle, wise) {
angleangle = angle || 0;
wisewise = wise ? 1 : -1;
ctx.save();
ctx.translate(x, y);
ctx.rotate(angle);
ctx.fillStyle = clrA;
ctx.beginPath();
ctx.arc(0, 0, radius, 0, Math.PI, true);
ctx.fill();
ctx.beginPath();
ctx.fillStyle = clrB;
ctx.arc(0, 0, radius, 0, Math.PI, false);
ctx.fill();
ctx.fillStyle = clrB;
ctx.beginPath();
ctx.arc(wise * -0.5 * radius, 0, radius / 2, 0, Math.PI * 2, true);
ctx.fill();
ctx.beginPath();
ctx.fillStyle = clrA;
ctx.arc(wise * +0.5 * radius, 0, radius / 2, 0, Math.PI * 2, false);
ctx.arc(wise * -0.5 * radius, 0, radius / 10, 0, Math.PI * 2, true);
ctx.fill();
ctx.beginPath();
ctx.fillStyle = clrB;
ctx.arc(wise * +0.5 * radius, 0, radius / 10, 0, Math.PI * 2, true);
ctx.fill();
ctx.restore();
}
loop = setInterval(function () {
beginTag = true;
ctx.clearRect(0, 0, canvas.width, canvas.height);
taiji(200, 200, 50, Math.PI * (angle / count) * 2, true);
//taiji(350, 350, 50, Math.PI * ((count - angle) / count) * 2, false);
angle = (angle + 5) % count;
}, 50);
</script> </p> <p></body>
</html>
0 0
- Canvas实现太极图案并旋转
- Canvas绘制旋转太极
- HTML5 Canvas组件绘制太极图案
- HTML5利用canvas绘制太极图案
- JavaScript中canvas绘制太极图案
- css3实现太极旋转
- Demo13:div实现太极旋转
- HTML5实现旋转的太极
- verilogVGA显示太极图案
- 使用HTML5 Canvas绘制一个太极,并令其转动
- Java实现的一个旋转效果(旋转太极)
- 自定义view绘制太极图案
- canvas实现旋转联动
- canvas经典太极
- canvas画太极
- 旋转的太极
- 旋转的太极
- 自定义View-太极旋转
- #51 Codeforces-E. Very simple problem (计算几何)(点被多少个三角形包含)
- error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class Stude
- 十一.MUI
- SSD: Single Shot MultiBox Detector论文阅读
- Spring MVC国际化——基于Session的国际化
- Canvas实现太极图案并旋转
- CentOS release 6.6 (64bit)升级GCC到4.8.2版本
- Disconf
- C++:引用作为返回值
- 数据结构&算法
- 算法设计Week8 LeetCode Algorithms Problem #70 Climbing Stairs
- 字符串和编码
- Spring mvc 拦截器
- 大神博客集合