<canvas id="mycanvas" width="150" height="100"></canvas> | |
<script type = 'text/javascript'> | |
var canvas = document.getElementById('mycanvas'); | |
var ctx = canvas.getContext('2d'); | |
ctx.lineWidth = 20; | |
// Checking whether straight lines with empty length have proper line caps | |
ctx.lineCap = 'round'; | |
ctx.beginPath(); | |
ctx.moveTo(50, 50); | |
ctx.lineTo(50, 50); | |
ctx.stroke(); | |
ctx.lineCap = 'square'; | |
ctx.beginPath(); | |
ctx.moveTo(100, 50); | |
ctx.lineTo(100, 50); | |
ctx.stroke(); | |
</script> |