Skip to main content

Tools

This is the API reference for all drawing tool classes and tool configurations in Upmade. Every tool handles user interactions on the canvas and can be registered and configured via the editor.

Base Tool​

UpmadeBaseTool is the abstract base class for all tools in Upmade. All specific tool implementations extend this class and inherit its properties and lifecycle hooks.

Properties​

PropertyTypeDescription
classstringIdentifier used for object serialization and deserialization
toolTypeUpmadeToolTypeType key identifying the tool type across builds ('base', 'selection', 'brush', 'line', 'shape', 'text', 'image', 'eraser')
namestringHuman-readable name of the tool

Methods​

onActivate​

Called when the tool becomes the active tool.

onActivate()

onDeactivate​

Called when the tool is deactivated.

onDeactivate()

handlePointerDown​

Handles pointer down events (mouse click, touch start, pen down).

handlePointerDown(event: PointerEvent)

handlePointerMove​

Handles pointer move events (mouse move, touch move, pen move).

handlePointerMove(event: PointerEvent)

handlePointerUp​

Handles pointer up events (mouse release, touch end, pen up).

handlePointerUp(event: PointerEvent)

handleWheel​

Handles mouse wheel events for zooming or panning.

handleWheel(event: WheelEvent)

serialize​

Serializes the tool state to a plain object.

serialize()

deserialize​

Restores the tool state from a serialized object.

deserialize(object: any)

Selection Tool​

UpmadeSelectionTool enables selecting, moving, resizing, and rotating objects on the canvas. It manages selection handles, multi-selection bounding boxes, and object transformations.

Properties​

PropertyTypeDescription
toolType'selection'Type identifier for the selection tool
selectionHandlerUpmadeSelectionHandlerHandler for selection box and multi-select logic
moveHandlerUpmadeMoveHandlerHandler for dragging and moving selected objects
resizeHandlerUpmadeResizeHandlerHandler for resizing selected objects
rotationHandlerUpmadeRotationHandlerHandler for rotating selected objects
hoverHandlerUpmadeHoverHandlerHandler for object hover highlighting
lineHandleHandlerUpmadeLineHandleHandlerHandler for manipulating line endpoint anchors
paletteThemeAwareColor[]Active color palette available for modifying selected objects

Methods​

hasSelection​

Checks if any objects are currently selected.

hasSelection()

getSelectedObjects​

Returns an array of currently selected objects.

getSelectedObjects()

Brush Tool​

UpmadeBrushTool handles freehand drawing on the canvas, creating vector UpmadePath objects as the pointer moves.

Properties​

PropertyTypeDescription
toolType'brush'Type identifier for the brush tool
colorThemeAwareColorStroke color of the brush
sizenumberStroke width in pixels
opacitynumberOpacity of the stroke (0–1)
paletteThemeAwareColor[]Available color palette presets
sizesnumber[]Available stroke size presets

Configuration​

Toolbar items can configure initial settings for the brush tool using UpmadeBrushToolConfig:

PropertyTypeDescription
colorThemeAwareColorInitial stroke color
sizenumberInitial stroke size in pixels
opacitynumberOptional initial opacity (0–1)
paletteThemeAwareColor[]Color palette options shown in tool configuration
sizesnumber[]Optional stroke size presets

Line Tool​

UpmadeLineTool creates straight or curved UpmadeLine objects with optional arrowheads by dragging from a start point to an end point.

Properties​

PropertyTypeDescription
toolType'line'Type identifier for the line tool
colorThemeAwareColorLine stroke color
sizenumberLine stroke width in pixels
opacitynumberLine opacity (0–1)
paletteThemeAwareColor[]Available color palette presets
sizesnumber[]Available line stroke size presets
arrowsLineArrowConfigArrowhead configurations for start and end points

Configuration​

Toolbar items configure initial line settings using UpmadeLineToolConfig:

PropertyTypeDescription
colorThemeAwareColorInitial line stroke color
sizenumberInitial stroke width in pixels
opacitynumberOptional initial opacity (0–1)
paletteThemeAwareColor[]Color palette options
sizesnumber[]Optional stroke size presets
arrowsLineArrowConfigOptional initial arrowhead styles ('triangle', 'open', 'diamond', 'circle')

Shape Tool​

UpmadeShapeTool creates geometric UpmadeShape objects (rectangles, ellipses, triangles) by dragging across the canvas.

Properties​

PropertyTypeDescription
toolType'shape'Type identifier for the shape tool
shapeTypeShapeTypeActive shape geometry (Rectangle, Ellipse, Triangle)
fillColorThemeAwareColorShape background fill color
strokeColorThemeAwareColorShape border stroke color
strokeWidthnumberBorder stroke width in pixels
opacitynumberShape opacity (0–1)
fontFamilystringFont family for optional embedded text
fontSizenumberFont size in points for embedded text
fontColorThemeAwareColorFont color for embedded text
paletteThemeAwareColor[]Available color palette presets
sizesnumber[]Available border width presets

Configuration​

Toolbar items configure initial shape settings using UpmadeShapeToolConfig:

PropertyTypeDescription
shapeTypeShapeTypeInitial shape type (Rectangle, Ellipse, Triangle)
fillColorThemeAwareColorInitial fill color
strokeColorThemeAwareColorInitial stroke color
strokeWidthnumberInitial stroke width in pixels
opacitynumberOptional initial opacity (0–1)
fontColorThemeAwareColorInitial font color for embedded text
fontSizenumberInitial font size for embedded text
fontFamilystringInitial font family for embedded text
paletteThemeAwareColor[]Color palette options
sizesnumber[]Optional stroke width presets

Text Tool​

UpmadeTextTool places and edits rich text UpmadeText objects on the canvas using an inline ProseMirror editor.

Properties​

PropertyTypeDescription
toolType'text'Type identifier for the text tool
fontFamilystringActive font family name
fontSizenumberActive font size in points
fontColorThemeAwareColorActive font color
opacitynumberText opacity (0–1)
paletteThemeAwareColor[]Available font color palette presets
sizesnumber[]Available font size presets

Configuration​

Toolbar items configure initial text tool settings using UpmadeTextToolConfig:

PropertyTypeDescription
colorThemeAwareColorInitial font color
sizenumberInitial font size in points
opacitynumberOptional initial opacity (0–1)
fontFamilystringInitial font family name
availableFontsUpmadeFontRegistration[]Optional array of registered fonts available in the tool UI
paletteThemeAwareColor[]Color palette options
sizesnumber[]Optional font size presets

Image Tool​

UpmadeImageTool handles uploading and inserting raster UpmadeImage objects onto the canvas via a native file picker dialog.

Properties​

PropertyTypeDescription
toolType'image'Type identifier for the image tool
fileInputHTMLInputElement | nullHidden HTML file input element used to select image files
maxCompressionSizenumberMaximum width/height dimension in pixels for automatic image compression
multiImportOffsetnumberStagger offset in world units applied when importing multiple images at once

Eraser Tool​

UpmadeEraserTool removes objects or path segments touched by the eraser during drag gestures.

Properties​

PropertyTypeDescription
toolType'eraser'Type identifier for the eraser tool

Support us

Upmade is an MIT-licensed open source project. If you like the idea of a framework-agnostic infinite canvas library and want to support our work, leave us a star or consider becoming a sponsor.