您好,欢迎来到划拓汽车网。
搜索
您的当前位置:首页canvas绘制奥运五环代码分享

canvas绘制奥运五环代码分享

来源:划拓汽车网
 运行效果:

<!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>

Copyright © 2019- huatuoask.net 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务