Constructor
new StyleTool(paperScope)
Create a new instance of the StyleTool class.
Parameters:
Name | Type | Description |
---|---|---|
paperScope |
paper.PaperScope | The PaperScope instance to associate with the tool. |
- Source:
Extends
- AnnotationUITool
Classes
Methods
ColorpickerCursor(cursorCellSize, cursorGridSize, parent)
Represents a color picker cursor for selecting colors from an image.
Parameters:
Name | Type | Description |
---|---|---|
cursorCellSize |
number | The size of the individual color cells in the cursor. |
cursorGridSize |
number | The size of the grid in the cursor. |
parent |
paper.Layer | The parent layer to which the cursor group will be added. |
- Source:
activateForItem(item)
Activate the StyleTool for a specific annotation item.
Parameters:
Name | Type | Description |
---|---|---|
item |
paper.Item | The item for which the StyleTool should be activated. |
- Source:
applyColor(value, type, item)
Apply the given color value to the specified type (fill or stroke) of the target items.
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The color value to apply. |
type |
string | The type of color to apply (either 'fill' or 'stroke'). |
item |
paper.Item | The specific item to apply the color to (optional). |
- Source:
applyFillColor(value, item)
Apply the given fill color value to the target items.
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The fill color value to apply. |
item |
paper.Item | The specific item to apply the color to (optional). |
- Source:
applyOpacity(opacity, property)
Apply the given opacity value to fill or stroke properties of the target items.
Parameters:
Name | Type | Description |
---|---|---|
opacity |
number | The opacity value to apply. |
property |
string | The property to apply the opacity to (e.g., 'fillOpacity', 'strokeOpacity'). |
- Source:
applyStrokeColor(value, item)
Apply the given stroke color value to the target items.
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The stroke color value to apply. |
item |
paper.Item | The specific item to apply the color to (optional). |
- Source:
applyStrokeWidth(value)
Apply the given stroke width to the target items.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | The stroke width value to apply. |
- Source:
cancelColorpicker()
Cancel the color picker interface and reject the associated Promise.
- Source:
createMaskedImage(item) → {paper.Group}
Create a masked image of the item for use in color sampling.
Parameters:
Name | Type | Description |
---|---|---|
item |
paper.Item | The item to create the masked image from. |
- Source:
Returns:
- A Group containing the masked image.
- Type
- paper.Group
(async) getAverageColor(itemToAverage) → {Promise.<paper.Color>}
Represents a utility function to calculate the average color of an item on the screen.
Parameters:
Name | Type | Description |
---|---|---|
itemToAverage |
paper.Item | The item for which to calculate the average color. |
- Source:
Returns:
- A promise that resolves with the calculated average color.
- Type
- Promise.<paper.Color>
onSelectionChanged()
Event handler for selection changes, updating the target items and the toolbar display.
- Source:
pickColor() → {Promise.<paper.Color>}
Activate the color picker interface, allowing users to pick a color from the canvas.
- Source:
Returns:
- A Promise that resolves to the selected color.
- Type
- Promise.<paper.Color>
updatePosition(point)
Update the position of the color picker cursor and retrieve colors from the image.
Parameters:
Name | Type | Description |
---|---|---|
point |
paper.Point | The point in the view where the cursor is positioned. |
- Source: