Latest web development tutorials

HTML canvas lineWidth property

HTML canvas Reference Manual HTML canvas Reference Manual

Examples

With a width of 10 pixels of lines to draw a rectangle:

YourbrowserdoesnotsupporttheHTML5canvastag.

JavaScript:

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.lineWidth=10;
ctx.strokeRect(20,20,80,100);

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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

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


Definition and Usage

lineWidth property sets or returns the current width of the line, in pixels.

Defaults: 1
JavaScript syntax: context.lineWidth = number;

Property Value

描述
number 当前线条的宽度,以像素计。


HTML canvas Reference Manual HTML canvas Reference Manual