Class: WandTool

OSDPaperjsAnnotation.WandTool(paperScope)

The `WandTool` class represents a powerful tool designed for making selections with a magic wand-like effect. It extends the `AnnotationUITool` class to provide advanced selection capabilities within the Paper.js framework. This tool allows users to create selections by intelligently selecting areas of similar colors within an image or canvas. It provides various modes and options for refining the selections and is particularly useful in interactive annotation and design workflows. The `WandTool` offers a seamless integration of selection, color manipulation, and interaction with the underlying image.

Constructor

new WandTool(paperScope)

Creates a new instance of the `WandTool` class, enabling users to make precise selections with sophisticated color-based mechanisms. This constructor initializes various properties and configurations that control the behavior of the tool.
Parameters:
Name Type Description
paperScope paper.PaperScope The PaperScope instance associated with this tool.
Source:

Extends

  • AnnotationUITool

Classes

WandToolbar

Members

colors :Object

An object containing color settings that guide the visual appearance of the tool.
Type:
  • Object
Properties:
Name Type Description
pixelAllowed paper.Color The color representing allowed pixels within the selection.
pixelNotAllowed paper.Color The color representing disallowed pixels within the selection.
currentItem paper.Color The color highlighting the currently selected item.
nullColor paper.Color The color of transparent pixels (for negative spaces).
defaultColor paper.Color The default color used for various UI elements.
Source:

floodMode :boolean

Determines whether the flood mode is active, influencing the behavior of the tool's selection algorithm. When flood mode is enabled, the tool uses a flood-fill approach to create selections. Otherwise, it employs a threshold mask approach.
Type:
  • boolean
Default Value:
  • true
Source:

reduceMode :boolean

Determines whether the reduce mode is active, altering the effect of dragging to create selections. When reduce mode is enabled, dragging reduces the current selection area instead of expanding it.
Type:
  • boolean
Default Value:
  • false
Source:

replaceMode :boolean

Determines whether the replace mode is active, affecting how the tool interacts with existing selections. In replace mode, the tool replaces the current selection with the new selection.
Type:
  • boolean
Default Value:
  • true
Source:

Methods

applyChanges()

Applies changes based on the magic wand selection.
Source:

applyMagicWand(eventPoint)

Applies the magic wand effect based on the current mouse point.
Parameters:
Name Type Description
eventPoint paper.Point The point where the magic wand is applied.
Source:

finish()

Finishes the wand tool operation and performs necessary cleanup.
Source:

getImageData()

Retrieves image data for processing the magic wand operation.
Source:

rasterPreview(binaryMask, sampleColor)

Rasterize the selection preview based on the binary mask and sample color.
Parameters:
Name Type Description
binaryMask Uint8ClampedArray The binary mask of the selection.
sampleColor Array.<number> The color sampled from the selected item.
Source:

setFloodMode(flood)

Sets whether the flood mode is enabled.
Parameters:
Name Type Description
flood boolean Whether to enable flood mode.
Source:

setReduceMode(erase)

Sets whether the reduce mode is enabled.
Parameters:
Name Type Description
erase boolean Whether to enable reduce mode.
Source:

setReplaceMode(replace)

Sets whether the replace mode is enabled.
Parameters:
Name Type Description
replace boolean Whether to enable replace mode.
Source:

setThreshold(t)

Sets the threshold value for the magic wand operation.
Parameters:
Name Type Description
t number The threshold value.
Source: