English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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).
When two lines intersect, create a rounded corner:
<!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 ‹/›
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.
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"; |
Value | Description |
---|---|
bevel | Create beveled corners. |
round | Create rounded corners. |
miter | Default. Create sharp corners. |