The DOMPoint()
constructor creates and returns a new DOMPoint
object, given the values for some or all of its properties.
You can also create a DOMPoint
by calling the DOMPoint.fromPoint()
static function. That function accepts any object with the required parameters, including a DOMPoint
or DOMPointReadOnly
.
new DOMPoint()
new DOMPoint(x)
new DOMPoint(x, y)
new DOMPoint(x, y, z)
new DOMPoint(x, y, z, w)
This example creates a DOMPoint
representing the top-left corner of the current window, then creates a second point based on the first, which is then offset by 100 pixels both vertically and horizontally.
const windTopLeft = new DOMPoint(window.screenX, window.screenY);
const newTopLeft = DOMPoint.fromPoint(windTopLeft);
newTopLeft.x += 100;
newTopLeft.y += 100;