HTML canvas miterLimit Property |
-- Learning is not just about technology, but also about dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
JavaScript Reference Manual
JavaScript Objects
- JavaScript Array Object
- JavaScript Boolean Object
- JavaScript Date Object
- JavaScript Math Object
- JavaScript Number Object
- JavaScript String Object
- JavaScript RegExp Object
- JavaScript Global Properties/Functions
- JavaScript Operators
- JavaScript Error
Browser Objects
DOM Objects
- HTML DOM Document Object
- HTML DOM Element Object
- HTML DOM Attribute Object
- HTML DOM Event Object
- HTML DOM Console Object
- CSSStyleDeclaration Object
- DOM HTMLCollection
HTML Objects
- <a>
- <area>
- <audio>
- <base>
- <blockquote>
- <body>
- <button>
- <canvas>
- <col>
- <colgroup>
- <datalist>
- <del>
- <details>
- <dialog>
- <embed>
- <fieldset>
- <form>
- <iframe>
- <frameset >
- <img>
- <ins>
- <input> - button
- <input> - checkbox
- <input> - color
- <input> - date
- <input> - datetime
- <input> - datetime-local
- <input> - email
- <input> - file
- <input> - hidden
- <input> - image
- <input> - month
- <input> - number
- <input> - range
- <input> - password
- <input> - radio
- <input> - reset
- <input> - search
- <input> - submit
- <input> - text
- <input> - time
- <input> - url
- <input> - week
- <keygen>
- <link>
- <label>
- <legend>
- <li>
- <map>
- <menu>
- <menuItem>
- <meta>
- <meter>
- <object>
- <ol>
- <optgroup>
- <option>
- <param>
- <progress>
- <q>
- <script>
- <select>
- <source>
- <style>
- <table>
- <td>
- <th>
- <tr>
- <textarea>
- <title>
- <time>
- <track>
- <video>
Deep Dive
- Scripting Languages
- Programming Languages
- Development Tools
- Web Services
- Computer Science
- Software
- Web Design and Development
- Scripting
- Programming
- Web Service
HTML canvas miterLimit Property
Example
Draw lines with a maximum miter length of 5:
Your browser does not support the HTML5 canvas tag.JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.lineWidth=10;
ctx.lineJoin="miter";
ctx.miterLimit=5;
ctx.moveTo(20,20);
ctx.lineTo(50,27);
ctx.lineTo(20,34);
ctx.stroke();
Browser Support
The miterLimit property is supported in Internet Explorer 9, Firefox, Opera, Chrome, and Safari.
Note: Internet Explorer 8 and earlier versions do not support the <canvas> element.
Definition and Usage
The miterLimit property sets or returns the maximum miter length.
The miter length refers to the distance between the inner corner and the outer corner where two lines meet.
Note: The miterLimit property is only effective when the lineJoin property is set to "miter".
The smaller the angle of the corner, the larger the miter length will be.
To avoid the miter length becoming _too long_, we can use the miterLimit property.
If the miter length exceeds the value of miterLimit, the corner will be displayed using the "bevel" type of lineJoin (Fig 3):
| Default value: | 10 |
| JavaScript syntax: | context.miterLimit=number; |
Property Values
| Value | Description |
|---|---|
| number | A positive number. Specifies the maximum miter length. If the miter length exceeds the value of miterLimit, the corner will be displayed using the "bevel" type of lineJoin. |
YouTip