Example
Create and update an inset.
const inset = new NutrientViewer.Geometry.Inset({
left: 5,
top: 15,
right: 10,
bottom: 5
});
inset = inset.set("bottom", 7);
rect.bottom; // => 7
Default Value
{ left: 0, top: 0, right: 0, bottom: 0 }Hierarchy
Constructors
Parameters
options{ bottom?: number; left?: number; right?: number; top?: number }Optional
Properties
left
The left distance of the inset. This is equivalent to x of a
NutrientViewer.Geometry.Point.
Default Value
0top
The top distance of the inset. This is equivalent to y of a
NutrientViewer.Geometry.Point.
Default Value
0Methods
Applies a transformation to the inset. We will transform each of the corners represented by the inset and then find the max and min values to generate the resulting inset.
Parameters
matrixTransformationMatrixReturns
Returns a new inset with the provided scale applied to all properties.
Parameters
scalenumberThe scale to apply to the inset.
Returns
applyToRect
- applyToRect(
inset: NutrientViewer.Geometry.Inset,
rect: NutrientViewer.Geometry.Rect,
): NutrientViewer.Geometry.RectReturns a new Rect by adding the provided inset values to the provided Rect.
Parameters
insetNutrientViewer.Geometry.InsetAn Inset instance.
A Rect instance.
Returns
A new
Rect.Example
const rect = NutrientViewer.Geometry.Inset.applyToRect(
rectangleAnnotation.cloudyBorderInset,
rectangleAnnotation.boundingBox
);
fromRect
Parameters
Returns
fromValue
Returns a new inset using the provided vale for all properties.
Parameters
insetValuenumberAn inset value to be applied to all the properties.
Returns
A new
Inset.Example
const inset = NutrientViewer.Geometry.Inset.fromValue(10);
// inset ->
// {
// left: 10,
// top: 10,
// right: 10,
// bottom: 10,
// }
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
- get<K extends "left" | "right" | "top" | "bottom">(
key: K,
): { bottom: number; left: number; right: number; top: number }[K]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
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
{ bottom: number; left: number; right: number; top: number }bottom: number
The
bottomdistance of the inset.Default Value
0left: number
The
leftdistance of the inset. This is equivalent toxof a NutrientViewer.Geometry.Point.Default Value
0right: number
The
rightdistance of the inset.Default Value
0top: number
The
topdistance of the inset. This is equivalent toyof a NutrientViewer.Geometry.Point.Default Value
0
Shallowly converts this Record to equivalent native JavaScript Object.
Returns
{ bottom: number; left: number; right: number; top: number }bottom: number
The
bottomdistance of the inset.Default Value
0left: number
The
leftdistance of the inset. This is equivalent toxof a NutrientViewer.Geometry.Point.Default Value
0right: number
The
rightdistance of the inset.Default Value
0top: number
The
topdistance of the inset. This is equivalent toyof a NutrientViewer.Geometry.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
An inset describes a rectangle by enumerating the distance from each side to the corresponding side of a reference rectangle. Therefore it does not hold coordinates, nor dimensions, only relative values for
left,top,rightandbottom. 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:inset.set("right", 15).