The lineJoin property determines how lines that join one another are drawn.
There are three values:
The default value is miter.
The following code shows the three styles in use.
<!DOCTYPE HTML> <html> <head> <title>Example</title> <style> canvas {border: thin solid black; margin: 4px} </style> </head> <body> <canvas id="canvas" width="500" height="140"> Your browser doesn't support the <code>canvas</code> element </canvas> <script> let ctx = document.getElementById("canvas").getContext("2d"); ctx.lineWidth = 20;// ww w. j a va2 s. co m ctx.lineJoin = "round"; ctx.strokeRect(20, 20, 100, 100); ctx.lineJoin = "bevel"; ctx.strokeRect(160, 20, 100, 100); ctx.lineJoin = "miter"; ctx.strokeRect(300, 20, 100, 100); </script> </body> </html>
In the example above, I have used the lineWidth property so that the strokeRect method will draw rectangles with very thick lines.