lineJoin property

The lineJoin property determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together (degenerate segments with zero lengths, whose specified endpoints and control points are exactly at the same position, are skipped).
There are three possible values for this property: round, bevel and miter. By default this property is set to miter. Note that the lineJoin setting has no effect if the two connected segments have the same direction, because no joining area will be added in this case.


        <title>Canvas tutorial</title>
            function draw(){
                var ctx = document.getElementById('canvas').getContext('2d');
                var lineJoin = ['round', 'bevel', 'miter'];
                ctx.lineWidth = 10;
                for (var i = 0; i < lineJoin.length; i++) {
                    ctx.lineJoin = lineJoin[i];
                    ctx.moveTo(-5, 5 + i * 40);
                    ctx.lineTo(35, 45 + i * 40);
                    ctx.lineTo(75, 5 + i * 40);
                    ctx.lineTo(115, 45 + i * 40);
                    ctx.lineTo(155, 5 + i * 40);
    <body onload="draw();">
        <canvas id="canvas" width="200" height="200">

You may also like...