@fabwcie/free-drawing / components/toolbar/widgets/PathShapeWidget / PathShapeWidget
Abstract Class: PathShapeWidget
Defined in: packages/free-drawing/src/components/toolbar/widgets/PathShapeWidget.ts:25
Tool drawing a closed shape in the dragged box (triangle, diamond, heart, cloud): background color, stroke style, Shift draws it in a square
Extends
ShapeWidget<Path>
Extended by
Constructors
Constructor
new PathShapeWidget(
drawer,id,title,icon,shortcut?):PathShapeWidget
Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:80
Create the widget with the shape overlay shared by shape tools of the drawer
Parameters
drawer
Drawer of this widget
id
"pan" | "selection" | "brush" | "eraser" | "undo" | "redo" | "text" | "rect" | "circle" | "ellipse" | "square" | "arrow" | "line" | "star" | "triangle" | "polygon" | "diamond" | "heart" | "cloud" | "highlighter" | "laser" | "frame"
Id of the tool
title
string
Title of the button without translation of the id
icon
string
Svg markup of the button icon
shortcut?
string
Default key activating the tool
Returns
PathShapeWidget
Inherited from
Properties
$button
$button:
HTMLButtonElement
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:38
Button activating the widget, pressed while it is active, named by the title of the tool
Inherited from
$container
protectedreadonly$container:HTMLElement
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:32
Container of the button in toolbar (or menu of its group), with a class from widget id
Inherited from
cursor
protectedcursor:string=crosshairCursor
Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:62
Stage cursor while widget is active
Inherited from
drawer
protecteddrawer:Drawer
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:64
Drawer of this widget
Inherited from
hasEdges
protectedhasEdges:boolean=false
Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:68
Corners sharp or round (edges option)
Inherited from
hasFill
protectedhasFill:boolean=true
Defined in: packages/free-drawing/src/components/toolbar/widgets/PathShapeWidget.ts:26
Shapes of tool have a background color (rectangle, ellipse)
Overrides
id
id:
"pan"|"selection"|"brush"|"eraser"|"undo"|"redo"|"text"|"rect"|"circle"|"ellipse"|"square"|"arrow"|"line"|"star"|"triangle"|"polygon"|"diamond"|"heart"|"cloud"|"highlighter"|"laser"|"frame"
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:40
Id of the tool, key of the widget in toolbar (drawer.getWidget(id)) and namespace of its stage events
Inherited from
inAction
inAction:
boolean=false
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:48
Pointer action in progress (drawing, erasing, selecting...), see startAction / endAction
Inherited from
options
readonlyoptions:WidgetOptions
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:46
Widget options given with drawer widgets option
Inherited from
overlay
overlay:
ShapeOverlay
Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:61
Options of the tool (color, width...), shown while widget is active (see showOverlayOnActive)
Inherited from
path
abstractprotectedpath:string
Defined in: packages/free-drawing/src/components/toolbar/widgets/PathShapeWidget.ts:30
Path in a box of width and height 1, see scalePath
pointerEvent
protectedpointerEvent:MouseEvent|TouchEvent|null=null
Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:70
Last pointer event of drawing (modifier keys)
Inherited from
shapeName
abstractprotectedshapeName:string
Defined in: packages/free-drawing/src/components/toolbar/widgets/PathShapeWidget.ts:28
Name of shapes (see shapeName)
shortcut
shortcut:
string|undefined
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:42
Key activating the tool, lower case (shortcut widget option, else default of the widget), none if undefined
Inherited from
showOverlayOnActive
protectedshowOverlayOnActive:boolean=true
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:50
Show overlay while widget is active (false when overlay depends on something else, e.g. selection)
Inherited from
ShapeWidget.showOverlayOnActive
Accessors
isDisabled
Get Signature
get isDisabled():
boolean
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:137
Widget can not be activated (see setDisabled)
Returns
boolean
Inherited from
isPaint
Get Signature
get isPaint():
boolean
Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:97
Shape being drawn (pointer action in progress)
Deprecated
use inAction
Returns
boolean
Inherited from
shapeStyle
Get Signature
get
protectedshapeStyle():object
Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:120
Style of new shapes, from drawer options
Returns
dash
dash:
number[] |undefined
Dash of strokeStyle option for this stroke width, undefined for solid
fill
fill:
ColorLike|undefined
Background color (fillColor option) of shapes having one (hasFill), none if transparent
hitStrokeWidth
hitStrokeWidth:
number
Width of the hit region, 20 at least: easier to select / erase than the stroke only
lineCap
lineCap:
"round"
Round ends of lines, dashes and dots
opacity
opacity:
number
Opacity (opacity option)
stroke
stroke:
ColorLike=strokeColor
Stroke color (strokeColor option)
strokeWidth
strokeWidth:
number
Stroke width (strokeWidth option)
Inherited from
Methods
addTo()
addTo(
parent):void
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:97
Internal
Adds the button of this widget (icon, shortcut letter) in its container, at the end of parent
Parameters
parent
HTMLElement
Element receiving the button container: toolbar root or menu of a group
Returns
void
Inherited from
afterDraw()
protectedafterDraw():void
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:226
Shape drawn with this tool: selection tool activated, nothing selected, unless tool is kept (keepTool preference)
Returns
void
Inherited from
clearSelection()
clearSelection():
void
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:219
Unselect shapes, with selection widget (implemented by it)
Returns
void
Inherited from
createShape()
protectedcreateShape(start):Path
Defined in: packages/free-drawing/src/components/toolbar/widgets/PathShapeWidget.ts:37
Empty path at drag start, round joins
Parameters
start
Vector2d
Drag start, in drawing coordinates
Returns
Path
Path named by shapeName
Overrides
endAction()
protectedendAction():void
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:202
Pointer action ends (pointer up)
Returns
void
Inherited from
initEvents()
protectedinitEvents():void
Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:167
Draw by drag: shape created on pointer down, updated on move (shared live), finished on pointer up (removed after a simple click)
Returns
void
Inherited from
onActive()
protectedonActive():void
Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:158
Overlay shared by shape tools: background color and edges only for shapes having them
Returns
void
Inherited from
onConstrainChange()
protectedonConstrainChange(constrain):void
Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:151
Shift pressed or released while drawing: shape updated to the pointer with or without constraint
Parameters
constrain
boolean
Shift pressed
Returns
void
Inherited from
onDesactive()
protectedonDesactive():void
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:176
Called on deactivation, after events removal and overlay hidden
Returns
void
Inherited from
onDrawEnd()?
protectedoptionalonDrawEnd(shape):void
Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:145
Drawing ended: shape drawn, or null (removed: simple click)
Parameters
shape
Path | null
Shape drawn, in its final geometry and placed in frames, null after a simple click
Returns
void
Inherited from
onStage()
protectedonStage(events,handler):void
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:147
Listen stage events while widget is active. Events are namespaced with widget id, so they are removed on deactivation without removing other listeners.
Parameters
events
string
Space separated event names
handler
KonvaEventListener<Stage, any>
Konva listener called with the stage event
Returns
void
Inherited from
removeEvents()
protectedremoveEvents():void
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:164
Remove widget events, called on deactivation
Returns
void
Inherited from
setActive()
setActive(
active):void
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:259
Activate widget (nothing if disabled): previous widget deactivated, button pressed, then initEvents, updateCursor, overlay shown (if showOverlayOnActive), onActive and drawer focused. Deactivate it: pointer action ended, removeEvents, overlay hidden, onDesactive, button released.
Parameters
active
boolean
Activate (true) or deactivate (false) widget
Returns
void
Inherited from
setDisabled()
setDisabled(
disabled):void
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:124
Disable or enable widget: a disabled widget can not be activated and its button is disabled (also its group when all its widgets are). Drawing tools are disabled in read only.
Parameters
disabled
boolean
Disable widget
Returns
void
Inherited from
shareLive()
protectedshareLive(...shapes):void
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:212
Shapes being drawn shown to collaborators while drawing (final state is sent on change)
Parameters
shapes
...DrawingShape[]
Shapes in their current state, sent as a live change of the collaboration session
Returns
void
Inherited from
startAction()
protectedstartAction():void
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:194
Pointer action starts (pointer down): shortcuts are disabled and UI (toolbar, overlays...) ignores pointer
Returns
void
Inherited from
toggleDisable()
toggleDisable():
void
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:115
Disable / enable widget, a disabled widget can not be activated
Returns
void
Inherited from
updateCursor()
updateCursor():
void
Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:187
Set stage cursor to the cursor of widget: on activation, and to restore it after a temporary one (pan grabbing)
Returns
void
Inherited from
updateShape()
protectedupdateShape(shape,start,end,constrain):void
Defined in: packages/free-drawing/src/components/toolbar/widgets/PathShapeWidget.ts:56
Path scaled to the dragged box
Parameters
shape
Path
Path being drawn
start
Vector2d
Drag start, in drawing coordinates
end
Vector2d
Pointer, in drawing coordinates
constrain
boolean
Shift pressed: square box
Returns
void