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

相关阅读 >>

利用html5中的canvas绘制笑脸的代码

使用html5 canvas api中的clip()方法裁剪区域图像代码实例

html5 canvas学习的实例介绍

html5+canvas调用手机拍照功能实现图片上传功能(图文详解上篇)

canvas绘制工作流之绘制节点

html5 canvas实现粒子时钟的示例代码

js html5 canvas绘制图片的方法

canvas如何实现二维码和图片合成的代码

html5 canvas基本绘图之绘制矩形

如何使用html5 canvas绘制文字的轮廓

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




打赏

取消

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

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

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

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

评论

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