Skip to content

SVG markers: a zero-length closepath takes the first segment's direction - #151

Merged
Malcolmnixon merged 1 commit into
mainfrom
fix/svg-zero-length-close
Nov 17, 2026
Merged

Malcolmnixon merged 1 commit into
mainfrom
fix/svg-zero-length-close

Conversation

@Malcolmnixon

Copy link
Copy Markdown
Member

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:

  • the start and end markers point along the first segment;
  • a marker-mid at the last explicit vertex bisects the segment before it and the first segment.

BuildMarkerVertices now 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code quality improvement

Related Issues

Follow-up to #150.

Pre-Submission Checklist

Before submitting this pull request, ensure you have completed the following:

Build and Test

  • Code builds successfully and all tests pass: pwsh ./build.ps1 (passed, 0 failures)
  • Code produces zero warnings

Code Quality

  • New code has appropriate XML documentation comments
  • Static analyzer warnings have been addressed

Quality Checks

Please run the following checks before submitting:

  • All linters pass: pwsh ./lint.ps1 (passed)

Testing

  • Added unit tests for new functionality
  • Updated existing tests if behavior changed
  • All tests follow the AAA (Arrange, Act, Assert) pattern
  • Test coverage is maintained or improved

Documentation

  • Updated README.md (if applicable)
  • Updated docs/ documentation (if applicable)
  • Added code examples for new features (if applicable)
  • Updated requirements.yaml (if applicable)

Additional Notes

The test SvgArrow_BuildMarkerVertices_ZeroLengthClose_UsesThePreviousSegment is renamed ..._UsesTheFirstSegment, and the reqstream, design, and verification text is updated to match.

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>
Copilot AI lite review requested due to automatic review settings November 17, 2026 17:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 BuildMarkerVertices to 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

@Malcolmnixon
Malcolmnixon merged commit 1bd44c2 into main Nov 17, 2026
13 checks passed
@Malcolmnixon
Malcolmnixon deleted the fix/svg-zero-length-close branch November 17, 2026 18:42
This was referenced Nov 20, 2026
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.

2 participants