HTML | canvas lineJoin Property

The HTML canvas lineJoin property is used to set or return the type of corner created, when two lines meet, by using the lineJoin property. The type of join can have one of three styles: bevel, round, or miter. However, the join style has generally miter style.

Syntax:

context.lineJoin = "bevel|round|miter";

Property Values:

  • miter: It is the default style. This value is used to design a sharp corner.
  • bevel: This design is used to create beveled corner.
  • round: This design is used to create rounded corner.

Example 1: This example illustrates the miter linejoin property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head
    <title
        HTML canvas lineJoin property
    </title
</head
  
<body style="text-align:center;">
      
    <h1 style="color:green"
        GeeksforGeeks 
    </h1
      
    <h2
        HTML canvas lineJoin property
    </h2
      
    <canvas id="canvas" width="350" height="380"></canvas>
      
    <script>
        var can = document.getElementById("canvas");
        var context = can.getContext("2d");
        context.beginPath();
        context.lineWidth = 20;
        context.lineJoin = "miter";
        context.moveTo(80, 250);
        context.lineTo(150, 50);
        context.lineTo(250, 240);
        context.strokeStyle ="green";
        context.stroke();
    </script>
</body>
  
</html>                    

chevron_right


Output:

Example 2: This example illustrates the bevel linejoin property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head
    <title
        HTML canvas lineJoin property
    </title
</head
  
<body style="text-align:center;">
      
    <h1 style="color:green"
        GeeksforGeeks 
    </h1
      
    <h2
        HTML canvas lineJoin property
    </h2
      
    <canvas id="canvas" width="350" height="380"></canvas>
      
    <script>
        var can = document.getElementById("canvas");
        var context = can.getContext("2d");
        context.beginPath();
        context.lineWidth = 20;
        context.lineJoin = "bevel";
        context.moveTo(80, 250);
        context.lineTo(150, 50);
        context.lineTo(250, 240);
        context.strokeStyle ="green";
        context.stroke();
    </script>
</body>
  
</html>                    

chevron_right


Output:

Example 3: This example illustrates the round linejoin property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head
    <title
        HTML canvas lineJoin property
    </title
</head
  
<body style="text-align:center;">
      
    <h1 style="color:green"
        GeeksforGeeks 
    </h1
      
    <h2
        HTML canvas lineJoin property
    </h2
      
    <canvas id="canvas" width="350" height="380"></canvas>
      
    <script>
        var can = document.getElementById("canvas");
        var context = can.getContext("2d");
        context.beginPath();
        context.lineWidth = 20;
        context.lineJoin = "round";
        context.moveTo(80, 250);
        context.lineTo(150, 50);
        context.lineTo(250, 240);
        context.strokeStyle ="green";
        context.stroke();
    </script>
</body>
  
</html>                    

chevron_right


Output:

Supported Browsers: The browser supported by HTML canvas lineJoin property are listed below:

  • Google Chrome
  • Internet Explorer 9.0
  • Firefox
  • Safari
  • Opera


My Personal Notes arrow_drop_up

Budding Web DeveloperKeen learnerAverage CoderDancer&Social Activist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.