Editor's Path Properties has 'Path length' but no 'Bounding box' (width × height) — user wanting to know the path's extents (for fit-to-view, alignment) has to compute from the nodes #356

Closed
opened 2026-10-04 03:56:43 +00:00 by Mark · 1 comment
Owner

Finding

grep -rn 'boundingBox\|pathBoundingBox' src/components/editor/EditorRightPanel.tsx returns 0. The right panel doesn't show the path's bounding box.

A user with a path:

  • Wants to know the width and height (e.g., 50mm × 30mm)
  • For fit-to-view
  • For alignment with other paths
  • The "length" is the perimeter, not the bounding box

The fix is to add bounding box dimensions.

Where

  • Path Properties: src/components/editor/EditorRightPanel.tsx
  • No bounding box: grep -rn 'pathBoundingBox' src/components/editor/ returns 0
  • The geometry: src/components/editor/geometry.ts (the pathBoundingBox function exists; it's just not displayed)

Suggested fix shape

  1. UI: in the Path Properties section, add "Bounding box" displays:
<div className="text-[11px]">
  Bounding box: {bbox.width.toFixed(2)} × {bbox.height.toFixed(2)} mm
</div>
  1. Position: the bounding box's (x, y) — i.e., where the top-left corner is:
<div className="text-[11px]">
  Top-left: ({bbox.x.toFixed(2)}, {bbox.y.toFixed(2)}) mm
</div>
  1. Visual: the bounding box is drawn on the canvas as a faint dashed line (already in place per the canvasRenderer?).

  2. Use cases:

  • Fit-to-view (the F key uses the bounding box)
  • Alignment (e.g., "make these two paths have the same width")
  • Export preview

Severity

Low. The user can compute. Power users notice.

Discovered by

Gap analysis (2026-10-02) of editor path properties.

  • #353 (open) — Position input. The bounding box's (x, y) is the position.
  • The geometry module's pathBoundingBox is the source.
  • Figma shows the bounding box. Standard.
## Finding `grep -rn 'boundingBox\|pathBoundingBox' src/components/editor/EditorRightPanel.tsx` returns 0. The right panel doesn't show the path's bounding box. A user with a path: - Wants to know the width and height (e.g., 50mm × 30mm) - For fit-to-view - For alignment with other paths - The "length" is the perimeter, not the bounding box The fix is to add bounding box dimensions. ## Where - Path Properties: `src/components/editor/EditorRightPanel.tsx` - No bounding box: `grep -rn 'pathBoundingBox' src/components/editor/` returns 0 - The geometry: `src/components/editor/geometry.ts` (the `pathBoundingBox` function exists; it's just not displayed) ## Suggested fix shape 1. **UI**: in the Path Properties section, add "Bounding box" displays: ```tsx <div className="text-[11px]"> Bounding box: {bbox.width.toFixed(2)} × {bbox.height.toFixed(2)} mm </div> ``` 2. **Position**: the bounding box's (x, y) — i.e., where the top-left corner is: ```tsx <div className="text-[11px]"> Top-left: ({bbox.x.toFixed(2)}, {bbox.y.toFixed(2)}) mm </div> ``` 3. **Visual**: the bounding box is drawn on the canvas as a faint dashed line (already in place per the canvasRenderer?). 4. **Use cases**: - Fit-to-view (the F key uses the bounding box) - Alignment (e.g., "make these two paths have the same width") - Export preview ## Severity Low. The user can compute. Power users notice. ## Discovered by Gap analysis (2026-10-02) of editor path properties. ## Related - #353 (open) — Position input. The bounding box's (x, y) is the position. - The geometry module's `pathBoundingBox` is the source. - Figma shows the bounding box. Standard.
Author
Owner

Shipped in commit 547222c. Two new rows in Path Statistics (right panel, node-edit mode):

  • Bounding box: W × H in mm, e.g. 20.00 × 20.00 mm. Includes control handles, so a smooth node whose handles extend past the anchors reports a larger box than the anchors alone.
  • Top-left: (x, y) of the bbox upper-left corner in path coordinates (mm). A path anchored at origin reports (0.00, 0.00).

Both source from the existing pathBoundingBox(geometry) helper — the same one the canvas transform handlers use as the flip / mirror / rotate pivot and the canvas editor selects on. So the numbers match what fit-to-view (F), flip, mirror, and rotate see.

Renders alongside Path Length / Stitches / Path area / Perimeter / Thread usage / Stitch time / Fabric coverage — sibling rows, same commit-and-format style.

6 new tests in src/components/editor/issue-356.test.tsx pin:

  • basic 2-node path (W × H + top-left)
  • negative-origin paths ((-25, -15) to (25, 15) → 50 × 30 mm, top-left (-25, -15))
  • bezier handle extension (smooth node with controlOut past anchors grows the bbox)
  • no-selection gate hides both rows
  • spatial order: bbox → top-left → area

Closes #356.

Shipped in commit 547222c. Two new rows in Path Statistics (right panel, node-edit mode): - **Bounding box**: W × H in mm, e.g. `20.00 × 20.00 mm`. Includes control handles, so a smooth node whose handles extend past the anchors reports a larger box than the anchors alone. - **Top-left**: (x, y) of the bbox upper-left corner in path coordinates (mm). A path anchored at origin reports `(0.00, 0.00)`. Both source from the existing `pathBoundingBox(geometry)` helper — the same one the canvas transform handlers use as the flip / mirror / rotate pivot and the canvas editor selects on. So the numbers match what fit-to-view (F), flip, mirror, and rotate see. Renders alongside Path Length / Stitches / Path area / Perimeter / Thread usage / Stitch time / Fabric coverage — sibling rows, same commit-and-format style. 6 new tests in `src/components/editor/issue-356.test.tsx` pin: - basic 2-node path (W × H + top-left) - negative-origin paths (`(-25, -15)` to `(25, 15)` → `50 × 30` mm, top-left `(-25, -15)`) - bezier handle extension (smooth node with `controlOut` past anchors grows the bbox) - no-selection gate hides both rows - spatial order: bbox → top-left → area Closes #356.
Mark closed this issue 2026-10-05 12:59:13 +00:00
Sign in to join this conversation.
No description provided.