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

相关阅读 >>

javascript canvas方法有哪些

html5中的canvas 和 svg分别是什么?它们的区别在何处?(实例)

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

canvas与h5如何实现视频截图功能

htmlcanvas矩形阵雨

canvas绘制各种基本图形

canvas实现波浪进度图(附demo)

html5 canvas基本绘图之绘制矩形

canvas绘制饼图的方法介绍(代码)

js html5 canvas绘制图片的方法

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




打赏

取消

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

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

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

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

评论

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

    暂无评论...