Class: DrawingPoint

PSPDFKit.Geometry.DrawingPoint

An extension of the PSPDFKit.Geometry.Point that can also store an intensity value. This is used for example inside an ink annotation, where the intensity is the pressure that was exerted by the touch device.

Constructor

new PSPDFKit.Geometry.DrawingPoint(args)

A 3D vector that describes a point in space and an intensity value.

Parameters:
Name Type Description
args object

An object used to initialize the Point. If x or y is omitted, 0 will be used instead. If intensity is omitted, 0.5 will be used (the neutral intensity value).

Default Value:
  • { x: 0, y: 0, intensity: 0.5 }
Example

Create and update a point

const point = new PSPDFKit.Geometry.DrawingPoint({
  x: 20,
  y: 30,
  intensity: 0.3
});
point.intensity; // => 0.3

Extends

Members

Methods




Members

intensity: number

The intensity is used to describe the pressure of a point inside an ink annotation. It is capped between 0 and 1 inclusive.

If the touch input does not allow to measure the pressure, a value of 0.5 should be used.

Type:
  • number
Default Value:
  • 0.5

x: number

The x coordinate of the point.

Type:
  • number
Inherited From:
Default Value:
  • 0

y: number

The y coordinate of the point.

Type:
  • number
Inherited From:
Default Value:
  • 0

Methods

distance(other) → {number}

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

scale(sx, synullable) → {PSPDFKit.Geometry.Point}

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 x coordinate. If sy is not set, this scale will also be applied to y.

sy number <nullable>

If empty, it will scale y with sx as well.

Returns:

A new Point.

Type
PSPDFKit.Geometry.Point
Example
const point = new PSPDFKit.Geometry.Point({ x: 10, y: 10 });
point.scale(2); // => Point {x: 20, y: 20}

translate(point) → {PSPDFKit.Geometry.Point}

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.

Type
PSPDFKit.Geometry.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}

translateX(tx) → {PSPDFKit.Geometry.Point}

Translate the x value by a given number.

Parameters:
Name Type Description
tx number

A number to translate the x value.

Returns:

A new Point.

Type
PSPDFKit.Geometry.Point
Example
const point = new PSPDFKit.Geometry.Point({ x: 10, y: 10 });
point.translateX(5); // => Point {x: 15, y: 10}

translateY(ty) → {PSPDFKit.Geometry.Point}

Translate the y value by a given number.

Parameters:
Name Type Description
ty number

A number to translate the y value.

Returns:

A new Point.

Type
PSPDFKit.Geometry.Point
Example
const point = new PSPDFKit.Geometry.Point({ x: 10, y: 10 });
point.translateY(5); // => Point {x: 10, y: 15}