Update FloorPlan spec: fix coord mapping, clamping, pointercancel, label placement
Browse files
docs/superpowers/specs/2026-03-14-floorplan-design.md
CHANGED
|
@@ -38,7 +38,9 @@ Gradio Custom Component (Svelte + SVG), integrated as a first-class `gr.Componen
|
|
| 38 |
}
|
| 39 |
```
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
| 42 |
|
| 43 |
---
|
| 44 |
|
|
@@ -67,8 +69,9 @@ SVG rect: `x = xmin`, `y = ymin`, `width = xmax - xmin`, `height = ymax - ymin`.
|
|
| 67 |
## Drag Interaction
|
| 68 |
|
| 69 |
1. `pointerdown` on a furniture `<g>` β mark as active, record pointer start position, apply highlight style (distinct stroke color + increased opacity)
|
| 70 |
-
2. `pointermove` on the `<svg>` β update active furniture's `(dx, dy)` offset in real time
|
| 71 |
-
3. `pointerup` anywhere β clear active state, compute new
|
|
|
|
| 72 |
|
| 73 |
Highlight state: active box gets a contrasting stroke color (e.g. orange) so the user clearly sees what is being moved.
|
| 74 |
|
|
@@ -104,7 +107,7 @@ Highlight state: active box gets a contrasting stroke color (e.g. orange) so the
|
|
| 104 |
- Room polygon: dark stroke (`#333`), no fill, stroke-width 2
|
| 105 |
- Furniture rect (default): semi-transparent fill (e.g. `rgba(100, 149, 237, 0.3)`), colored stroke
|
| 106 |
- Furniture rect (active/dragging): orange stroke (`#f97316`), higher opacity
|
| 107 |
-
- Label text: small, centered
|
| 108 |
|
| 109 |
---
|
| 110 |
|
|
@@ -114,3 +117,4 @@ Highlight state: active box gets a contrasting stroke color (e.g. orange) so the
|
|
| 114 |
- Snapping furniture to walls or grid
|
| 115 |
- Multi-select or grouping furniture
|
| 116 |
- Persisting positions beyond the Gradio session
|
|
|
|
|
|
| 38 |
}
|
| 39 |
```
|
| 40 |
|
| 41 |
+
`localisation` index mapping: `[0]=ymin`, `[1]=xmin`, `[2]=ymax`, `[3]=xmax`.
|
| 42 |
+
|
| 43 |
+
Coordinates are in pixels, matching the SVG viewport. Input coordinates are assumed to fit within the fixed SVG viewport β behavior for out-of-bounds input is undefined.
|
| 44 |
|
| 45 |
---
|
| 46 |
|
|
|
|
| 69 |
## Drag Interaction
|
| 70 |
|
| 71 |
1. `pointerdown` on a furniture `<g>` β mark as active, record pointer start position, apply highlight style (distinct stroke color + increased opacity)
|
| 72 |
+
2. `pointermove` on the `<svg>` β update active furniture's `(dx, dy)` offset in real time; clamp so the box stays fully within the SVG viewport
|
| 73 |
+
3. `pointerup` anywhere β clear active state, compute new `localisation`: `new_xmin = xmin + dx`, `new_ymin = ymin + dy`, `new_xmax = xmax + dx`, `new_ymax = ymax + dy` (preserving `(ymin, xmin, ymax, xmax)` order), then emit updated `furnitures` to Gradio
|
| 74 |
+
4. `pointercancel` β revert the furniture to its original position, clear active state, do not emit
|
| 75 |
|
| 76 |
Highlight state: active box gets a contrasting stroke color (e.g. orange) so the user clearly sees what is being moved.
|
| 77 |
|
|
|
|
| 107 |
- Room polygon: dark stroke (`#333`), no fill, stroke-width 2
|
| 108 |
- Furniture rect (default): semi-transparent fill (e.g. `rgba(100, 149, 237, 0.3)`), colored stroke
|
| 109 |
- Furniture rect (active/dragging): orange stroke (`#f97316`), higher opacity
|
| 110 |
+
- Label text: small, centered inside the rect, dark color
|
| 111 |
|
| 112 |
---
|
| 113 |
|
|
|
|
| 117 |
- Snapping furniture to walls or grid
|
| 118 |
- Multi-select or grouping furniture
|
| 119 |
- Persisting positions beyond the Gradio session
|
| 120 |
+
- Input coordinates outside the fixed SVG viewport bounds
|