DOMPointReadOnly

DOMPointReadOnly interface specifies the coordinate and perspective fields used by DOMPoint to define a 2D or 3D point in a coordinate system.

注意: 此特征可用于 Web 工作者 .

There are two ways to create a new DOMPointReadOnly instance. First, you can use its constructor, passing in the values of the parameters for each dimension and, optionally, the perspective:

/* 2D */
const point = new DOMPointReadOnly(50, 50);
/* 3D */
const point = new DOMPointReadOnly(50, 50, 25);
/* 3D with perspective */
const point = new DOMPointReadOnly(100, 100, 100, 1.0);
					

The other option is to use the static DOMPointReadOnly.fromPoint() method:

const point = DOMPointReadOnly.fromPoint({x: 100, y: 100, z: 50; w: 1.0});
					

构造函数

DOMPointReadOnly()
创建新的 DOMPointReadOnly object given the values of its coordinates and perspective. To create a point using a DOMPointInit object, you can instead use DOMPointReadOnly.fromPoint() .

特性

DOMPointReadOnly.x 只读
The point's horizontal coordinate, x .
DOMPointReadOnly.y 只读
The point's vertical coordinate, y .
DOMPointReadOnly.z 只读
The point's depth coordinate, z .
DOMPointReadOnly.w 只读
The point's perspective value, w .

静态方法

DOMPointReadOnly.fromPoint()
A static method that creates a new DOMPointReadOnly object given the coordinates provided in the specified DOMPointInit 对象。

方法

matrixTransform()
Applies a matrix transform specified as a DOMMatrixInit object to the DOMPointReadOnly 对象。
toJSON()
Returns a JSON representation of the DOMPointReadOnly 对象。

规范

规范 状态 Comment
Geometry Interfaces Module Level 1
The definition of 'DOMPoint' in that specification.
候选推荐 Latest spec version is an ED.

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
DOMPointReadOnly Chrome 61 Edge 79 Firefox 31 IE No Opera 48 Safari 10.1 WebView Android 61 Chrome Android 61 Firefox Android 31 Opera Android 45 Safari iOS 10.3 Samsung Internet Android 8.0
DOMPointReadOnly() 构造函数 Chrome 61 Edge 79 Firefox 31 IE No Opera 48 Safari 10.1 WebView Android 61 Chrome Android 61 Firefox Android 31 Opera Android 45 Safari iOS 10.3 Samsung Internet Android 8.0
fromPoint() static function Chrome 61 Edge 79 Firefox 31 IE No Opera 48 Safari 10.1 WebView Android 61 Chrome Android 61 Firefox Android 31 Opera Android 45 Safari iOS 10.3 Samsung Internet Android 8.0
matrixTransform()
弃用
Chrome 61 Edge 79 Firefox 31 IE No Opera 48 Safari 10.1 WebView Android 61 Chrome Android 61 Firefox Android 31 Opera Android 45 Safari iOS 10.3 Samsung Internet Android 8.0
toJSON() Chrome 61 Edge 79 Firefox 62 IE No Opera 48 Safari 10.1 WebView Android 61 Chrome Android 61 Firefox Android 62 Opera Android 45 Safari iOS 10.3 Samsung Internet Android 8.0
w Chrome 61 Edge 79 Firefox 31 IE No Opera 48 Safari 10.1 WebView Android 61 Chrome Android 61 Firefox Android 31 Opera Android 45 Safari iOS 10.3 Samsung Internet Android 8.0
Available in workers Chrome 61 Edge 79 Firefox 69 IE No Opera 48 Safari 10.1 WebView Android 61 Chrome Android 61 Firefox Android No Opera Android 45 Safari iOS 10.3 Samsung Internet Android 8.0
x Chrome 61 Edge 79 Firefox 31 IE No Opera 48 Safari 10.1 WebView Android 61 Chrome Android 61 Firefox Android 31 Opera Android 45 Safari iOS 10.3 Samsung Internet Android 8.0
y Chrome 61 Edge 79 Firefox 31 IE No Opera 48 Safari 10.1 WebView Android 61 Chrome Android 61 Firefox Android 31 Opera Android 45 Safari iOS 10.3 Samsung Internet Android 8.0
z Chrome 61 Edge 79 Firefox 31 IE No Opera 48 Safari 10.1 WebView Android 61 Chrome Android 61 Firefox Android 31 Opera Android 45 Safari iOS 10.3 Samsung Internet Android 8.0

图例

完整支持
完整支持
不支持
不支持
弃用。不要用于新网站。
弃用。不要用于新网站。

另请参阅