카테고리 없음

html canvas 예제

OJR 2023. 3. 30. 00:06
Canvas Example

 

 

<!DOCTYPE html>
<html>
<head>
	<title>Canvas Example</title>
	<style>
		canvas {
			border: 1px solid black;
		}
	</style>
</head>
<body>
	<canvas id="myCanvas" width="400" height="400"></canvas>

	<script>
		var canvas = document.getElementById("myCanvas");
		var ctx = canvas.getContext("2d");

		// Draw a red rectangle
		ctx.fillStyle = "red";
		ctx.fillRect(50, 50, 100, 100);

		// Draw a blue circle
		ctx.beginPath();
		ctx.arc(200, 200, 50, 0, 2*Math.PI);
		ctx.fillStyle = "blue";
		ctx.fill();
	</script>
</body>
</html>
반응형