Repository navigation
Conversation
This branch has not been deployed
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.
Closes #284.
Selecting
ConnectionOffsetMode.Rectanglewithout also changing the offset made horizontal connections disappear: the offset vector came outNaN, so the whole geometry was non-finite and nothing was drawn. No exception, no warning.The face-selection test in
GetRectangleModeOffsetdecides which side of the offset rectangle the connection leaves through:The default offset is
new Size(14, 0)(BoxValue.ConnectionOffset), soHeightis zero. For a horizontal connection both sides of that comparison are zero —14 * 2 * 0against0 * 2 * 1— and<is false, so it took theelsebranch, which is the one that needs a vertical component to scale against:result.Y = Math.Sign(0) * 0→0angle = Math.Atan2(0, 1)→0, so1.0 / Math.Tan(0)→InfinityInfinity * 0→NaNThe mirrored direction was wrong too, but quietly: for a right-to-left connection
angleisMath.PIandMath.Tan(Math.PI)is-1.2246e-16rather than exactly zero, so the same expression yields-0— finite, but no offset applied at all. So of the two horizontal directions one producedNaNand one produced nothing, and which you got depended on floating-point rounding.The guard returns what the
ifbranch would have produced for that case:offset.Widthalong X, in the direction of travel.On the shape of the fix
The underlying cause is arguably the comparison being strict, so a degenerate zero-height offset lands in the wrong branch. Making it
<=reaches the same answer and is a smaller diff. I kept the explicit guard because it is provably unchanged everywhere except where the result wasNaNor-0, whereas<=alters branch selection for any input where the two products are exactly equal — a set I have not characterised. Happy to switch to<=if you prefer it; the behaviour I measured is identical on the cases I tested.Proof
The repo has no test project, so this is a console app that references
Nodify.csproj, drives the geometry and reads the result two independent ways — the offset vector and every control point of the producedGeometry, checking each withdouble.IsFinite. One accessor cannot fake success.Before:
After, all finite, and the diagonal and vertical controls byte-identical to before.
dotnet build Nodify.sln→Ошибок: 0, and noCSwarnings underNodify/. Changelog entry added.Possible drawbacks
This is a deliberate behaviour change on a case that did not crash. A right-to-left horizontal connection previously got a silently-dropped
-0offset and now gets a real-offset.Width, which is a visible 14px shift in that configuration. Anyone who had settled onRectangleplus a zero-height offset and was relying on the resulting no-op would see connections move. I think that is the right trade, since the other direction was drawing nothing at all, but it is a change and not purely a fix.Cases where
delta.Y != 0are byte-identical before and after — verified by diffing the harness output rather than by inspection.Only
net10.0-windowswas executed at runtime; the other seven target frameworks are compile-verified through the solution build.net472/net48are pinned toLangVersion8.0 and the added ternary is C# 7 syntax, so it compiles there, but no runtime check ran on them. And the geometry is proven numerically — I have not confirmed how it looks in a rendered window.