summaryrefslogtreecommitdiff
path: root/examples/script/context2d/scripts/linecap.js
blob: 18ceb2353b06a09d7f1465d1e10f9ee33fa3dd78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var ctx = document.getElementById('tutorial').getContext('2d');
  var lineCap = ['butt','round','square'];

  // Draw guides
  ctx.save();
  ctx.strokeStyle = '#09f';
  ctx.beginPath();
  ctx.moveTo(10,10);
  ctx.lineTo(140,10);
  ctx.moveTo(10,140);
  ctx.lineTo(140,140);
  ctx.stroke();

  // Draw lines
  ctx.strokeStyle = 'black';
  for (i=0;i<lineCap.length;i++){
    ctx.lineWidth = 15;
    ctx.lineCap = lineCap[i];
    ctx.beginPath();
    ctx.moveTo(25+i*50,10);
    ctx.lineTo(25+i*50,140);
    ctx.stroke();
  }
  ctx.restore();