Skip to content

SVG export: add 'Z' close-path command for closed contours - #1737

Merged
phkahler merged 1 commit into
solvespace:masterfrom
AnibalPinto:master-issue1368
Aug 13, 2026
Merged

SVG export: add 'Z' close-path command for closed contours#1737
phkahler merged 1 commit into
solvespace:masterfrom
AnibalPinto:master-issue1368

Conversation

@AnibalPinto

Copy link
Copy Markdown
Contributor

Fixes #1368.

For closed paths (loops), the SVG path definition now ends with 'Z' to explicitly close the path, rather than relying on the last point being equal to the first point.

  • Add virtual ClosePath() method to VectorFileWriter base class
  • Override ClosePath() in SvgFileWriter to emit ' Z'
  • Call ClosePath() in OutputLinesAndMesh when SBezierLoop::IsClosed()
  • Add export/svg/closed_path_has_z test case

@phkahler

phkahler commented Jul 18, 2026

Copy link
Copy Markdown
Member

@AnibalPinto It might be better to add a "IsClosed" flag for the FinishPath function and pass the flag to that. Then in the SVG version of FinishPath, check the flag and output the Z as needed there. I think this is maybe better than adding a new virtual function just for this. This is also something we don't need a test case for.

@AnibalPinto

Copy link
Copy Markdown
Contributor Author

@phkahler thanks for the notification. It changes more code but avoid more functions.

I tried to use clang to check format but or I am doing something wrong or format isn't used.

@ruevs
ruevs force-pushed the master-issue1368 branch from 4733e6c to 5bdeccc Compare August 3, 2026 18:20
Fixes solvespace#1368.

For closed paths (loops), the SVG path definition now ends with 'Z' to
explicitly close the path, rather than relying on the last point being
equal to the first point.

Modified FinishPath with information if path is closed and SVG export
append an Z when path is closed.
@phkahler

Copy link
Copy Markdown
Member

Thanks for this. Better file output is always good.

@phkahler
phkahler merged commit 1b7bc42 into solvespace:master Aug 13, 2026
4 checks passed
@AnibalPinto
AnibalPinto deleted the master-issue1368 branch August 13, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SVG export: for closed paths, svg path definition should contain a final "Z"

2 participants