Constructor
A 2D vector that describes a point in space.
Parameters:
Name | Type | Description |
---|---|---|
args |
object | An object used to initialize the Point. If |
- Default Value:
- { x: 0, y: 0 }
Example
const point = new PSPDFKit.Geometry.Point({ x: 20, y: 30 });
point = point.set("y", 20);
point.y; // => 20
Extends
- Immutable.Record
Members
Methods
Members
The x
coordinate of the point.
Type:
- number
- Default Value:
- 0
The y
coordinate of the point.
Type:
- number
- Default Value:
- 0
Methods
Calculates the euclidean distance to another point.
Parameters:
Name | Type | Description |
---|---|---|
other |
PSPDFKit.Geometry.Point | The other point to calculate the distance with. |
Returns:
The distance between the two points.
- Type
- number
Example
var point1 = new PSPDFKit.Geometry.Point({ x: 10, y: 10 });
var point2 = new PSPDFKit.Geometry.Point({ x: 20, y: 10 });
point1.distance(point2); // => 10
Scales x
and y
by the given sx
and sy
factor. If only sx
is set and sy
not defined,
it will scale x
and y
by sx
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
sx |
number | Scale value for the |
|
sy |
number |
<nullable> |
If empty, it will scale |
Returns:
A new Point
.
Example
const point = new PSPDFKit.Geometry.Point({ x: 10, y: 10 });
point.scale(2); // => Point {x: 20, y: 20}
Translate all values of the point by a given Point
.
Parameters:
Name | Type | Description |
---|---|---|
point |
PSPDFKit.Geometry.Point | A point that describes the translation distance. |
Returns:
A new Point
.
Example
const point = new PSPDFKit.Geometry.Point({ x: 10, y: 10 });
point.translate(new PSPDFKit.Geometry.Point({ x: 5, y: -5 })); // => Point {x: 15, y: 5}
Translate the x
value by a given number.
Parameters:
Name | Type | Description |
---|---|---|
tx |
number | A number to translate the |
Returns:
A new Point
.
Example
const point = new PSPDFKit.Geometry.Point({ x: 10, y: 10 });
point.translateX(5); // => Point {x: 15, y: 10}
Translate the y
value by a given number.
Parameters:
Name | Type | Description |
---|---|---|
ty |
number | A number to translate the |
Returns:
A new Point
.
Example
const point = new PSPDFKit.Geometry.Point({ x: 10, y: 10 });
point.translateY(5); // => Point {x: 10, y: 15}