Constructor
new PolygonTool(paperScope)
Initializes the PolygonTool by calling the base class (AnnotationUITool) constructor and setting up event handlers for drawing and editing polygons.
Parameters:
Name | Type | Description |
---|---|---|
paperScope |
Object | The Paper.js paper scope object, which provides context for working with Paper.js functionalities. |
Properties:
Name | Type | Description |
---|---|---|
tool |
paper.Tool | The Paper.js Tool object associated with the PolygonTool. |
drawingGroup |
paper.Group | The Paper.js Group used for drawing polygons. |
draggingSegment |
paper.Segment | The currently dragged segment during editing. |
eraseMode |
boolean | A flag indicating whether the tool is in erase mode. |
simplifying |
Object | A flag indicating whether the tool is simplifying the drawn polygon. |
simplifier |
SimplifyJS | An instance of the SimplifyJS library used for polygon simplification. |
- Source:
Extends
- AnnotationUITool
Classes
Methods
doSimplify()
Simplifies the polygon by reducing the number of points while preserving shape fidelity.
- Source:
drawing() → (nullable) {Object}
Retrieves the current drawing state, including the active path being drawn.
- Source:
Returns:
The current drawing state or null if no path is being drawn.
- Type
- Object
finish()
Finalizes the current polygon drawing and performs necessary cleanup.
- Source:
finishCurrentPath()
Completes the current polygon path and updates the annotation accordingly.
- Source:
redo()
Redoes the previously undone annotation action, restoring the next state.
- Source:
saveHistory()
Saves the current state of the annotation to the history stack for undo/redo functionality.
- Source:
setEraseMode(erase)
Sets the erase mode, enabling or disabling removal of segments or entire polygons.
Parameters:
Name | Type | Description |
---|---|---|
erase |
boolean | True to enable erase mode, false to disable. |
- Source:
undo()
Undoes the last annotation action, restoring the previous state.
- Source: