Skip to content

refactor(svg): extract tower-path rendering into a standalone buildTowerPaths() helper #288

@JhaSourav07

Description

@JhaSourav07

🧩 Background

Both generateSVG and generateAutoThemeSVG in lib/svg/generator.ts contain a near-identical for loop that builds tower SVG strings. This duplicates ~30 lines of complex geometry logic.

🎯 Objective

Extract the loop body into a buildTowerPaths(towers, accent, autoTheme) helper so each renderer calls one function.

📁 Files to touch

  • lib/svg/generator.ts

🛠️ Implementation steps

  • Create function buildTowerPaths(towers: TowerData[], accent: string, autoTheme: boolean): string.
  • Move the shared loop body into it.
  • Call it from both generateSVG and generateAutoThemeSVG.

✅ Definition of done

  • Both renderers delegate to the new helper.
  • All SVG generator tests pass unchanged.
  • No observable change in SVG output.

Metadata

Metadata

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions