h5教程 canvas绘制奥运五环代码分享

 所属分类:web前端开发

 浏览:91次-  评论: 0次-  更新时间:2022-10-27
描述:更多教程资料进入php教程获得。 运行效果:前端(vue)入门到精通课程:进入学习Apipost = Postman + Swagger + Mock + Jmeter 超...
更多教程资料进入php教程获得。 运行效果:

前端(vue)入门到精通课程:进入学习
Apipost = Postman + Swagger + Mock + Jmeter 超好用的API调试工具:点击使用

<!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绘制奥运五环代码分享的详细内容,更多请关注zzsucai.com其它相关文章!

积分说明:注册即送10金币,每日签到可获得更多金币,成为VIP会员可免金币下载! 充值积分充值会员更多说明»

讨论这个素材(0)回答他人问题或分享使用心得奖励金币

〒_〒 居然一个评论都没有……

表情  文明上网,理性发言!