HTML canvas lineJoin Property
Last Updated :
09 Jun, 2023
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.
<!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 >
|
Output:
Example 2: This example illustrates the bevel linejoin property.
<!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 >
|
Output:
Example 3: This example illustrates the round linejoin property.
<!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 >
|
Output:
Supported Browsers: The browser supported by HTML canvas lineJoin property are listed below:
- Google Chrome
- Internet Explorer 9.0
- Firefox
- Safari
- Opera
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...