为了账号安全,请及时绑定邮箱和手机立即绑定

HTML5画布CANVAS动画。

HTML5画布CANVAS动画。

qq_控心_0 2016-03-29 19:09:30
就剩那两个大半圆不知道怎么用代码表示了,求大神给看下,怎么设置的才可以以自己的圆心来转。实现旋转的八卦。不能上传视频,有个转的过程图,在最下面。<!DOCTYPE HTML><html> <head> <meta charset="utf-8"> <title></title> </head><body><canvas id="myCanvas" width="500" height="500">your browser does not support the canvas tag</canvas><script type="text/javascript"> var deg1=0.0; var deg2=0.0; var deg3=0.0; var deg4=0.0; var deg5=0.0; var deg6=0.0; setInterval(drawCircle,40); function drawCircle() { var canvas = document.getElementById('myCanvas'); var context = canvas.getContext('2d'); context.clearRect(0, 0, 500, 500); context.beginPath(); context.fillStyle = "black"; var px =Math.sin(deg5)*100; var py =Math.cos(deg5)*100; context.arc(300+px,300-py,200,1.5*Math.PI,0.5*Math.PI,true); context.fill(); deg5 +=0.05;   //黑色大半圆 context.beginPath(); context.fillStyle = "red"; var px =Math.sin(deg6)*100; var py =Math.cos(deg6)*100; context.arc(300+px,300-py,200,0.5*Math.PI,1.5*Math.PI,true); context.fill(); deg6 +=0.05;   //红色大半圆 context.beginPath(); context.fillStyle = "red"; var px =Math.sin(deg4)*100; var py =Math.cos(deg4)*100; context.arc(300-px,300+py,100,0,2*Math.PI,true); context.fill(); deg4 +=0.05;  //红色中圆 context.beginPath(); context.fillStyle = "black"; var px =Math.sin(deg2)*100; var py =Math.cos(deg2)*100; context.arc(300-px,300+py,25,0,2*Math.PI,true); context.fill(); deg2 +=0.05;  //黑色中圆 context.beginPath(); context.fillStyle = "black"; var px =Math.sin(deg3)*100; var py =Math.cos(deg3)*100; context.arc(300+px,300-py,100,0,2*Math.PI,true); context.fill(); deg3 +=0.05;  // 黑色小圆 context.beginPath(); context.fillStyle = "red"; var px =Math.sin(deg1)*100; var py =Math.cos(deg1)*100; context.arc(300+px,300-py,25,0,2*Math.PI,true); context.fill(); deg1 +=0.05;  //红色小圆 }</script></body></html>
查看完整描述

1 回答

?
qq_控心_0

TA贡献4条经验 获得超0个赞

已经知道了。嘿嘿。

查看完整回答
反对 回复 2016-03-30
  • 1 回答
  • 0 关注
  • 1640 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信