canvas绘制奥运五环代码分享

互联网 17-7-18
运行效果:

<!DOCTYPE html>  <html>  <head>  </head>  <body>  <canvas id="drawing" width="800" height="600">A drawing of someing!</canvas>      <script type="text/javascript">var drawing = document.getElementById('drawing');if(drawing.getContext) {//绘制奥运五环,画圆var context = drawing.getContext('2d');              context.lineWidth = 7;              context.strokeStyle = '#0180C3';              context.beginPath();              context.arc(70, 70, 40, 0, 2*Math.PI, false);              context.stroke();              context.strokeStyle = '#000';              context.beginPath();              context.arc(160, 70, 40, 0, 2*Math.PI, false);              context.stroke();              context.strokeStyle = '#BF0628';              context.beginPath();              context.arc(250, 70, 40, 0, 2*Math.PI, false);              context.stroke();              context.strokeStyle = '#EBC41F';              context.beginPath();              context.arc(115, 110, 40, 0, 2*Math.PI, false);              context.stroke();              context.strokeStyle = '#198E4A';              context.beginPath();              context.arc(205, 110, 40, 0, 2*Math.PI, false);              context.stroke();//环环相扣,画弧(实现相关圆弧的覆盖)context.strokeStyle = '#0180C3';              context.beginPath();              context.arc(70, 70, 40, 1.9*Math.PI, 2.1*Math.PI, false);              context.stroke();              context.strokeStyle = '#000';              context.beginPath();              context.arc(160, 70, 40, 1.9*Math.PI, 2.1*Math.PI, false);              context.stroke();              context.beginPath();              context.arc(160, 70, 40, 0.5*Math.PI, 0.7*Math.PI, false);              context.stroke();              context.strokeStyle = '#BF0628';              context.beginPath();              context.arc(250, 70, 40, 0.5*Math.PI, 0.7*Math.PI, false);              context.stroke();          }</script>  </body>  </html>

以上就是 canvas绘制奥运五环代码分享的详细内容,更多内容请关注技术你好其它相关文章!

来源链接:
免责声明:
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场
标签: 周一
上一篇:php获取远程图片并下载保存到本地的方法分析 下一篇:h5页面如何调用摄像头代码分享

相关资讯