strokeStyle 속성
strokeStyle 속성은 캔버스에 그릴 때 선의 색상을 설정합니다.
속성 값으로는 모든 CSS
색상 단위를 사용할 수 있습니다.
문법
컨텍스트.strokeStyle = 색상;
예제
rect 메서드를 사용하여 윤곽선을 그리고
빨간색으로 칠해 봅시다:
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
let canvas = document.querySelector('#canvas');
let ctx = canvas.getContext('2d');
ctx.rect(50, 50, 100, 100);
ctx.strokeStyle = 'red';
ctx.stroke();
:
함께 보기
-
도형의 채우기 색상을 설정하는 메서드
fillStyle