DOMPointInit - Web APIs 编辑

The DOMPointInit dictionary is used to provide the values of the coordinates and perspective when creating and JSONifying a DOMPoint or DOMPointReadOnly object.

It's used as an input parameter to the DOMPoint/DOMPointReadOnly method fromPoint(). It's used as the return value when calling toJSON().

Properties

DOMPointInit.x
An unrestricted floating-point value indicating the x-coordinate of the point in space. This is generally the horizontal coordinate, with positive values being to the right and negative values to the left. The default value is 0.
DOMPointInit.y
An unrestricted floating-point number providing the point's y-coordinate. This is the vertical coordinate, and barring any transforms applied to the coordinate system, positive values are downward and negative values upward toward the top of the screen. The default is 0.
DOMPointInit.z
An unrestricted floating-point value which gives the point's z-coordinate, which is (assuming no transformations that alter the situation) the depth coordinate; positive values are closer to the user and negative values retreat back into the screen. The default value is 0.
DOMPointInit.w
The point's w perspective value, given as an unrestricted floating-point number. The default is 1.

Example

This example creates a new DOMPoint representing the top-left corner of the current window, with a z component added to move the point closer to the user. This same code will work to create a DOMPointReadOnly object; just change the interface name in the code.

const pointDesc = {
  x: window.screenX,
  y: window.screenY,
  z: 5.0
};

const windTopLeft = DOMPoint.fromPoint(pointDesc)

Specifications

SpecificationStatusComment
Geometry Interfaces Module Level 1
The definition of 'DOMPointReadOnly.fromPoint()' in that specification.
Candidate RecommendationInitial definition

Browser compatibility

BCD tables only load in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:102 次

字数:3549

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文