Class: Inset

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, right and bottom. If nothing else is specified, point values are always interpreted as px.

It is an Immutable.Record and thus can be updated using set(key, value), for example: inset.set("right", 15).

Constructor

new PSPDFKit.Geometry.Inset(args)

A relative rectangle inset in 2D space.

Parameters:
Name Type Description
args Object

An object used to initialize the Point. If left, top, right or bottom is omitted, 0 will be used instead.

Default Value:
  • { left: 0, top: 0, right: 0, bottom: 0 }
Example

Create and update an inset

const inset = new PSPDFKit.Geometry.Inset({
  left: 5,
  top: 15,
  right: 10,
  bottom: 5
});
inset = inset.set("bottom", 7);
rect.bottom; // => 7

Extends

  • Immutable.Record

Members

Methods




Members

bottom: number

The bottom distance of the inset.

Type:
  • number
Default Value:
  • 0

left: number

The left distance of the inset. This is equivalent to x of a PSPDFKit.Geometry.Point.

Type:
  • number
Default Value:
  • 0

The right distance of the inset.

Type:
  • number
Default Value:
  • 0

top: number

The top distance of the inset. This is equivalent to y of a PSPDFKit.Geometry.Point.

Type:
  • number
Default Value:
  • 0

Methods

(static) applyToRect(inset, rect) → {PSPDFKit.Geometry.Rect}

Returns a new Rect by adding the provided inset values to the provided Rect.

Parameters:
Name Type Description
inset Inset

An Inset instance.

rect Rect

A Rect instance.

Returns:

A new Rect.

Type
PSPDFKit.Geometry.Rect
Example
const rect = PSPDFKit.Geometry.Inset.applyToRect(
  rectangleAnnotation.cloudyBorderInset,
  rectangleAnnotation.boundingBox
);

(static) fromValue(insetValue) → {PSPDFKit.Geometry.Inset}

Returns a new inset using the provided vale for all properties.

Parameters:
Name Type Description
insetValue number

An inset value to be applied to all the properties.

Returns:

A new Inset.

Type
PSPDFKit.Geometry.Inset
Example
const inset = PSPDFKit.Geometry.Inset.fromValue(10);
// inset ->
// {
//    left: 10,
//    top: 10,
//    right: 10,
//    bottom: 10,
// }