HTML canvas lineWidth property
Examples
With a width of 10 pixels of lines to draw a rectangle:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.lineWidth=10;
ctx.strokeRect(20,20,80,100);
var ctx=c.getContext("2d");
ctx.lineWidth=10;
ctx.strokeRect(20,20,80,100);
try it"
Browser Support
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