Repository navigation
SVG markers: a zero-length closepath takes the first segment's direction - #151
Merged
Merged
Conversation
Matches Edge: the start and end markers of a closed subpath whose last point already equals its first point along the first segment, and the last explicit vertex bisects the segment before it and the first segment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the change is supported by updated implementation, regression coverage, and synchronized documentation for zero-length closepath marker orientation.
No open issues 🎉
What changed in this PR
This pull request corrects SVG marker orientation for closed subpaths whose explicit final point equals the starting point. Zero-length closepaths now use the first segment’s direction, matching Edge/browser behavior, while preserving normal closepath handling and updating related tests and documentation.
Changes:
- Updated
BuildMarkerVerticesto use the first segment’s tangent for zero-length closepaths. - Renamed and revised the marker geometry regression test.
- Synchronized design, verification, and ReqStream documentation.
| File | Description |
|---|---|
| test/DemaConsulting.CanvasNet.Svg.Tests/SvgArrowTests.cs | Renames and updates the regression test to verify marker orientations for zero-length closepaths. |
| src/DemaConsulting.CanvasNet.Svg/SvgCodec.Markers.cs | Uses the first segment direction as the tangent fallback for zero-length closing segments. |
| docs/verification/canvas-net-svg/svg-codec.md | Updates verification evidence, test references, and expected zero-length closepath behavior. |
| docs/reqstream/canvas-net-svg/svg-codec.yaml | Updates the linked verification test identifier. |
| docs/design/canvas-net-svg/svg-codec.md | Documents the browser-compatible first-segment direction rule for zero-length closepaths. |
Review effort: Lite
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Follow-up to #150, whose final review summary noted an overlooked zero-length closepath edge case.
When a closed subpath's last explicit point already equals its first point (
M30,30 L150,30 L150,150 L30,30 Z), the closing segment has zero length. CanvasNet gave it the direction of the segment before it, so the start and end markers bisected that segment and the first one. Edge instead gives a zero-length closepath the direction of the subpath's first segment:marker-midat the last explicit vertex bisects the segment before it and the first segment.BuildMarkerVerticesnow follows Edge. Closepaths of non-zero length are unchanged. Comparison sheets (start, end, and mid markers on a zero-length-close triangle, a zero-length-close square, and a normal closed square) rendered by Edge headless and by CanvasNet now match.Type of Change
Related Issues
Follow-up to #150.
Pre-Submission Checklist
Before submitting this pull request, ensure you have completed the following:
Build and Test
pwsh ./build.ps1(passed, 0 failures)Code Quality
Quality Checks
Please run the following checks before submitting:
pwsh ./lint.ps1(passed)Testing
Documentation
Additional Notes
The test
SvgArrow_BuildMarkerVertices_ZeroLengthClose_UsesThePreviousSegmentis renamed..._UsesTheFirstSegment, and the reqstream, design, and verification text is updated to match.