0
어떻게하면이 코드에 수평으로 여러 개의 원을 그릴 수 있습니까? 나는 루프를 시도했지만 아무 소용이 없다.여러 개의 원을 가로로 그리기 HTML5
<!doctype html>
<html>
<head>
<title> Draw circle </title>
<body>
<canvas id="myCanvas" width="500" height="300" style="border:solid 2px white;">
</canvas>
<script>
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
function draw_circle (circleX, circleY, radius, fill) {
context.fillStyle = "black";
context.fillRect(0, 0, 500, 300);
context.strokeStyle = "red";
context.strokeRect(5, 5, 490, 290);
context.fillStyle = fill;
context.arc(circleX, circleY, radius, 0, Math.PI*2);
context.fill();
}
draw_circle(100, 100, 30 , "cyan");
</script>
</body>
</html>
귀하의'draw_circle' 함수가 호출 될 때 검은 색마다와 캔버스를 작성한다. 해당 코드는 한 번만 실행해야합니다. – EvilZebra
알겠습니다. 고쳐 주셔서 감사합니다. – Drew