English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML tag大全

HTML canvas lineJoin attribute

lineJoin is a Canvas 2D API is used to set2How to connect two line segments (line segments, arcs, curves) that are not of length 0 (parts of length 0, whose specified endpoints and control points are at the same position, will be ignored).

HTML canvas Reference Manual

Online Example

When two lines intersect, create a rounded corner:

Your browser does not support HTML5 canvas tag.
<!DOCTYPE html>
<html>
<head>
<title>HTML canvas lineJoin attribute usage (Basic Tutorial Website oldtoolbag.com)</<title>
</<head>
<body>
<canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3>
Your browser does not support HTML5 canvas tag.</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.lineWidth=10;
ctx.lineJoin="round";
ctx.moveTo(20,20);
ctx.lineTo(100,50);
ctx.lineTo(20,100);
ctx.stroke();
</script>
</body>
</html>
Test and see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

Internet Explorer 9Firefox, Opera, Chrome, and Safari support the lineJoin attribute.

Note:Internet Explorer 8 And earlier versions do not support the <canvas> element.

Definition and Usage

When two lines meet, the lineJoin attribute sets or returns the type of corner created.

Note:The "miter" value is affected bymiterLimit The effect of the attribute.

Default Value:miter
JavaScript Syntax:context.lineJoin="bevel|round|miter";

Attribute value

 
ValueDescription
bevelCreate beveled corners.
roundCreate rounded corners.
miterDefault. Create sharp corners.
HTML canvas Reference Manual