Create a rounded corner when the two lines meet:
<!DOCTYPE html> <html> <body> <canvas id="myCanvas" width="300" height="180" style="border:1px solid #d3d3d3;"> Your browser does not support the HTML5 canvas tag.</canvas> <script> var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.beginPath();/*from www. ja v a 2 s. c om*/ ctx.lineWidth = 10; ctx.lineJoin = "round"; ctx.moveTo(20, 20); ctx.lineTo(100, 50); ctx.lineTo(20, 100); ctx.stroke(); </script> </body> </html>
The lineJoin property sets or gets the type of corner created, when two lines meet.
The "miter" value is affected by the miterLimit property.
The lineJoin property Default value: miter
context.lineJoin = "bevel|round|miter";
Property Values
Value | Description |
---|---|
bevel | Creates a beveled corner |
round | Creates a rounded corner |
miter | Default. Creates a sharp corner |