Canvas lineWidth 属性

定义和用法

lineWidth 属性设置或返回当前线条的宽度,以像素计。

实例

用宽度为 10 像素的线条来绘制矩形:

Your browser does not support the canvas tag.

JavaScript:

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

亲自试一试

语法

context.lineWidth=number;

属性值

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

技术细节

默认值:1

浏览器支持

表中的数字注明了首个完全支持该属性的浏览器版本。

ChromeEdgeFirefoxSafariOpera
ChromeEdgeFirefoxSafariOpera
4.09.03.64.010.1

注释:Internet Explorer 8 以及更早的版本不支持 <canvas> 元素。