用html5画动态太极图
admin
2023-06-11 22:41:57
0
  1. >  
  2. <html>  
  3. <body>  
  4.   
  5. <canvas id="myCanvas"  width="500" height="500" >your browser does not support the canvas tag canvas>  
  6.   
  7.  <script type="text/javascript">   
  8.     var deg = 0;  
  9.     var r = 30;  
  10.     var rl = 100;  
  11. function drawTaiji() { 
  12. var canvas = document.getElementById('myCanvas'); 
  13. var context = canvas.getContext('2d'); 
  14. var colorA = "rgb(0, 0, 0)"
  15. var colorB = "red"
  16.  
  17. var px =Math.sin(deg)*r; 
  18. var py =Math.cos(deg)*r; 
  19. context.clearRect(0, 0, 300, 300); 
  20. context.beginPath(); 
  21. context.fillStyle = colorA
  22. context.arc(rl, rl, 60, 0.5 * Math.PI +deg, 1.5 * Math.PI +deg, true); 
  23. context.closePath(); 
  24. context.fill(); 
  25. context.fillStyle = colorB
  26. context.beginPath(); 
  27. context.arc(rl, rl, 60, 1.5* Math.PI +deg, 0.5 * Math.PI +deg, true); 
  28. context.closePath(); 
  29. context.fill(); 
  30. context.fillStyle = colorB
  31. context.beginPath(); 
  32. context.arc(rl+px, rl-py, 30, 0.5 * Math.PI + deg, 1.5 * Math.PI + deg, true); 
  33. context.closePath(); 
  34. context.fill(); 
  35. context.fillStyle = colorA
  36. context.beginPath(); 
  37. context.arc(rl-px, rl+py, 30, 1.5 * Math.PI + deg, 0.5 * Math.PI + deg, true); 
  38. context.closePath(); 
  39. context.fill(); 
  40. context.fillStyle = colorA
  41. context.beginPath(); 
  42. context.arc(rl+px, rl-py, 8, 0, 2 * Math.PI, true); 
  43. context.closePath(); 
  44. context.fill(); 
  45. context.fillStyle = colorB
  46. context.beginPath(); 
  47. context.arc(rl-px, rl+py, 8, 0, 2 * Math.PI, true); 
  48. context.closePath(); 
  49. context.fill(); 
  50. deg +=0.1; 
  51. }  
  52. setInterval(drawTaiji, 100);
  53.  script>   
  54.   
  55. body>  
  56. html>  


 

用html5画动态太极图

  1. >   
  2. <html>   
  3. <body>   
  4.    
  5. <canvas id="myCanvas"  width="500" height="500" >your browser does not support the canvas tag canvas>   
  6.    
  7.  <script type="text/javascript">    
  8. var canvas = document.getElementById('myCanvas'); 
  9. var ctx = canvas.getContext("2d"); 
  10. var angle = 0
  11. var count = 360
  12. var clrA = '#000'
  13. var clrB = 'red'
  14.  
  15. function taiji(x, y, radius, angle, wise) { 
  16.     angleangle = angle || 0; 
  17.     wisewise = wise ? 1 : -1; 
  18.     ctx.save(); 
  19.     ctx.translate(x, y); 
  20.     ctx.rotate(angle); 
  21.     ctx.fillStyle = clrA
  22.     ctx.beginPath(); 
  23.     ctx.arc(0, 0, radius, 0, Math.PI, true); 
  24.     ctx.fill(); 
  25.     ctx.beginPath(); 
  26.     ctx.fillStyle = clrB
  27.     ctx.arc(0, 0, radius, 0, Math.PI, false); 
  28.     ctx.fill(); 
  29.     ctx.fillStyle = clrB
  30.     ctx.beginPath(); 
  31.     ctx.arc(wise * -0.5 * radius, 0, radius / 2, 0, Math.PI * 2, true); 
  32.     ctx.fill(); 
  33.     ctx.beginPath(); 
  34.     ctx.fillStyle = clrA
  35.     ctx.arc(wise * +0.5 * radius, 0, radius / 2, 0, Math.PI * 2, false); 
  36.     ctx.arc(wise * -0.5 * radius, 0, radius / 10, 0, Math.PI * 2, true); 
  37.     ctx.fill(); 
  38.     ctx.beginPath(); 
  39.     ctx.fillStyle = clrB
  40.     ctx.arc(wise * +0.5 * radius, 0, radius / 10, 0, Math.PI * 2, true); 
  41.     ctx.fill(); 
  42.     ctx.restore(); 
  43.  
  44. loop = setInterval(function () { 
  45.     beginTag = true
  46.     ctx.clearRect(0, 0, canvas.width, canvas.height); 
  47.     taiji(200, 200, 50, Math.PI * (angle / count) * 2, true); 
  48.     //taiji(350, 350, 50, Math.PI * ((count - angle) / count) * 2, false); 
  49.     angle = (angle + 5) % count; 
  50. }, 50); 
  51.  
  52.  script>    
  53.    
  54. body>   
  55. html>   

出自:http://www.cnblogs.com/iamzhanglei/archive/2012/03/27/2419268.html

 

相关内容

热门资讯

俄方称将对基辅军工联合体发动打... △基辅(资料图)当地时间25日,俄罗斯外交部发布通报称,俄军将对乌克兰首都基辅的军工联合体发动一系列...
深耕特色兴实业 因地制宜谱新篇 近期,全国各地立足资源禀赋、深耕产业赛道,处处涌动着产业升级、增收致富的蓬勃生机。 向新攀登 河南跑...
荣耀600全系搭载教科书级护眼... 快科技5月25日消息,荣耀600系列于今晚正式发布,全系配备教科书级护眼屏。 据悉,荣耀600系列首...
近万“青鸟”上街参加挺军购游行... 海峡导报综合报道 为抗议在野阵营通过7800亿元(新台币,下同)特别预算,台湾亲绿民团23日下午发起...
华为公布半导体领域重大突破 5月25日,2026国际电路与系统研讨会在上海举行,华为公司董事、半导体业务部总裁何庭波在题为《半导...
全焦段4K实况照片+8000m... 一、前言:全能无短板!荣耀600 Pro闪亮登场 现如今的中高端手机市场,可以说是卷得五花八门。大家...
强烈信号,家长们现在要连夜排队... 北京家长凌晨3点排队,只为孩子能上个中职学校。5月10日这天,是北京昌平职业技术学校自主招生面试日:...
自主选课+实战赋能,北京地铁公... 5月25日,据北京地铁公司消息,为精准破解员工岗位实训短板、满足个性化成长需求,近期北京地铁公司优化...
荣耀600 Pro测评:“销量... 荣耀的数字系列是一款典型的“销量大于网上声量”的产品。 在过去这些年,荣耀的数字系列一直都是3000...
美团、腾讯参投!机器人公司天机... 图片来源:广东天机智能系统有限官网 5月25日,天机机器人公众号发布消息称,广东天机智能系统有限公司...