资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

用html5画动态太极图-创新互联

  1. your browser does not support the canvas tag 
  2.  
  3.     var deg = 0;
  4.     var r = 30;
  5.     var rl = 100;
  6. function drawTaiji() {
  7. var canvas = document.getElementById('myCanvas');
  8. var context = canvas.getContext('2d');
  9. var colorA = "rgb(0, 0, 0)";
  10. var colorB = "red";
  11. var px =Math.sin(deg)*r;
  12. var py =Math.cos(deg)*r;
  13. context.clearRect(0, 0, 300, 300);
  14. context.beginPath();
  15. context.fillStyle = colorA;
  16. context.arc(rl, rl, 60, 0.5 * Math.PI +deg, 1.5 * Math.PI +deg, true);
  17. context.closePath();
  18. context.fill();
  19. context.fillStyle = colorB;
  20. context.beginPath();
  21. context.arc(rl, rl, 60, 1.5* Math.PI +deg, 0.5 * Math.PI +deg, true);
  22. context.closePath();
  23. context.fill();
  24. context.fillStyle = colorB;
  25. context.beginPath();
  26. context.arc(rl+px, rl-py, 30, 0.5 * Math.PI + deg, 1.5 * Math.PI + deg, true);
  27. context.closePath();
  28. context.fill();
  29. context.fillStyle = colorA;
  30. context.beginPath();
  31. context.arc(rl-px, rl+py, 30, 1.5 * Math.PI + deg, 0.5 * Math.PI + deg, true);
  32. context.closePath();
  33. context.fill();
  34. context.fillStyle = colorA;
  35. context.beginPath();
  36. context.arc(rl+px, rl-py, 8, 0, 2 * Math.PI, true);
  37. context.closePath();
  38. context.fill();
  39. context.fillStyle = colorB;
  40. context.beginPath();
  41. context.arc(rl-px, rl+py, 8, 0, 2 * Math.PI, true);
  42. context.closePath();
  43. context.fill();
  44. deg +=0.1;
  45. }
  46. setInterval(drawTaiji, 100);
  47.  

用html5画动态太极图

成都创新互联公司,专注为中小企业提供官网建设、营销型网站制作、成都响应式网站建设、展示型成都网站制作、成都做网站等服务,帮助中小企业通过网站体现价值、有效益。帮助企业快速建站、解决网站建设与网站营销推广问题。
  1. your browser does not support the canvas tag 
  2.  
  3. var canvas = document.getElementById('myCanvas');
  4. var ctx = canvas.getContext("2d");
  5. var angle = 0;
  6. var count = 360;
  7. var clrA = '#000';
  8. var clrB = 'red';
  9. function taiji(x, y, radius, angle, wise) {
  10.     angleangle = angle || 0;
  11.     wisewise = wise ? 1 : -1;
  12.     ctx.save();
  13.     ctx.translate(x, y);
  14.     ctx.rotate(angle);
  15.     ctx.fillStyle = clrA;
  16.     ctx.beginPath();
  17.     ctx.arc(0, 0, radius, 0, Math.PI, true);
  18.     ctx.fill();
  19.     ctx.beginPath();
  20.     ctx.fillStyle = clrB;
  21.     ctx.arc(0, 0, radius, 0, Math.PI, false);
  22.     ctx.fill();
  23.     ctx.fillStyle = clrB;
  24.     ctx.beginPath();
  25.     ctx.arc(wise * -0.5 * radius, 0, radius / 2, 0, Math.PI * 2, true);
  26.     ctx.fill();
  27.     ctx.beginPath();
  28.     ctx.fillStyle = clrA;
  29.     ctx.arc(wise * +0.5 * radius, 0, radius / 2, 0, Math.PI * 2, false);
  30.     ctx.arc(wise * -0.5 * radius, 0, radius / 10, 0, Math.PI * 2, true);
  31.     ctx.fill();
  32.     ctx.beginPath();
  33.     ctx.fillStyle = clrB;
  34.     ctx.arc(wise * +0.5 * radius, 0, radius / 10, 0, Math.PI * 2, true);
  35.     ctx.fill();
  36.     ctx.restore();
  37. }
  38. loop = setInterval(function () {
  39.     beginTag = true;
  40.     ctx.clearRect(0, 0, canvas.width, canvas.height);
  41.     taiji(200, 200, 50, Math.PI * (angle / count) * 2, true);
  42.     //taiji(350, 350, 50, Math.PI * ((count - angle) / count) * 2, false);
  43.     angle = (angle + 5) % count;
  44. }, 50);
  45.  

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

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


新闻名称:用html5画动态太极图-创新互联
链接分享:http://cdkjz.cn/article/dghhsd.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220