HTMLキャンバスstrokeRect()メソッド
例
150 * 100ピクセルの長方形を描画します。
JavaScript:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.strokeRect(20, 20, 150, 100);
ブラウザのサポート
表の数字は、このメソッドを完全にサポートする最初のブラウザバージョンを示しています。
Method | |||||
---|---|---|---|---|---|
strokeRect() | Yes | 9.0 | Yes | Yes | Yes |
定義と使用法
strokeRect()メソッドは長方形を描画します(塗りつぶしなし)。ストロークのデフォルトの色は黒です。
ヒント:strokeStyleプロパティを使用して、ストロークのスタイルを設定する色、グラデーション、またはパターンを設定します。
JavaScript構文: | context .strokeRect(x、y、width、height); |
---|
パラメータ値
Parameter | Description | Play it |
---|---|---|
x | The x-coordinate of the upper-left corner of the rectangle | |
y | The y-coordinate of the upper-left corner of the rectangle | |
width | The width of the rectangle, in pixels | |
height | The height of the rectangle, in pixels |
❮HTMLキャンバスリファレンス