Latest web development tutorials

HTML canvas miterLimit property

HTML canvas Reference Manual HTML canvas Reference Manual

Examples

5 maximum miter length to draw lines:

YourbrowserdoesnotsupporttheHTML5canvastag.

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();

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 9, Firefox, Opera, Chrome and Safari support miterLimit property.

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


Definition and Usage

miterLimit property sets or returns the maximum length of the miter.

Miter length is the distance between the two lines of intersection of the inner and outer corners.

Miter Limit figure 1

Note: Only when lineJoin property to "miter", miterLimit valid.

The smaller the angle of the corner, the greater the length of the miter.

To avoid miter length is too long, we can use miterLimit property.

If the miter length exceeds the value miterLimit, the corners will be "bevel" type lineJoin to display (Fig 3):

Miter Limit figure 2
Defaults: 10
JavaScript syntax: context.miterLimit = number;

Property Value

描述
number 正数。规定最大斜接长度。如果斜接长度超过 miterLimit 的值,边角会以 lineJoin 的 "bevel" 类型来显示。


HTML canvas Reference Manual HTML canvas Reference Manual