如何使用 canvas绘制奥运五环

发布时间:2020-07-21 14:04:10 作者:Leah
来源:亿速云 阅读:326

如何使用 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>

关于如何使用 canvas绘制奥运五环问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

推荐阅读:
  1. HTML5 Canvas标签如何使用
  2. 使用canvas绘制矩形有哪些方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

canvas 奥运

上一篇:拥抱IPv6技术 通往下一代网络

下一篇:流言终结者:大数据工程师真的做不过35岁吗?

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》