Remove tiny jog segments (<8px) from SVG edge path rendering
Small boundary adjustment segments (4px, 19px) create weird kinks when the 40px corner radius is applied. Filter them out before building the rounded path — connect the surrounding points directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2037,15 +2037,37 @@ public sealed class WorkflowRenderSvgRenderer
|
||||
return $"M {Format(points[0].X + offsetX)},{Format(points[0].Y + offsetY)} L {Format(points[1].X + offsetX)},{Format(points[1].Y + offsetY)}";
|
||||
}
|
||||
|
||||
// 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++)
|
||||
{
|
||||
var prev = cleaned[^1];
|
||||
var curr = points[i];
|
||||
var next = points[i + 1];
|
||||
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)
|
||||
{
|
||||
// Skip this tiny segment — connect prev directly to next
|
||||
continue;
|
||||
}
|
||||
|
||||
cleaned.Add(curr);
|
||||
}
|
||||
|
||||
cleaned.Add(points[^1]);
|
||||
|
||||
var builder = new StringBuilder();
|
||||
var p0 = points[0];
|
||||
var p0 = cleaned[0];
|
||||
builder.Append($"M {Format(p0.X + offsetX)},{Format(p0.Y + offsetY)}");
|
||||
|
||||
for (var index = 1; index < points.Count - 1; index++)
|
||||
for (var index = 1; index < cleaned.Count - 1; index++)
|
||||
{
|
||||
var prev = points[index - 1];
|
||||
var curr = points[index];
|
||||
var next = points[index + 1];
|
||||
var prev = cleaned[index - 1];
|
||||
var curr = cleaned[index];
|
||||
var next = cleaned[index + 1];
|
||||
|
||||
var dxIn = curr.X - prev.X;
|
||||
var dyIn = curr.Y - prev.Y;
|
||||
@@ -2071,7 +2093,7 @@ public sealed class WorkflowRenderSvgRenderer
|
||||
builder.Append($" Q {Format(curr.X + offsetX)},{Format(curr.Y + offsetY)} {Format(departX + offsetX)},{Format(departY + offsetY)}");
|
||||
}
|
||||
|
||||
var last = points[^1];
|
||||
var last = cleaned[^1];
|
||||
builder.Append($" L {Format(last.X + offsetX)},{Format(last.Y + offsetY)}");
|
||||
|
||||
return builder.ToString();
|
||||
|
||||
Reference in New Issue
Block a user