canvas绘制奥运五环代码分享


本文摘自PHP中文网,作者巴扎黑,侵删。

运行效果:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

<!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绘制奥运五环代码分享的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

怎样用h5 canvas实现3d动态chart图表

如何利用canvas实现按住鼠标移动绘制出轨迹

html5中canvas的使用--画线和面

canvas实现的骨骼动画

html5 canvas标签是什么意思?canvas标签使用方法介绍

html5 canvas 图形组合是如何实现的?附代码

h5 canvas实现圆形动态加载进度实例

canvas中beginpath()和closepath()的分析总结(附示例)

html5 canvas如何绘制动态径向渐变

canvas怎么使用

更多相关阅读请进入《canvas》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...