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 property is "miter" is valid.

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

To avoid excessive bevel length, we can use the miterLimit property.

If the bevel length exceeds the value of miterLimit, the corners will be rounded with the lineJoin "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();

亲自试一试

语法

context.miterLimit=number;

属性值

描述
number

正数。规定最大斜接长度。

如果斜接长度超过 miterLimit 的值,边角会以 lineJoin 的 "bevel" 类型来显示。

Maelezo ya mengine

Chaguo cha kawaida: 10

Muungano wa browser

Inaangalika za joto kwenye tabia zinaonekana kwa sababu ya browser za kwanza zinaongea kwa tabia hii.

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

Kumekadiri:Internet Explorer 8 na zaidi ya hayo hazinaongea kwa kina <canvas>.