---
id: TASK-29
title: Port folk-drawfast shape (collaborative drawing/gesture recognition)
status: Done
assignee: []
created_date: '2026-02-18 19:50'
updated_date: '2026-04-10 21:28'
labels:
  - shape-port
  - phase-2
  - creative
milestone: m-0
dependencies:
  - TASK-24
references:
  - canvas-website/src/shapes/DrawfastShapeUtil.tsx
priority: low
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Port DrawfastShapeUtil from canvas-website to rspace-online.

Source: canvas-website/src/shapes/DrawfastShapeUtil.tsx (652 lines)
Target: rspace-online/lib/folk-drawfast.ts

Features to implement:
- Freehand sketch input canvas
- Gesture recognition (circles, lines, rectangles, arrows)
- Shape detection and conversion
- Real-time collaborative drawing
- May use perfect-freehand (already in rspace deps)
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Freehand drawing works with pointer/touch input
- [x] #2 Gesture recognition detects basic shapes
- [x] #3 Drawing state syncs across clients
- [x] #4 Toolbar button added to canvas.html
<!-- AC:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
2026-04-10: Added AI sketch-to-image generation (fal.ai + Gemini via /api/image-gen/img2img). Split-view layout with drawing canvas + AI result. Auto-generate toggle, strength slider, provider selector. Image preloading for smooth transitions. Port descriptors for folk-arrow connections. AC#1 (freehand drawing) and AC#4 (toolbar button) were already implemented. AC#2 (gesture recognition) and AC#3 (collaborative sync) still outstanding.

AC#2: Implemented  Unistroke Recognizer with templates for circle, rectangle, triangle, line, arrow, checkmark. Freehand strokes matching >70% confidence are auto-converted to clean geometric shapes with a floating badge. AC#3: Fixed applyData() to restore strokes array, prompt text, and last result URL from Automerge sync data. toJSON() now exports prompt text for sync.
<!-- SECTION:NOTES:END -->
