--- title: Point slug: Mozilla/JavaScript_code_modules/Geometry.jsm/Point translation_of: Mozilla/JavaScript_code_modules/Geometry.jsm/Point ---
The Point class offers methods for performing common geometry operations on two dimensional points
Point add(x, y); |
Point add(Point); |
Point clone(); |
boolean equals(x, y); |
Point equals(Point); |
boolean isZero(); |
Point map(mapFunction); |
Point scale(scaleFactor); |
Point set(x, y); |
Point set(Point); |
Point subtract(x, y); |
Point subtract(Point); |
String toString(); |
יוצר אובייקט Point חדש.
let p = new Point(x, y);
The new point, p, has the specified X and Y coordinates.
Adds another point to this one.
Point add( x, y ); Point add( Point );
xyPoint object instead of separate X and Y coordinates.The value of the Point object after adding the specified value; this isn't a new object, just the same one you called the function on.
Creates and returns a copy of the Point object.
Point clone();
None.
A new Point object which is a duplicate of the current object.
Determines whether another point is equal to this one.
boolean equals( x, y ); boolean equals( Point );
xyPoint object instead of separate X and Y coordinates.true if the two points are equal, otherwise false. Equality, in this context, means that both the X and Y coordinates are the same.
Determines whether or not the point is (0, 0).
boolean isZero();
None.
true if the point's X and Y coordinates are both zero; otherwise false.
Calls a specified function to manipulate the values of the point's coordinates.
Point map( mapFunction );
mapFunctionPoint object will be the value of this within the called function.The value of the Point object after modifying its coordinates by calling the specified function; this isn't a new object, just the same one you called the function on.
Scales the point's coordinates by a specified factor.
Point scale( scaleFactor );
scaleFactorThe value of the Point object after scaling its coordinates by the specified amount; this isn't a new object, just the same one you called the function on.
Sets the value of the Point object.
Point set( x, y ); Point set( Point );
xyPoint object instead of separate X and Y coordinates.The Point object.
Subtracts another point from this one.
Point subtract( x, y ); Point subtract( Point );
xyPoint object instead of separate X and Y coordinates.The value of the Point object after subtracting the specified value; this isn't a new object, just the same one you called the function on.
Returns a string representation of the Point object.
String toString();
None.
A String object representing the point, in "(x,y)" format.