Skip to content

DRY: share node-position bounds computation #77

@lowhung

Description

@lowhung

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions