HTML canvas miterLimit attribute

Definition and Usage

miterLimit Sets or returns the maximum bevel length.

The bevel length refers to the distance between the inner and outer angles at the intersection of two lines.

Tip:Only when the lineJoin attribute is "miter" is valid.

The smaller the angle of the corner, the longer the bevel length will be.

To avoid excessively long bevel lengths, we can use the miterLimit property.

If the bevel length exceeds the value of miterLimit, the corners will be rounded with the lineJoin attribute "bevel" type to display (Illustration 3):

Example

With the maximum bevel length of 5 draw lines:

Your browser does not support the 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();

Kokeile itse

Syntaksi

context.miterLimit=number;

Omistussuhde

Arvo Kuvaus
number

Luku. Määrittää suurimman terävän kulman pituuden.

Jos terävän kulman pituus ylittää miterLimit-arvon, reunat näytetään lineJoin:n "bevel"-tyylinä.

Tekninen tarkistus

Oletusarvo: 10

Selaimen tuki

Taulukossa olevat numerot osoittavat ensimmäisen täysin tukevan selaimen version.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
4.0 9.0 3.6 4.0 10.1

Huomautus:Internet Explorer 8 ja aikaisemmat versiot eivät tue <canvas>-elementtiä.