Example
Create and update a point.
const point = new NutrientViewer.Geometry.Point({ x: 20, y: 30 });
point = point.set("y", 20);
point.y; // => 20
Default Value
{ x: 0, y: 0 }Constructors
Parameters
options{ x?: number; y?: number; [key: string]: unknown }Optional
Properties
Methods
Applies a transformation to the point by multiplying the point like a 2D vector to the matrix.
Parameters
matrixTransformationMatrixReturns
this
Calculates the euclidean distance to another point.
Parameters
otherthisThe other point to calculate the distance with.
Returns
numberThe distance between the two points.
Example
var point1 = new NutrientViewer.Geometry.Point({ x: 10, y: 10 });
var point2 = new NutrientViewer.Geometry.Point({ x: 20, y: 10 });
point1.distance(point2); // => 10
Rotates the point at the origin [0, 0].
Parameters
degnumberReturns
this
Scales
xandyby the givensxandsyfactor. If onlysxis set andsynot defined, it will scalexandybysx.Parameters
sxnumberScale value for the
xcoordinate. Ifsyis not set, this scale will also be applied toy.synumberOptionalIf empty, it will scale
ywithsxas well.Returns
thisA new
Point.Example
const point = new NutrientViewer.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
point{ x: number; y: number }A point that describes the translation distance.
Returns
thisA new
Point.Example
const point = new NutrientViewer.Geometry.Point({ x: 10, y: 10 });
point.translate(new NutrientViewer.Geometry.Point({ x: 5, y: -5 })); // => Point {x: 15, y: 5}
Translate the
xvalue by a given number.Parameters
txnumberA number to translate the
xvalue.Returns
thisA new
Point.Example
const point = new NutrientViewer.Geometry.Point({ x: 10, y: 10 });
point.translateX(5); // => Point {x: 15, y: 10}
Translate the
yvalue by a given number.Parameters
tynumberA number to translate the
yvalue.Returns
thisA new
Point.Example
const point = new NutrientViewer.Geometry.Point({ x: 10, y: 10 });
point.translateY(5); // => Point {x: 10, y: 15}
Immutable Record API
24
asImmutable
- Deprecated
Returns
thisDeprecated
Not part of the collection API the Nutrient Web SDK supports. Build the value once, or use withMutations().
See Also
Map#asImmutable
asMutable
- Deprecated
Returns
thisDeprecated
Not part of the collection API the Nutrient Web SDK supports. Use withMutations().
See Also
Map#asMutable
Returns a new instance of this Record type with all values set to their default values.
Returns
this
Returns a new instance of this Record type with the value for the specific key set to its default value.
Returns a new instance of this Record type with the value at the given key path removed.
Also available as
removeIn.Parameters
keyPathIterable<unknown>Returns
this
Parameters
otherunknownReturns
boolean
Returns the value associated with the provided key, which may be the default value defined when creating the Record factory function.
If the requested key is not defined by this Record type, then notSetValue will be returned if provided. Note that this scenario would produce an error when using Flow or TypeScript.
Parameters
keyPathIterable<unknown>notSetValueunknownOptionalReturns
unknown
Parameters
keyunknownReturns
boolean
Parameters
...collectionsPartial<{ x: number; y: number }>[]Returns
this
mergeIn
removeIn
- Deprecated
Parameters
keyPathIterable<unknown>Returns
thisDeprecated
Not part of the collection API the Nutrient Web SDK supports. Use deleteIn(), or update() followed by delete().
Parameters
keyPathIterable<unknown>valueunknownReturns
this
Deeply converts this Record to equivalent native JavaScript Object.
Note: This method may not be overridden. Objects with custom serialization to plain JS may override toJSON() instead.
Returns
{ x: number; y: number }x: number
The
xcoordinate of the point.Default Value
0y: number
The
ycoordinate of the point.Default Value
0
Shallowly converts this Record to equivalent native JavaScript Object.
Returns
{ x: number; y: number }x: number
The
xcoordinate of the point.Default Value
0y: number
The
ycoordinate of the point.Default Value
0
toSeq
- Deprecated
Returns
Keyed<string, unknown>Deprecated
Not part of the collection API the Nutrient Web SDK supports. Use entries().
Note: Not all methods can be used on a mutable collection or within
withMutations! Onlysetmay be used mutatively.Parameters
mutator(mutable: this) => unknownReturns
thisSee Also
Map#withMutations
A point describes a 2D vector in space consisting of an
xandycoordinate. Provided values are defined in same units used by the page, point units. Point units are only equal to pixels when zoom value is1.It is an Immutable.Record and thus can be updated using
set(key, value), for example:point.set("x", 20).