線の幅が 10 ピクセルの矩形を描画します:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.lineWidth=10;
ctx.strokeRect(20,20,80,100);
Try it Yourself ❯
表中の数字は、プロパティを完全にサポートした最初のブラウザ・バージョンを指定しています。
プロパティ | |||||
---|---|---|---|---|---|
lineWidth | Yes | 9.0 | Yes | Yes | Yes |
lineWidth プロパティは、現在の線の幅をピクセルで設定または返します。
デフォルト値: | 1 |
---|---|
JavaScript 構文: | context.lineWidth=number; |
値 | 説明 | Play it |
---|---|---|
number | 現在の線の幅(ピクセル) | Play it ❯ |