Skip to content

Draw Item

Represents a pen stroke drawn on the canvas. Draw items are created automatically when the user draws in freehand or straight line mode.

Creating a Draw Item

Draw items are created by the user through the useDraw hook. To activate freehand or straight drawing:

tsx
const { changeDrawMode, setDrawType } = useDraw()

// Freehand stroke
setDrawType('free')
changeDrawMode('draw')

// Straight line
setDrawType('straight')
changeDrawMode('draw')

Each completed stroke is automatically saved as a Draw item on the canvas.

Properties

All properties below are passed inside itemProps.

PropertyTypeDescription
pointsnumber[]Flattened array of stroke coordinates [x0, y0, x1, y1, ...]. Required.
colorstringStroke color (hex). Required.
strokeWidthnumberStroke thickness in pixels. Required.
strokeStyle'solid' | 'doodle'Stroke rendering style.
dashnumber[]Dash pattern (e.g. [10, 5] for dashed lines).

Notes

  • points is a flattened coordinate array, not an array of objects.
  • The active drawing settings (drawColor, drawStrokeWidth, drawStrokeStyle, drawDash) from useDraw are applied automatically when a stroke is completed.

Released under a proprietary license.