DOMRectReadOnly: fromRect() 静的メソッド

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

fromRect()DOMRectReadOnly オブジェクトの静的メソッドで、指定された位置と大きさで新しい DOMRectReadOnly オブジェクトを作成します。

構文

js
DOMRectReadOnly.fromRect()
DOMRectReadOnly.fromRect(rectangle)

引数

rectangle 省略可

矩形の位置と寸法を指定するオブジェクト。すべてのプロパティは既定で 0 です。プロパティは次の通りです。

  • x: 矩形の左端の座標です。
  • y: 矩形の上端の座標です。
  • width: 矩形の幅です。
  • height: 矩形の高さです。

返値

DOMRectReadOnly のインスタンスです。

仕様書

Specification
Geometry Interfaces Module Level 1
# dom-domrectreadonly-fromrect

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
fromRect() static method

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support