Constructor
Create a new TransformTool instance.
Parameters:
Name |
Type |
Description |
paperScope |
paper.PaperScope
|
The Paper.js scope for the tool.
The constructor initializes the TransformTool by calling the base class (AnnotationUITool) constructor and sets up the necessary toolbar control (TransformToolbar). |
Properties:
Name |
Type |
Description |
ps |
paper.PaperScope
|
The Paper.js scope associated with the project. |
_mode |
string
|
The current mode of the TransformTool. |
_moving |
Array.<paper.Item>
|
An array of items currently being moved or transformed. |
_transformTool |
paper.Group
|
The TransformTool object that contains transformation controls. |
- Source:
Extends
Classes
- TransformToolbar
Methods
A function that creates and initializes the TransformTool object with the specified zoom level.
This function sets up the corners for resizing, the rotation handle, and translation controls.
Parameters:
Name |
Type |
Description |
currentZoom |
number
|
The current zoom level of the canvas. |
Properties:
Name |
Type |
Description |
_transformTool |
paper.Group
|
The TransformTool object that contains transformation controls.
Properties
Name |
Type |
Description |
corners |
object
|
An object containing corner control points for resizing the bounding box.
Properties
Name |
Type |
Description |
topLeft |
paper.Shape.Rectangle
|
The control point for the top-left corner. |
topRight |
paper.Shape.Rectangle
|
The control point for the top-right corner. |
bottomRight |
paper.Shape.Rectangle
|
The control point for the bottom-right corner. |
bottomLeft |
paper.Shape.Rectangle
|
The control point for the bottom-left corner. |
|
rotationHandle |
paper.Shape.Circle
|
The control point for rotating the bounding box. |
setBounds |
function
|
A function that (re)positions the tool handles (corners, rotation control). |
transformItems |
function
|
A function that applies transformation to selected items and sets up new objects for transforming. |
onMouseDown |
function
|
This function is triggered when the mouse button is pressed on the transform tool. It marks that the tool is in the dragging state. |
onMouseUp |
function
|
This function is triggered when the mouse button is released on the transform tool. It marks that the tool is not in the dragging state. |
onMouseDrag |
function
|
This function is triggered when the mouse is moved while a mouse button is pressed on the transform tool. It handles the dragging behavior of the transform tool. Depending on the state (resizing or translating), it resizes or translates the selected items accordingly. |
onMouseMove |
function
|
This function is triggered when the mouse is moved on the transform tool. It updates the visual appearance of the transform tool, highlighting relevant handles and controls based on the mouse position. |
|
- Source:
A function that disables the TransformTool object after transforming selected items.
This function deactivates the TransformTool, sends it to the back, and resets item matrices.
- Source:
A function that enables the TransformTool object for transforming selected items.
This function activates the TransformTool, bringing it to the front, and sets up items for transformation.
- Source:
hitTest(coords) → {paper.HitResult}
A function that performs a hit test on the canvas to find the item under the specified coordinates.
This function is used to determine the item selected for transformation.
Parameters:
Name |
Type |
Description |
coords |
paper.Point
|
The coordinates to perform the hit test. |
- Source:
Returns:
- The result of the hit test, containing the selected item.
-
Type
-
paper.HitResult
Parameters:
Name |
Type |
Description |
alwaysRescaleUniformly |
boolean
|
Whether the tool should enforce uniform scaling to maintain width:height ratio |
- Source: