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画图之画圆形的实例介绍

使用canvas设计出一个简易的画板

在html5 canvas中放入图片和保存为图片的方法

canvas橡皮筋式线条绘图的方法介绍(代码示例)

html5中globalcompositeoperation属性的详细介绍

h5canvas绘制五星红旗的实例讲解

html5联合canvas实现图片压缩

canvas如何做出3d动态的chart图表

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

微信小程序-canvas生成图片并保存到本地

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




打赏

取消

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

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

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

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

评论

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