- HTML5 캔버스 삼각형 그리기
1 예제1: 채우기(fill)[ | ]
html
Copy
<canvas id="my-canvas" width="120" height="120"></canvas>
<script>
var ctx = document.getElementById("my-canvas").getContext("2d");
ctx.beginPath();
ctx.moveTo(10,10);
ctx.lineTo(10,100);
ctx.lineTo(100,100);
ctx.closePath();
ctx.fillStyle="hotpink";
ctx.fill();
</script>
2 예제2: 외곽선(stroke)[ | ]
html
Copy
<canvas id="my-canvas" width="120" height="120"></canvas>
<script>
var ctx = document.getElementById("my-canvas").getContext("2d");
ctx.beginPath();
ctx.moveTo(10,10);
ctx.lineTo(10,100);
ctx.lineTo(100,100);
ctx.closePath();
ctx.strokeStyle="hotpink";
ctx.stroke();
</script>
3 같이 보기[ | ]
편집자 175.125.196.32 Jmnote 14.47.99.164 Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.