1、线段样式
<style>
canvas {
width: 500px;
height: 300px;
border: 1px solid;
}
</style>
</head>
<body>
<canvas id="can" width="500px" height="300px"></canvas>
<script>
var canvas = document.getElementById("can");
var ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.lineWidth = 15;
ctx.moveTo(100,100);
ctx.lineTo(200,100);
ctx.lineCap = "square";//square:前后都加小方块;round:两端变圆 butt:默认值
ctx.lineTo(100,150);
ctx.lineJoin = "round";//round:拐点变圆点 bevel:直接砍掉尖 默认:miter 锋锐
ctx.miterLimit = 5;//防止值:防止线段出现的尖过于尖锐,做一个预设值
ctx.stroke();
</script>
</body>