Summary
Extract a shared utility to compute bounds for node positions and use it in minimap and SVG export code.
Why
Both draw_minimap and export_to_svg iterate all positions to compute (min_x, max_x, min_y, max_y) with near-identical logic.
Affected files
- src/ui/drawing.rs
- src/ui/export.rs
Extraction plan
- Add utility like
positions_bounds(&HashMap<String, Pos2>) -> Option<(f32, f32, f32, f32)>.
- Reuse utility in
draw_minimap world-bounds calculation.
- Reuse utility in
export_to_svg and keep padding behavior local to export.
- Add tests for empty/non-empty bounds.
Risk
Low. Shared numeric helper; small risk of changing empty-state behavior if not preserved.
Acceptance criteria
- Single bounds utility used by both minimap and SVG export.
- Empty-position behavior unchanged.
- Tests pass.
Summary
Extract a shared utility to compute bounds for node positions and use it in minimap and SVG export code.
Why
Both
draw_minimapandexport_to_svgiterate all positions to compute(min_x, max_x, min_y, max_y)with near-identical logic.Affected files
Extraction plan
positions_bounds(&HashMap<String, Pos2>) -> Option<(f32, f32, f32, f32)>.draw_minimapworld-bounds calculation.export_to_svgand keep padding behavior local to export.Risk
Low. Shared numeric helper; small risk of changing empty-state behavior if not preserved.
Acceptance criteria