Fix tiny jog removal: snap next point axis to prevent diagonals
When removing a <8px jog segment, snap the next point's changed axis to the previous point's value. Without this, removing the jog creates a diagonal segment that produces a visible S-curve kink at the 40px corner radius. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2038,27 +2038,35 @@ public sealed class WorkflowRenderSvgRenderer
|
||||
}
|
||||
|
||||
// Remove tiny jog segments (< 8px) that create weird curves.
|
||||
// These are routing artifacts from small boundary adjustments.
|
||||
var cleaned = new List<WorkflowRenderPoint> { points[0] };
|
||||
for (var i = 1; i < points.Count - 1; i++)
|
||||
// When removing a jog, snap the next point to the previous point's
|
||||
// axis so we get a clean L-shape instead of a diagonal.
|
||||
var mutablePoints = points.ToList();
|
||||
var cleaned = new List<WorkflowRenderPoint> { mutablePoints[0] };
|
||||
for (var i = 1; i < mutablePoints.Count; i++)
|
||||
{
|
||||
var prev = cleaned[^1];
|
||||
var curr = points[i];
|
||||
var next = points[i + 1];
|
||||
var curr = mutablePoints[i];
|
||||
var dxIn = Math.Abs(curr.X - prev.X);
|
||||
var dyIn = Math.Abs(curr.Y - prev.Y);
|
||||
var segLen = dxIn + dyIn;
|
||||
if (segLen < 8d && i < points.Count - 2)
|
||||
if (segLen < 8d && i < mutablePoints.Count - 1)
|
||||
{
|
||||
// Skip this tiny segment — connect prev directly to next
|
||||
var next = mutablePoints[i + 1];
|
||||
if (dxIn < dyIn)
|
||||
{
|
||||
mutablePoints[i + 1] = new WorkflowRenderPoint { X = next.X, Y = prev.Y };
|
||||
}
|
||||
else
|
||||
{
|
||||
mutablePoints[i + 1] = new WorkflowRenderPoint { X = prev.X, Y = next.Y };
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
cleaned.Add(curr);
|
||||
}
|
||||
|
||||
cleaned.Add(points[^1]);
|
||||
|
||||
var builder = new StringBuilder();
|
||||
var p0 = cleaned[0];
|
||||
builder.Append($"M {Format(p0.X + offsetX)},{Format(p0.Y + offsetY)}");
|
||||
|
||||
Reference in New Issue
Block a user