【HTML5】——canvas畫奧運五環

在這裏插入圖片描述

思路

先畫在環下面的,如下圖,最後將剩下的全部畫出來
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<canvas id="c1" width="400px" height="400" style="border: 1px solid black;"></canvas>

		<script>
			var c = document.getElementById("c1");
			var ctx = c.getContext("2d");
			ctx.beginPath();
			ctx.arc(150, 150, 50, Math.PI, 0);
			ctx.lineWidth = 5;
			ctx.strokeStyle = "#eecd40";
			ctx.stroke();

			ctx.beginPath();
			ctx.arc(260, 150, 50, Math.PI, 0);
			ctx.lineWidth = 5;
			ctx.strokeStyle = "#198e4a";
			ctx.stroke();

			ctx.beginPath();
			ctx.arc(100, 100, 50, 0, 2 * Math.PI);
			ctx.lineWidth = 5;
			ctx.strokeStyle = "#163b62";
			ctx.stroke();

			ctx.beginPath();
			ctx.arc(210, 100, 50, 0, 2 * Math.PI);
			ctx.lineWidth = 5;
			ctx.strokeStyle = "#000000";
			ctx.stroke();

			ctx.beginPath();
			ctx.arc(320, 100, 50, 0, 2 * Math.PI);
			ctx.lineWidth = 5;
			ctx.strokeStyle = "#bf0628";
			ctx.stroke();

			ctx.beginPath();
			ctx.arc(150, 150, 50, -0.1 * Math.PI, 1.1 * Math.PI);
			ctx.lineWidth = 5;
			ctx.strokeStyle = "#ecc729";
			ctx.stroke();

			ctx.beginPath();
			ctx.arc(260, 150, 50, -0.1 * Math.PI, 1.1 * Math.PI);
			ctx.lineWidth = 5;
			ctx.strokeStyle = "#198e4a";
			ctx.stroke();
		</script>
	</body>
</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章