DOMPointReadOnly: fromPoint() static method
The static DOMPointReadOnly
method fromPoint()
creates and returns a new
DOMPointReadOnly
object given a source point.
You can also create a new DOMPointReadOnly
object using the
new DOMPointReadOnly()
constructor.
Syntax
js
DOMPointReadOnly.fromPoint(sourcePoint)
Parameters
sourcePoint
-
A
DOMPoint
orDOMPointReadOnly
instance, or an object containing the following properties, from which to take the values of the new point's properties: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 is0
. 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 is0
. 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 is0
. w
-
The point's
w
perspective value, given as an unrestricted floating-point number. The default is1
.
Return value
A new DOMPointReadOnly
object (which is identical to the source point).
Examples
Creating a 2D point
Creating a 3D point using an existing point
This example creates a point, origPoint
, of type
DOMPoint
, using new DOMPoint()
. That
point is then used as the input for fromPoint()
to create a new point,
newPoint
.
js
const origPoint = new DOMPoint(25, 25, 100, 0.5);
const newPoint = DOMPointReadOnly.fromPoint(origPoint);
Specifications
Specification |
---|
Geometry Interfaces Module Level 1 # dom-dompointreadonly-frompoint |
Browser compatibility
BCD tables only load in the browser