Class: RotationUtils

Core.Annotations. RotationUtils


new RotationUtils()

A namespace containing utility functions for annotation rotation

Methods


<static> getRotatedBoundingBoxRectFromRectangularAnnotations(unrotatedDimensions, angle, rotationPoint)

Calculates the rotated bounding box rect from an annotation's unrotated dimensions
Parameters:
Name Type Description
unrotatedDimensions Core.Annotations.RotationUtils.UnrotatedDimensions An object with the annotation's unrotated dimensions
angle number The angle (in radians) that the annotation is rotated
rotationPoint Core.Math.Point The pivot point for which the annotation is rotated on
Returns:
The rect representing the rotated annotation's bounding box
Type
Core.Math.Rect

<static> getRotatedPointsArray(pointsArray, angle, rotationPoint)

Calculates and returns the rotated positions of an array of points
Parameters:
Name Type Description
pointsArray Array.<Core.Math.Point> An array containing the points to be rotated
angle number The angle (in radians) to rotate the points
rotationPoint Core.Math.Point The pivot point around which the points in the array will be rotated
Returns:
An array containing the rotated points
Type
Array.<Core.Math.Point>

<static> getRotationAngleInDegreesByRadians(angleInRadians)

Converts an angle in radians to degrees
Parameters:
Name Type Description
angleInRadians number The angle in radians
Returns:
The angle in degrees
Type
number

<static> getRotationAngleInRadiansByDegrees(angleInDegrees)

Converts an angle in degrees to radians
Parameters:
Name Type Description
angleInDegrees number The angle in degrees
Returns:
The angle in radians
Type
number

<static> getUnrotatedDimensionsFromRectangularAnnotations(rect, angle)

Calculates the unrotated dimensions from a rotated rectangular annotation's bounding box
Parameters:
Name Type Description
rect Core.Math.Rect The rect representing the rotated annotation's bounding box
angle number The angle (in radians) that the annotation is rotated
Returns:
An object with the annotation's unrotated dimensions
Type
Core.Annotations.RotationUtils.UnrotatedDimensions

<static> normalizeAngle(angleInRadians)

Normalizes an angle to be within the range of 0 to 2π radians
Parameters:
Name Type Description
angleInRadians number The angle in radians
Returns:
The normalized angle (between 0 and 2π) in radians
Type
number

PathCustomAnnotationRotationMixin()

A mixin that adds rotation support for path-based custom annotations. Adds the following methods to a class:
  • rotate: Changes the Rotation property of the annotation, updates the annotation path and updates the bounding box
  • adjustRect: Adjusts the annotation's bounding box
  • serialize / deserialize: Makes sure the annotation gets correctly saved into the PDF when downloading the document and that it will load correctly
For this mixin to work properly, the annotation class must implement two methods:
  • setPath: Updates the annotation's path (array of points)
  • getPath: Returns the annotation's path (array of points)
Returns:
A mixin object to be applied to a custom annotation class
Type
object

RectangularCustomAnnotationRotationMixin()

A mixin that adds rotation support for rectangular custom annotations. Adds the following methods to a class:
  • rotate: Changes the Rotation property of the annotation and updates the bounding box
  • getUnrotatedDimensions: Calculates the correct dimension for drawing
  • getRotatedAnnotationBoundingBoxRect: Calculates the bounding box dimensions
  • serialize / deserialize: Makes sure the annotation gets correctly saved into the PDF when downloading the document and that it will load correctly
Returns:
A mixin object to be applied to a custom annotation class
Type
object

Type Definitions


UnrotatedDimensions

Type:
  • object
Properties:
Name Type Description
x number The x-coordinate of the top-left corner
y number The y-coordinate of the top-left corner
width number The width of the unrotated annotation
height number The height of the unrotated annotation