http://www.html5canvastutorials.com/tutorials/html5-canvas-line-caps/
html5 canvas line에 cap을 추가 할 수 있다.
cap은 다음 셋중 하나를 선택할 수 있다; butt, round, square.
context.lineCap=[value];
아래 링크로 예제를 확인 할 수 있다.
http://www.html5canvastutorials.com/demos/tutorials/html5_canvas_line_caps/
window.onload = function(){ var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); // butt line cap (top line) context.beginPath(); context.moveTo(200, canvas.height / 2 - 50); context.lineTo(canvas.width - 200, canvas.height / 2 - 50); context.lineWidth = 20; context.strokeStyle = "#0000ff"; // line color context.lineCap = "butt"; context.stroke(); // round line cap (middle line) context.beginPath(); context.moveTo(200, canvas.height / 2); context.lineTo(canvas.width - 200, canvas.height / 2); context.lineWidth = 20; context.strokeStyle = "#0000ff"; // line color context.lineCap = "round"; context.stroke(); // square line cap (bottom line) context.beginPath(); context.moveTo(200, canvas.height / 2 + 50); context.lineTo(canvas.width - 200, canvas.height / 2 + 50); context.lineWidth = 20; context.strokeStyle = "#0000ff"; // line color context.lineCap = "square"; context.stroke(); };
'프로그래밍 > HTML5' 카테고리의 다른 글
모바일 웹에서 확대 기능 막기, 사이즈 고정하기 (1) | 2012.01.11 |
---|---|
1.2.3 HTML5 Canvas Line Color Tutorial (0) | 2012.01.09 |
1.2.2 HTML5 Canvas line width ( 선 너비 / 굵기 ) 튜토리얼 (0) | 2012.01.09 |
1.2.1 HTML5 Canvas Line Tutorial (0) | 2012.01.09 |
1.1.1 HTML5 Canvas Element Tutorial (0) | 2012.01.09 |